@@ -119,12 +119,12 @@ class ASTRunner : public AcyclicVisitor,
119119 public Visitor<LoopNode> {
120120public:
121121 ASTRunner (ComputationGraph& g, const std::vector<std::string>& opLabels, const boost::shared_ptr<ModelCG> model,
122- const bool generatePayLog, const std::string& script, bool & interactive, Context& context ,
123- ASTNode*& lastVisitedNode, std::set<std::size_t >& keepNodes,
122+ const bool generatePayLog, const bool includePastCashflows, const std::string& script, bool & interactive,
123+ Context& context, ASTNode*& lastVisitedNode, std::set<std::size_t >& keepNodes,
124124 std::vector<ComputationGraphBuilder::PayLogEntry>& payLogEntries)
125125 : g_(g), opLabels_(opLabels), model_(model), size_(model ? model->size () : 1), generatePayLog_(generatePayLog),
126- script_(script ), interactive_(interactive ), keepNodes_(keepNodes), payLogEntries_(payLogEntries ),
127- context_(context), lastVisitedNode_(lastVisitedNode) {
126+ includePastCashflows_(includePastCashflows ), script_(script ), interactive_(interactive ),
127+ keepNodes_(keepNodes), payLogEntries_(payLogEntries), context_(context), lastVisitedNode_(lastVisitedNode) {
128128 filter.emplace (size_, true );
129129 value.push (RandomVariable ());
130130 filter_node.push (ComputationGraph::nan);
@@ -1029,7 +1029,7 @@ class ASTRunner : public AcyclicVisitor,
10291029 QL_REQUIRE (model_, " model is null" );
10301030 // handle case of past payments: do not evaluate the other parameters, since not needed (e.g. past fixings)
10311031 Date pay = boost::get<EventVec>(paydate).value ;
1032- if (pay <= model_->referenceDate () && !log) {
1032+ if (pay <= model_->referenceDate () && ( !log || !includePastCashflows_) ) {
10331033 value.push (RandomVariable (size_, 0.0 ));
10341034 std::size_t node = cg_const (g_, 0.0 );
10351035 value_node.push (node);
@@ -1465,6 +1465,7 @@ class ASTRunner : public AcyclicVisitor,
14651465 const boost::shared_ptr<ModelCG> model_;
14661466 const Size size_;
14671467 const bool generatePayLog_;
1468+ const bool includePastCashflows_;
14681469 const std::string script_;
14691470 bool & interactive_;
14701471 std::set<std::size_t >& keepNodes_;
@@ -1481,14 +1482,15 @@ class ASTRunner : public AcyclicVisitor,
14811482
14821483} // namespace
14831484
1484- void ComputationGraphBuilder::run (const bool generatePayLog, const std::string& script, bool interactive) {
1485+ void ComputationGraphBuilder::run (const bool generatePayLog, const bool includePastCashflows, const std::string& script,
1486+ bool interactive) {
14851487
14861488 keepNodes_.clear ();
14871489 payLogEntries_.clear ();
14881490
14891491 ASTNode* loc;
1490- ASTRunner runner (g_, opLabels_, model_, generatePayLog, script, interactive, *context_, loc, keepNodes_ ,
1491- payLogEntries_);
1492+ ASTRunner runner (g_, opLabels_, model_, generatePayLog, generatePayLog && includePastCashflows, script, interactive ,
1493+ *context_, loc, keepNodes_, payLogEntries_);
14921494
14931495 randomvariable_output_pattern pattern;
14941496 if (model_ == nullptr || model_->type () == ModelCG::Type::MC) {
0 commit comments