Block decomposition: bugfix for solve one boundary blocks with mfs>0

Ref. dynare#1726
issue#70
Sébastien Villemot 2020-10-07 18:52:34 +02:00
parent e736b9234f
commit 740ea833f6
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 5 additions and 4 deletions

View File

@ -411,10 +411,11 @@ DynamicModel::writeDynamicPerBlockHelper(int blk, ostream &output, ExprNodeOutpu
for (const auto &[indices, d] : blocks_derivatives[blk])
{
auto [eq, var, lag] = indices;
if (lag == 0)
if (lag == 0 && eq >= block_recursive_size && var >= block_recursive_size)
{
i_output << " g1_i" << LEFT_ARRAY_SUBSCRIPT(output_type) << line_counter
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << '=' << eq+1 << ';' << endl;
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << '='
<< eq+1-block_recursive_size << ';' << endl;
j_output << " g1_j" << LEFT_ARRAY_SUBSCRIPT(output_type) << line_counter
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << '='
<< var+1-block_recursive_size << ';' << endl;
@ -473,9 +474,9 @@ DynamicModel::nzeDeterministicJacobianForBlock(int blk) const
|| simulation_type == BlockSimulationType::solveBackwardComplete
|| simulation_type == BlockSimulationType::solveForwardComplete)
nze_deterministic = count_if(blocks_derivatives[blk].begin(), blocks_derivatives[blk].end(),
[](const auto &kv) {
[=](const auto &kv) {
auto [eq, var, lag] = kv.first;
return lag == 0;
return lag == 0 && eq >= block_recursive_size && var >= block_recursive_size;
});
return nze_deterministic;
}