27 const std::vector<Date>& dates,
const Size nSamples) {
28 DLOG(
"Build cloned scenario generator for " << dates.size() <<
" dates and " << nSamples <<
" samples.");
29 for (
size_t i = 0; i < dates.size(); ++i) {
33 scenarioGenerator->reset();
35 for (Size i = 0; i < nSamples; ++i) {
36 for (Size j = 0; j < dates.size(); ++j) {
37 scenarios_[i * dates.size() + j] = scenarioGenerator->next(dates[j])->clone();
46 auto stepIdx =
dates_.find(d);
47 QL_REQUIRE(stepIdx !=
dates_.end(),
"ClonedScenarioGenerator::next(" << d <<
"): invalid date " << d);
48 size_t timePos = stepIdx->second;
49 size_t currentStep = (
nSim_ - 1) *
dates_.size() + timePos;
51 "ClonedScenarioGenerator::next(" << d <<
"): no more scenarios stored.");
ClonedScenarioGenerator(const QuantLib::ext::shared_ptr< ScenarioGenerator > &scenarioGenerator, const std::vector< Date > &dates, const Size nSamples)
std::vector< QuantLib::ext::shared_ptr< Scenario > > scenarios_
QuantLib::ext::shared_ptr< Scenario > next(const Date &d) override
Return the next scenario for the given date.
virtual void reset() override
Reset the generator so calls to next() return the first scenario.
std::map< Date, size_t > dates_