Skip to content

Commit 1d68161

Browse files
authored
Always check for finite x0 (#1955)
Initial states should always be checked for finite values, not only with `Model.setAlwaysCheckFinite(True)`. As this only happens once per simulation, the overhead is negligible. Closes #1952
1 parent 1b4b02b commit 1d68161

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/model.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ void Model::initializeStates(AmiVector &x) {
305305
fx_solver(x0_solver.data(), x0data_.data());
306306
std::copy(x0_solver.cbegin(), x0_solver.cend(), x.data());
307307
}
308+
309+
checkFinite(x.getVector(), ModelQuantity::x0);
308310
}
309311

310312
void Model::initializeStateSensitivities(AmiVectorArray &sx,
@@ -1663,10 +1665,7 @@ void Model::fx0(AmiVector &x) {
16631665
state_.unscaledParameters.data(),
16641666
state_.fixedParameters.data());
16651667

1666-
if (always_check_finite_) {
1667-
checkFinite(derived_state_.x_rdata_, ModelQuantity::x0_rdata);
1668-
checkFinite(x.getVector(), ModelQuantity::x0);
1669-
}
1668+
checkFinite(derived_state_.x_rdata_, ModelQuantity::x0_rdata);
16701669
}
16711670

16721671
void Model::fx0_fixedParameters(AmiVector &x) {

0 commit comments

Comments
 (0)