Skip to content

Commit 0e5444e

Browse files
authored
Fix storing final state upon preequilibration failures (#2883)
If preequlibration fails, don't try to use the final state of the main simulation. Fixes #2857
1 parent d6613f8 commit 0e5444e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

include/amici/forwardproblem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,12 @@ class ForwardProblem {
794794
return pre_simulator_.result;
795795
}
796796

797+
/**
798+
* @brief Whether pre-equilibration was performed successfully.
799+
* @return
800+
*/
801+
bool was_preequilibrated() const { return preequilibrated_; }
802+
797803
/** pointer to model instance */
798804
Model* model;
799805

src/rdata.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ void ReturnData::processSimulationObjects(
198198
posteq_bwd = bwd->getPostequilibrationBwdProblem();
199199
}
200200
}
201-
202201
if (preeq)
203202
processPreEquilibration(*preeq, preeq_bwd, model);
204203

@@ -210,7 +209,11 @@ void ReturnData::processSimulationObjects(
210209
if (posteq)
211210
processPostEquilibration(*posteq, posteq_bwd, model, edata);
212211

213-
if (fwd && !posteq)
212+
if (edata && !edata->fixedParametersPreequilibration.empty() && fwd
213+
&& !fwd->was_preequilibrated() && preeq) {
214+
// failure during preequilibration
215+
storeJacobianAndDerivativeInReturnData(*preeq, model);
216+
} else if (fwd && !posteq)
214217
storeJacobianAndDerivativeInReturnData(*fwd, model);
215218
else if (posteq)
216219
storeJacobianAndDerivativeInReturnData(*posteq, model);

0 commit comments

Comments
 (0)