gtopt/solver_monitor.hpp file

Solver monitoring API: real-time workpool statistics and JSON status file for SDDP and Monolithic solvers.

Provides a reusable SolverMonitor class that:

  • Samples CPU load and active worker-thread count from an AdaptiveWorkPool via a background std::jthread.
  • Stores the sampled history (a std::vector<MonitorPoint>).
  • Writes atomic JSON status files for external monitoring tools (e.g. scripts/sddp_monitor.py).

The class is used by both SDDPMethod (SDDP iteration history + real-time workpool stats) and MonolithicMethod (scene-solve progress + real-time workpool stats).

Indicators monitored by MonolithicMethod

The MonolithicMethod adds the following keys to its JSON status file:

  • "total_scenes": total number of scenes to process.
  • "scenes_done": scenes solved so far (thread-safe counter).
  • "scene_times": wall-clock time in seconds for each completed scene.
  • "elapsed_s": total wall time since solve() was called.
  • "status": "running" while in progress, "done" on completion.
  • "realtime": rolling CPU-load and active-worker history (same format as the SDDP status file).

Namespaces

namespace gtopt

Classes

struct gtopt::MonitorPoint
A single real-time sample point (CPU load, active workers, timestamp).
class gtopt::SolverMonitor
Background thread that samples workpool statistics and writes JSON.

Defines

#define SPDLOG_ACTIVE_LEVEL