Add realtime_trace_jsonl recipe for structured real-time optimization progress streaming #1177
+223
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
PySCIPOpt already has recipe(s) that store optimization progress in memory. However, in-memory traces are not suitable for real-time, external observation (e.g., another process tailing progress, dashboards, log collectors).
This recipe focuses on the missing piece: a stream-friendly, structured output that can be consumed outside the running Python process during solve.
Design Decisions
setTracefile()(PR Add setTracefile() method for structured optimization progress loggingAdd settracefile api #1158):type,time,primalbound,dualbound,gap,nodes,nsol) for consistency across tracing approaches.model.data["trace"]for convenience/testing, but the recipe is centered on file streaming viapath=...run_endrecord on normal termination, interruption, or exceptionrun_endincludes structured error metadata (status, exception type, message)run_endto make completion detection reliableEvents Recorded
bestsol_found: when a new best solution is founddualbound_improved: when the dual bound improvesrun_end: when optimization terminates (also emitted on interrupt/exception)Fields
type, time, primalbound, dualbound, gap, nodes, nsol(aligned with the JSONL trace schema introduced in PR #1158)(
run_endmay additionally include:status, exception, messageon failure)