gtopt::LpMatrixOptions struct

Configuration options for converting to flat LP representation.

Public static variables

static double default_kvl_row_clamp
static bool default_pin_logic_rows
static int default_ruiz_max_iterations
static double default_ruiz_tolerance
static double default_water_dual_clamp

Public functions

void fill_unset_from(const LpMatrixOptions& base)
void merge(const LpMatrixOptions& other)

Public variables

bool col_with_name_map
Include column name mapping (level >= 1).
bool col_with_names
Include column names (state vars at level 0).
bool compute_fingerprint
OptBool compute_stats
std::shared_ptr<FlatLpDedupRegistry> dedup_registry
bool drop_disposable_collections
OptBool drop_element_collections
double eps
std::optional<LpEquilibrationMethod> equilibration_method
std::optional<FastSqrtMethod> fast_sqrt_method
std::optional<PhaseUid> flatten_phase_uid
std::optional<SceneUid> flatten_scene_uid
bool keep_row_label_meta
OptReal kvl_row_clamp
k in c in [1/k, k] (default 100)
OptBool kvl_row_scale
OptReal kvl_x_ref
OptBool label_meta_without_names
LowMemoryMode low_memory_mode
OptReal lp_coeff_ratio_threshold
LP coefficient ratio threshold for numerical conditioning diagnostics. When the global max/min |coefficient| ratio exceeds this value, a per-scene/phase breakdown is printed. (default: 1e7).
CompressionCodec memory_codec
bool move_names
Move instead of copy names.
LpNameSpillStore* name_store
OptBool pin_logic_rows
bool release_ampl_after_flatten
bool row_with_name_map
Include row name mapping.
bool row_with_names
Include row names (level >= 1).
OptInt ruiz_max_iterations
OptReal ruiz_tolerance
double scale_objective
OptBool share_label_meta
bool skip_matrix_build
std::string solver_name
Solver backend name (empty = auto-detect).
double stats_eps
LpValidationOptions validation
OptReal water_dual_clamp
Symmetric clamp c in [1/k, k] for the factor above (default 1e3).
OptReal water_dual_target

Function documentation

void gtopt::LpMatrixOptions::fill_unset_from(const LpMatrixOptions& base)

Fill every unset user-facing optional field from base, keeping the fields already set here (explicit value wins only when set). Covers exactly the JSON-mapped fields (merge above); the build-internal fields (names, eps, solver, low-memory, ...) are untouched.

void gtopt::LpMatrixOptions::merge(const LpMatrixOptions& other)

Merge optional fields from another LpMatrixOptions. Non-optional fields (eps, col_with_names, etc.) are not merged — first-value-wins semantics like SolverOptions.

Variable documentation

static bool gtopt::LpMatrixOptions::default_pin_logic_rows

Keep rows tagged SparseRow::pin_scale (pure commitment-logic rows: u / v / w transitions, exclusion, start-up tiers, start limits, charge / discharge exclusivity, plant unit counts with unit coefficients — all ±1 rows) out of the row equilibration (row_max, Ruiz and the incremental add_row normalisation): their row factor stays 1. Unset = default_pin_logic_rows (false): they are balanced like every other row. Opt-in: on cuc39 (MIP) pinning made the solve much slower, and kappa never moved.

static int gtopt::LpMatrixOptions::default_ruiz_max_iterations

Ruiz equilibration iteration cap and convergence tolerance. JSON-bound (sibling of equilibration_method / fast_sqrt_method), so the converter can emit them and --set lp_matrix_options.ruiz_max_iterations can tune them. The iterative Ruiz pass (apply_ruiz_scaling) runs at most ruiz_max_iterations row/column rescaling rounds, stopping early when the worst infinity-norm deviation from 1 drops below ruiz_tolerance. Only consulted when equilibration_method == ruiz.

Default cap is 5 (was 10). Solvers with their own internal scaling re-equilibrate the matrix anyway, so additional Ruiz iterations add little conditioning while costing build time linearly. 5 keeps a margin of equilibration headroom for scaling-free backends (HiGHS / CLP) while halving the per-build Ruiz cost vs the old 10.

