Block decomposition: fix crash when a variable appears in an equation but has zero symbolic derivative
parent
5d1264e2b9
commit
9b04c5436e
|
@ -4441,7 +4441,11 @@ DynamicModel::computeChainRuleJacobian()
|
||||||
switch (derivType)
|
switch (derivType)
|
||||||
{
|
{
|
||||||
case BlockDerivativeType::standard:
|
case BlockDerivativeType::standard:
|
||||||
d = derivatives[1][{ eq_orig, deriv_id }];
|
if (auto it = derivatives[1].find({ eq_orig, deriv_id });
|
||||||
|
it != derivatives[1].end())
|
||||||
|
d = it->second;
|
||||||
|
else
|
||||||
|
d = Zero;
|
||||||
break;
|
break;
|
||||||
case BlockDerivativeType::chainRule:
|
case BlockDerivativeType::chainRule:
|
||||||
d = equations[eq_orig]->getChainRuleDerivative(deriv_id, recursive_vars);
|
d = equations[eq_orig]->getChainRuleDerivative(deriv_id, recursive_vars);
|
||||||
|
|
|
@ -106,7 +106,7 @@ protected:
|
||||||
For each derivation order, stores a map whose key is a vector of integer: the
|
For each derivation order, stores a map whose key is a vector of integer: the
|
||||||
first integer is the equation index, the remaining ones are the derivation
|
first integer is the equation index, the remaining ones are the derivation
|
||||||
IDs of variables (in non-decreasing order, to avoid storing symmetric
|
IDs of variables (in non-decreasing order, to avoid storing symmetric
|
||||||
elements several times) */
|
elements several times). Only non-zero derivatives are stored. */
|
||||||
vector<map<vector<int>, expr_t>> derivatives;
|
vector<map<vector<int>, expr_t>> derivatives;
|
||||||
|
|
||||||
//! Number of non-zero derivatives
|
//! Number of non-zero derivatives
|
||||||
|
|
Loading…
Reference in New Issue