Skip to content

Commit a4eca9b

Browse files
hmgaudeckerclaude
andauthored
solve_brute: lazy diagnostics with per-period fail-fast on NaN (#339)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b880524 commit a4eca9b

4 files changed

Lines changed: 346 additions & 150 deletions

File tree

src/lcm/model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,14 @@ def solve(
221221
)
222222
except InvalidValueFunctionError as exc:
223223
if log_path is not None and exc.partial_solution is not None:
224-
save_solve_snapshot(
224+
snap_dir = save_solve_snapshot(
225225
model=self,
226226
params=params,
227227
period_to_regime_to_V_arr=exc.partial_solution, # ty: ignore[invalid-argument-type]
228228
log_path=Path(log_path),
229229
log_keep_n_latest=log_keep_n_latest,
230230
)
231+
exc.add_note(f"Snapshot saved to {snap_dir}")
231232
raise
232233
if log_level == "debug" and log_path is not None:
233234
save_solve_snapshot(
@@ -331,13 +332,14 @@ def simulate(
331332
)
332333
except InvalidValueFunctionError as exc:
333334
if log_path is not None and exc.partial_solution is not None:
334-
save_solve_snapshot(
335+
snap_dir = save_solve_snapshot(
335336
model=self,
336337
params=params,
337338
period_to_regime_to_V_arr=exc.partial_solution, # ty: ignore[invalid-argument-type]
338339
log_path=Path(log_path),
339340
log_keep_n_latest=log_keep_n_latest,
340341
)
342+
exc.add_note(f"Snapshot saved to {snap_dir}")
341343
raise
342344
result = simulate(
343345
internal_params=internal_params,

0 commit comments

Comments
 (0)