gtopt::SDDPWorkPool class final

Work pool specialised for the SDDP solver with tuple priority key.

Uses SDDPTaskKey = std::tuple<IterationIndex, int, SDDPTaskKind> (iteration, is_backward, kind) as the secondary sort key with the default std::less<SDDPTaskKey> comparator (lexicographic). A concrete derived class so that class SDDPWorkPool; can be forward-declared in headers that only need the pointer type.

Base classes

template<typename Key = int64_t, typename KeyCompare = std::less<Key>>
class BasicWorkPool<SDDPTaskKey>
Adaptive thread pool with generic priority key.

Public types

using key_compare = std::less<SDDPTaskKey>
using key_type = SDDPTaskKey
using Requirements = BasicTaskRequirements<SDDPTaskKey>

Public functions

auto format_statistics() const -> std::string noexcept
auto get_statistics() const -> Statistics noexcept
void log_statistics() const
auto max_memory_percent() const -> double noexcept
auto max_process_rss_mb() const -> double noexcept
auto max_threads() const -> int noexcept
auto max_threads_ceiling() const -> int noexcept
auto release_slot_while_blocking() -> SlotReleaseGuard noexcept
void shutdown()
void start()
auto submit(Func&& func, const Requirements& req = Requirements(), Args && ... args) -> std::expected<std::future<std::invoke_result_t<Func, Args...>>, std::error_code>
auto submit_batch(std::vector<std::pair<Func, Requirements>>& tasks) -> std::vector<std::expected<std::future<std::invoke_result_t<Func>>, std::error_code>>
auto submit_lambda(Func&& func, Requirements req = {}) -> auto

Typedef documentation

using gtopt::SDDPWorkPool::key_compare = std::less<SDDPTaskKey>

using gtopt::SDDPWorkPool::key_type = SDDPTaskKey

using gtopt::SDDPWorkPool::Requirements = BasicTaskRequirements<SDDPTaskKey>

Function documentation

std::string gtopt::SDDPWorkPool::format_statistics() const noexcept

Statistics gtopt::SDDPWorkPool::get_statistics() const noexcept

void gtopt::SDDPWorkPool::log_statistics() const

double gtopt::SDDPWorkPool::max_memory_percent() const noexcept

System-wide memory-usage backstop threshold (percent). Routine throttling is the marginal-RSS gate; this fires only near OOM.

double gtopt::SDDPWorkPool::max_process_rss_mb() const noexcept

Process-RSS budget driving the marginal-RSS dispatch gate (0 = the gate + measured model are disabled). Exposed for tests / diagnostics.

int gtopt::SDDPWorkPool::max_threads() const noexcept

Thread cap configured for this pool. Needed by tests that verify make_solver_work_pool(cpu_factor) clamps its thread count correctly (e.g. tiny cpu_factor must floor to 1 thread to give a genuine serial baseline). Safe to call from any thread — max_threads_ may grow at runtime up to the ceiling.

int gtopt::SDDPWorkPool::max_threads_ceiling() const noexcept

Absolute growth ceiling for max_threads() (the un-clamped CPU budget). Equals max_threads() initially when growth is disabled.

SlotReleaseGuard gtopt::SDDPWorkPool::release_slot_while_blocking() noexcept

Acquire a guard that releases this task's worker slot for the duration of an external blocking wait. See SlotReleaseGuard for rationale and usage.

void gtopt::SDDPWorkPool::shutdown()

void gtopt::SDDPWorkPool::start()

std::expected<std::future<std::invoke_result_t<Func, Args...>>, std::error_code> gtopt::SDDPWorkPool::submit(Func&& func, const Requirements& req = Requirements(), Args && ... args)

std::vector<std::expected<std::future<std::invoke_result_t<Func>>, std::error_code>> gtopt::SDDPWorkPool::submit_batch(std::vector<std::pair<Func, Requirements>>& tasks)

Submit multiple callables under a single lock acquisition. Returns a vector of futures, one per callable.

auto gtopt::SDDPWorkPool::submit_lambda(Func&& func, Requirements req = {})