sddp_pool.hpp file
SDDP-specialised work pool: SDDPTaskKey, SDDPWorkPool, and factory.
This header provides the work-pool specialisation used by the SDDP solver:
SDDPTaskKey– a 4-tuple(iteration, is_backward, phase_rank, kind)used as the sort key so LP solves in the earliest iteration, with forward strictly ahead of backward at the same iteration, are always scheduled first;phase_rankis a non-negative laggard-first tie-break for per-phase backward aperture chunks (0 for phase-agnostic drivers).SDDPPassDirection– enum class (forward/backward) used by callers to identify the pass; converted tois_backward(0 / 1) by the factory.SDDPTaskKind– enum class (lp / non_lp) for task kind.make_sddp_task_key()– factory from strong types to SDDPTaskKey tuple.SDDPWorkPool– a concreteBasicWorkPool<SDDPTaskKey>subclass that can be forward-declared asclass SDDPWorkPool;in other headers.make_sddp_work_pool()– a factory that creates, configures, and starts anSDDPWorkPoolwith sensible CPU-aware defaults.
SDDPTaskKey semantics
The tuple (iteration_index, is_backward, phase_rank, kind):
iteration_index: SDDP iteration number (0, 1, …)is_backward: 0 = forward pass, 1 = backward passphase_rank: non-negative laggard-first tie-break (0 = driver)kind:lp(0) = LP solve/resolve,non_lp(1) = other
With the default std::less<SDDPTaskKey> lexicographic comparison (smaller tuple → higher dequeue priority):
- Lower iteration wins (iter 0 before iter 1, …) — so backward iter N still outranks forward iter N+1.
- Forward (0) beats backward (1) at the same iteration. Within a single iter, forward always runs first by definition (it produces the trial points the backward pass needs), so the only way the queue contains both at once is that one scene's forward is late while another scene's same-iter backward has already been submitted. Draining the late forward first lets the slow scene catch up; flipping the order would widen the spread instead.
- Smaller
phase_rankwins among per-phase backward aperture chunks tied on(iteration, is_backward). The backward sweep visits phases N-1…1, so a scene at a smaller phase index has MORE phases left this iteration (the laggard); the chunk submitter setsphase_rank = (n_phases-1) - phaseso that larger-remaining scene gets the smaller rank and drains first. Scene-driver tasks run all their phases as one task and leavephase_rank = 0. The field is kept NON-NEGATIVE so it can never reorder forward ahead of backward (which-phasewould, by sorting before any positive rank). lp(0) wins overnon_lp(1) so write_lp / dump tasks never block a solve worker.
phase_rank matters only in the async path: there two scenes can be in the same iteration's backward sweep at different phases at once. In the synchronous coordinator path (the default) apertures run inline on each scene's own driver thread, so chunks never funnel through this pool and phase_rank is moot — but the key stays correct for the opt-in async / cascade path and any future engine that schedules chunks here.
Namespaces
- namespace gtopt
Classes
- class gtopt::SDDPWorkPool
- Work pool specialised for the SDDP solver with tuple priority key.
Defines
- #define SPDLOG_ACTIVE_LEVEL