25#include <boost/algorithm/string.hpp>
26#include <boost/algorithm/string/case_conv.hpp>
27#include <boost/algorithm/string/trim.hpp>
28#include <boost/lexical_cast.hpp>
29#include <boost/tokenizer.hpp>
47 std::ostringstream oss;
48 if (grid->tenors().size() == 0) {
51 oss << grid->tenors()[0];
52 for (Size i = 1; i < grid->tenors().
size(); i++) {
53 oss <<
", " << grid->tenors()[i];
69 DayCounter dc = dcString.empty() ? ActualActual(ActualActual::ISDA) :
parseDayCounter(dcString);
72 std::vector<std::string> tokens;
73 boost::split(tokens,
gridString_, boost::is_any_of(
","));
74 if (tokens.size() <= 2) {
78 grid_ = QuantLib::ext::make_shared<DateGrid>(gridTenors, cal, dc);
80 LOG(
"ScenarioGeneratorData grid points size = " <<
grid_->size());
84 LOG(
"ScenarioGeneratorData sequence type = " << sequenceTypeString);
87 LOG(
"ScenarioGeneratorData seed = " <<
seed_);
90 LOG(
"ScenarioGeneratorData samples = " <<
samples_);
93 if (
auto c = getenv(
"OVERWRITE_SCENARIOGENERATOR_SAMPLES")) {
96 }
catch (
const std::exception& e) {
97 WLOG(
"enviroment variable OVERWRITE_SCENARIOGENERATOR_SAMPLES is set ("
98 << c <<
") but can not be parsed to a number - ignoring.");
100 LOG(
"Overwrite samples with " <<
samples_ <<
" from environment variable OVERWRITE_SCENARIOGENERATOR_SAMPLES")
106 ordering_ = SobolBrownianGenerator::Steps;
123 if (mporMode ==
"StickyDate") {
125 LOG(
"Use Mpor sticky date mode");
126 }
else if (mporMode ==
"ActualDate") {
128 LOG(
"Use Mpor actual date mode");
130 QL_FAIL(
"MporMode " << mporMode <<
" not recognised");
134 LOG(
"ScenarioGeneratorData done.");
SobolBrownianGenerator::Ordering ordering_
SobolRsg::DirectionIntegers directionIntegers_
QuantLib::ext::shared_ptr< DateGrid > grid_
virtual void fromXML(XMLNode *node) override
Load members from XML.
virtual XMLNode * toXML(XMLDocument &doc) const override
Write members to XML.
SequenceType sequenceType_
void setGrid(QuantLib::ext::shared_ptr< DateGrid > grid)
XMLNode * allocNode(const string &nodeName)
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
static void checkNode(XMLNode *n, const string &expectedName)
static XMLNode * locateNode(XMLNode *n, const string &name="")
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static vector< Period > getChildrenValuesAsPeriods(XMLNode *node, const string &name, bool mandatory=false)
Calendar parseCalendar(const string &s)
SequenceType parseSequenceType(const std::string &s)
Period parsePeriod(const string &s)
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers(const std::string &s)
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering(const std::string &s)
DayCounter parseDayCounter(const string &s)
Size size(const ValueType &v)
std::string to_string(const LocationInfo &l)
Build a scenariogenerator.
factory classes for simple scenarios