Optional so a caller-supplied value and the planning-level JSON value can be told apart when the two are merged (see PlanningOptionsLP::resolve_lp_matrix_options); unset resolves to default_ruiz_max_iterations / default_ruiz_tolerance at the consumer site.

bool gtopt::LpMatrixOptions::compute_fingerprint

Compute LP fingerprint (structural hash) during flatten. Default false — only enabled when --lp-fingerprint is set.

OptBool gtopt::LpMatrixOptions::compute_stats

Compute coefficient min/max/ratio

std::shared_ptr<FlatLpDedupRegistry> gtopt::LpMatrixOptions::dedup_registry

Shared cross-cell snapshot dedup registry (see FlatLpDedupRegistry in memory_compress.hpp). Installed by PlanningLP::create_systems under low_memory = compress; each cell's compressed flat LP is then stored as an XOR delta against one base per (kind, phase). Null disables dedup. Build-control carrier only — NOT merged, serialised, or compared.

bool gtopt::LpMatrixOptions::drop_disposable_collections

Drop the disposable (non-HasUpdateLP) element collections after the build even under low_memory = off, and rebuild them on demand for write_out exactly as compress does. Set by PlanningLP::create_systems for SDDP / cascade (whose code already follows the compress rebuild discipline); left false for monolithic, whose post-solve paths (MIP start, investment master) read the collections directly. On the CEN 2y case the disposable wrappers were ~10.7 GiB of the 26 GiB off peak. Build-control carrier only — NOT merged, serialised, or compared.

OptBool gtopt::LpMatrixOptions::drop_element_collections

Drop the disposable (non-HasUpdateLP) element collections after the build under low_memory = off for SDDP / cascade, rebuilding them for write_out as compress does. Default true; false keeps them resident for the whole run (the previous behaviour). Ignored by monolithic (always keeps them) and by compress (always drops them).

double gtopt::LpMatrixOptions::eps

Coefficient epsilon: |v| <= eps is treated as zero. If negative, no filtering is applied.

std::optional<LpEquilibrationMethod> gtopt::LpMatrixOptions::equilibration_method

Matrix equilibration method. See LpEquilibrationMethod for options. Unset resolves through PlanningOptionsLP::equilibration_method (ruiz for multi-bus Kirchhoff, else row_max).

std::optional<FastSqrtMethod> gtopt::LpMatrixOptions::fast_sqrt_method

Approximate sqrt for Ruiz scaling. See FastSqrtMethod for options. Default is ieee_halve.

std::optional<SceneUid> gtopt::LpMatrixOptions::flatten_scene_uid

Optional (scene, phase) UIDs of the LP cell currently being flattened. Used to prepend [s14 p46] to per-cell LP_QUALITY messages so they line up with SDDP Forward / Backward info lines (which also print UIDs, not internal indices). Set by system_lp.cpp::flatten_from_collections and read by LinearProblem::flatten. Stored as strong-typed UIDs, not a pre-formatted string, so consumers can also use them for structured logging or per-cell stat aggregation. Not merged across LpMatrixOptions.

bool gtopt::LpMatrixOptions::keep_row_label_meta

