Skip to content

CVODEBase: enforce mxstep budget on the CV_ONE_STEP path - #34

Merged
jeliason merged 1 commit into
mainfrom
feature/cv-one-step-mxstep-cap
Jul 1, 2026
Merged

CVODEBase: enforce mxstep budget on the CV_ONE_STEP path#34
jeliason merged 1 commit into
mainfrom
feature/cv-one-step-mxstep-cap

Conversation

@jeliason

@jeliason jeliason commented Jul 1, 2026

Copy link
Copy Markdown
Member

The CV_ONE_STEP scenario loop (simOdeStepOne) had no total-step ceiling — CVodeSetMaxNumSteps(mxstep) only bounds steps per CVode call, which is inert in one-step mode where each call advances exactly one step. A pathologically stiff θ could therefore grind indefinitely between dose boundaries.

This adds an explicit cumulative-step check inside simOdeStepOne: once getNumSteps() exceeds mxstep (50000), it raises CV_TOO_MUCH_WORK, matching the CV_NORMAL path's existing behavior. Valid sims that pass the CV_NORMAL 50k cap also pass this one, so no new failures are introduced — only genuinely non-converging stiff sims are cut.

CVodeSetMaxNumSteps(mxstep) bounds internal steps PER CVode() call. On the
CV_NORMAL path a whole interval is one call, so CVODE raises CV_TOO_MUCH_WORK
at mxstep and stiff draws fail fast. But the scenario/evolve output loops run
CV_ONE_STEP — one internal step per call — so that ceiling is never reached
and the loops have NO total-work cap: a stiff / near-singular draw crawls in
sub-ULP steps until an external per-sim timeout kills it (minutes of wall
time). The earlier 500000 -> 50000 mxstep reduction only ever protected the
CV_NORMAL path for this reason.

simOdeStepOne now checks getNumSteps() (cumulative steps since the last
re-init, i.e. per integration segment — the same unit a CV_NORMAL call spans)
and raises CV_TOO_MUCH_WORK once it crosses mxstep, so a bad draw fails in
seconds (~18s at mxstep=50000) identical to CV_NORMAL, becoming NaN
downstream instead of a multi-minute straggler.
@jeliason
jeliason merged commit 23ed635 into main Jul 1, 2026
2 checks passed
@jeliason
jeliason deleted the feature/cv-one-step-mxstep-cap branch July 1, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant