Skip to content

Commit c87c580

Browse files
committed
Update logic flow
1 parent 41f664b commit c87c580

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

arrow/obsidian.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ evolve_result evolve(Info *info, double duration, int64_t *state, double *rates)
191191
interval = 0.0;
192192
choice = -1;
193193
status = 1; // overflow
194+
break;
194195
}
195196

196197
// If the total is zero, then we have no more reactions to perform and can exit
@@ -208,6 +209,11 @@ evolve_result evolve(Info *info, double duration, int64_t *state, double *rates)
208209
interval = sample_exponential(random_state, total);
209210
point = sample_uniform(random_state) * total;
210211

212+
// If we have surpassed the provided duration we can exit now
213+
if (now + interval > duration) {
214+
break;
215+
}
216+
211217
// Based on the random sample, find the event that it corresponds to by
212218
// iterating through the propensities until we surpass our sampled value
213219
choice = 0;
@@ -218,11 +224,6 @@ evolve_result evolve(Info *info, double duration, int64_t *state, double *rates)
218224
choice += 1;
219225
}
220226

221-
// If we have surpassed the provided duration we can exit now
222-
if (choice == -1 || (now + interval) > duration) {
223-
break;
224-
}
225-
226227
// Increase time by the interval sampled above
227228
now += interval;
228229

0 commit comments

Comments
 (0)