Keep the structural ROW label metadata even with names off. Only the SDDP investment master needs it (it finds each candidate's capacity row through row_label_at); every other names-off build keeps no label metadata at all. Build-control carrier only — NOT merged, serialised, or compared.

OptBool gtopt::LpMatrixOptions::kvl_row_scale

EXPERIMENTAL. Post-equilibration conditioning of the node-angle KVL rows (Line.theta). The KVL dual is dLMP / x_tau, up to 1e6-1e7 on congested low-impedance corridors. When true, each KVL row is multiplied after equilibration by c = clamp(x_ref / x_tau, 1/kvl_row_clamp, kvl_row_clamp) with x_ref = median(X/V^2) of the network (the LP dual becomes y / c; physical duals, cuts and outputs unchanged). Default off.

OptReal gtopt::LpMatrixOptions::kvl_x_ref

Reference x_tau. Unset: PlanningLP::auto_scale_theta fills it with median(X/V^2) when kvl_row_scale is true. An explicit value (also enables the scaling) overrides the median.

OptBool gtopt::LpMatrixOptions::label_meta_without_names

Keep the label metadata (FlatLpMeta) of every cell even when LP names are off. Default false: with names off no label metadata is kept and diagnostics fall back to row / column indices. True restores the previous behaviour (metadata always resident).

LowMemoryMode gtopt::LpMatrixOptions::low_memory_mode

Low-memory build hint. When set to a non-off value, SystemLP's constructor skips the initial LinearInterface::load_flat() call and installs the flat LP as a deferred snapshot instead — the solver backend is reconstructed lazily on first use. Used by SDDP and cascade methods to avoid loading every (scene, phase) backend upfront only to release it again before the first solve. Default off: backend is loaded eagerly (current behavior).

CompressionCodec gtopt::LpMatrixOptions::memory_codec

Codec for the deferred snapshot when low_memory_mode == compress. auto_select defers to select_codec() which resolves to zstd (level 1).

LpNameSpillStore* gtopt::LpMatrixOptions::name_store

Non-owning back-pointer to the run-lifetime async metadata store (PlanningLP::m_name_store_). When non-null (set only when names are kept and the method is not monolithic), create_linear_interface spills each cell's label metadata here and drops the resident copy; write_lp reloads it on demand. Null disables the spill (current behaviour). Build-control carrier only — NOT merged, serialised, or compared.

bool gtopt::LpMatrixOptions::release_ampl_after_flatten

Release each cell's AMPL variable + metadata registry immediately after flatten(). That registry exists only to resolve user constraints during the build (find_ampl_col / collect_sum_cols) and is never read afterwards, so freeing it reclaims memory — hundreds of MB at CEN scale — for the rest of the solve. INTERNAL build-control flag (like skip_matrix_build), deliberately NOT JSON-bound: the production solve path (gtopt_lp_runner::prepare_matrix_options) turns it on, while the direct PlanningLP / SystemLP APIs leave it false so white-box tests can still inspect the registry via find_ampl_col after building. Default false.

double gtopt::LpMatrixOptions::scale_objective

Global divisor for all objective coefficients (numerical conditioning). Applied uniformly during flatten().

OptBool gtopt::LpMatrixOptions::share_label_meta

Share the label metadata between a cell's LinearInterface and its retained flat-LP snapshot (one copy). Default true; false restores the previous per-LinearInterface deep copy.

bool gtopt::LpMatrixOptions::skip_matrix_build

Skip the entire LinearProblem::flatten() matrix-build body and return an empty FlatLinearProblem. Used by the write-out rebuild path in system_lp.cpp::rebuild_collections_if_needed where the produced flat LP is discarded — only the add_to_lp side effects (XLP per-element col/row indices) are needed. Setting this kills the CSC build pass, the row-bound scan, the col-bound scan, the label-name pass and the equilibration pass — typically 5–10× faster on the rebuild slice for CEN-scale cells. Default false.

double gtopt::LpMatrixOptions::stats_eps

Minimum |coefficient| tracked in stats min/max. Applied in addition to eps: only values with |v| > max(eps, stats_eps) update stats_min_abs. Defaults to 1e-10 for consistency with external LP analysis tools.

LpValidationOptions gtopt::LpMatrixOptions::validation

Build-time LP validation thresholds and on/off flag. When enabled (default true at the consumer site), LinearInterface emits spdlog::warn lines as bad coefficients / bounds / RHS / objective values land in the LP, capped per-kind to avoid log-spam. See LpValidationOptions for individual thresholds.

OptReal gtopt::LpMatrixOptions::water_dual_target

Target magnitude of the LP-space dual of rows that carry a SparseRow::dual_hint (reservoir energy balances). Unset / <= 0 = off (bit-identical LP). Rows are multiplied AFTER equilibration by c = clamp(expected|y_LP| / target, 1/clamp, clamp); physical duals, cuts and outputs are unchanged (the stored row scale absorbs c).