Skip to content

Commit

Permalink
898 change test for valid transition distibution from ide model (#913)
Browse files Browse the repository at this point in the history
Changed the index of a test in check_constraints for the ide model because the transitiondistribution S-> E is never used, so it does not have to have valid support. This can lead to unexpected errors if the function was set arbitrarily.
  • Loading branch information
lenaploetzke authored Feb 16, 2024
1 parent 5bef2c8 commit f32c96d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cpp/models/ide_secir/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class Model
* @param[in] idx_TransitionDistribution2 Specifies the index of the second relevant TransitionDistribution,
* related to a flow from the considered #InfectionState to any other #InfectionState (in most cases to Recovered).
* Necessary related probability is calculated via 1-probability[idx_TransitionDistribution1].
* If the second index is not needed, eg if probability[idx_TransitionDistribution1]=1,
* just use an arbitrary legal index.
* @param[in] dt Time discretization step size.
*/
void compute_compartment(Eigen::Index idx_InfectionState, Eigen::Index idx_IncomingFlow,
Expand Down
7 changes: 4 additions & 3 deletions cpp/models/ide_secir/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,11 @@ class Parameters : public ParametersBase
1);
return true;
}

for (size_t i = 0; i < (int)InfectionTransition::Count; i++) {
/* The first entry of TransitionDistributions is not checked because the distribution S->E is never used
(and it makes no sense to use the distribution). The support does not need to be valid.*/
for (size_t i = 1; i < (int)InfectionTransition::Count; i++) {
if (floating_point_less(this->get<TransitionDistributions>()[i].get_support_max(10), 0.0, 1e-14)) {
log_error("Constraint check: One parameter in TransitionDistributions has invalid support.");
log_error("Constraint check: One function in TransitionDistributions has invalid support.");
return true;
}
}
Expand Down

0 comments on commit f32c96d

Please sign in to comment.