FlatLinearProblem struct
#include <gtopt/linear_problem.hpp>
Represents a linear problem in column-major flat representation.
This format is commonly used by solver interfaces like COIN-OR, CPLEX, etc.
Public types
- struct RowTypeStatsEntry
-
using index_map_t = std::unordered_map<std::string_view, index_
t> - using index_t = int32_t
- Type for indices (row/column indices).
- using name_vec_t = std::vector<std::string>
Public functions
- auto col_labels_meta() const -> const std::vector<SparseColLabel>& noexcept
- Accessor for the shared column labels (empty when
label_metanull). - auto row_labels_meta() const -> const std::vector<SparseRowLabel>& noexcept
- Accessor for the shared row labels (empty when
label_metanull).
Public variables
- std::vector<ConstraintScaleType> col_cost_scale_types
- std::vector<double> col_scales
-
std::vector<index_
t> colint - std::vector<double> collb
- Lower bounds for variables.
-
index_
map_ t colmp - Map from variable names to indices.
-
name_
vec_ t colnm - Variable names (dense; populated when names enabled).
- std::vector<double> colub
- Upper bounds for variables.
- LpEquilibrationMethod equilibration_method
-
std::vector<index_
t> fast_start_cols - LabelMaker label_maker
- std::shared_ptr<const FlatLpMeta> label_meta
-
std::vector<index_
t> matbeg - Column start indices in the sparse matrix.
-
std::vector<index_
t> matind - Row indices for non-zero coefficients.
- std::vector<double> matval
- Values of non-zero coefficients.
- std::string name
- Problem name.
-
index_
t ncols - Number of columns (variables).
-
index_
t nrows - Number of rows (constraints).
- double obj_constant_raw
- std::vector<double> objval
- Objective coefficients.
- bool pin_logic_rows
- std::vector<ConstraintScaleType> row_cost_scale_types
- std::vector<double> row_scales
- std::vector<double> rowlb
- Lower bounds for constraints.
-
index_
map_ t rowmp - Map from constraint names to indices.
-
name_
vec_ t rownm - Constraint names (dense; populated when names enabled).
- std::vector<double> rowub
- Upper bounds for constraints.
- double scale_objective
-
std::vector<std::vector<index_
t>> sos2_sets - VariableScaleMap variable_scale_map
Coefficient statistics (populated when
LpMatrixOptions::compute_stats)
- size_t stats_nnz
- Non-zero count for the constraint matrix A.
- size_t stats_zeroed
- Count of non-zero entries filtered out by eps.
- double stats_max_abs
- Largest |coefficient| in constraint matrix A.
- double stats_min_abs
- Smallest |coefficient| in filtered A.
- std::optional<ColIndex> stats_max_col
- std::optional<ColIndex> stats_min_col
- std::string stats_max_col_name
- Name of column with largest |coeff|.
- std::string stats_min_col_name
- Name of column with smallest |coeff|.
- std::vector<RowTypeStatsEntry> row_type_stats
- auto stats_coeff_ratio() const -> double noexcept
- Coefficient ratio max/min (1.0 when empty, no valid min, or all equal).
Variable documentation
std::vector<ConstraintScaleType> gtopt:: FlatLinearProblem:: col_cost_scale_types
Per-column / per-row objective time-basis, captured from SparseCol::cost_scale_type / SparseRow::cost_scale_type at flatten(). Consumed by OutputContext (via LinearInterface) to select the inverse cost-factor family when reading reduced costs / duals back to physical units (Power → ÷duration, Energy → no ÷duration, Raw → face value). Empty / out-of-range indices default to Power.
std::vector<double> gtopt:: FlatLinearProblem:: col_scales
Per-column physical-to-LP scale factors (physical = LP × scale; default 1.0)
LpEquilibrationMethod gtopt:: FlatLinearProblem:: equilibration_method
Equilibration method selected at flatten() time. Persisted so the LinearInterface::add_row path can apply the same per-row equilibration to post-build cut rows.
std::vector<index_ t> gtopt:: FlatLinearProblem:: fast_start_cols
Integer columns (u/v/w commitment columns of fast-start units) relaxed to continuous in the pricing_mode = "fast_start" pricing LP; every other integer stays pinned at the MIP incumbent. Collected via LinearProblem::add_fast_start_cols and recorded by LinearInterface::load_flat. Empty unless the LP has fast-start commitments.
LabelMaker gtopt:: FlatLinearProblem:: label_maker
LabelMaker copied from LinearProblem during flatten(). LinearInterface picks this up in load_flat() so dynamically added columns and rows generate labels consistent with the original names_level configuration.
std::shared_ptr<const FlatLpMeta> gtopt:: FlatLinearProblem:: label_meta
Lightweight label metadata, populated unconditionally at flatten. Carries just the (class_name, variable_name / constraint_name, uid, context) fields that LabelMaker needs to synthesise a human-readable label on demand. LinearInterface copies these at load_flat time so write_lp can produce real gtopt names even when colnm / rownm are empty (flatten ran without col_with_names / row_with_names).
Held behind a shared_ptr<const FlatLpMeta> (see FlatLpMeta) so a phase's scenes can share one immutable copy. Null on a default- constructed FlatLinearProblem; always set by flatten(). Read through the col_labels_meta() / row_labels_meta() accessors, which fall back to an empty vector when the bundle is absent.
double gtopt:: FlatLinearProblem:: obj_constant_raw
Constant offset added to get_obj_value_raw() by LinearInterface. Stored on the raw (LP-scaled) cost scale — i.e. the source LinearProblem::m_obj_constant_ (physical scale) divided by scale_objective at flatten() time. This makes both views compose naturally without an extra constant term in get_obj_value():
get_obj_value_raw() = solver_raw + obj_constant_raw get_obj_value() = get_obj_value_raw() × scale_objective
Pre-substitution tests that assert raw-value magnitudes continue to hold across formulations because the raw view already includes the substituted constant in LP-scaled units.
Accumulated by LinearProblem::add_obj_constant(c) (physical scale) whenever a model rewrite folds a dispatch-side variable away via substitution (e.g. the P0 demand-failure variable rewrite: fail = lmax − load leaves the objective with a +fail_cost × lmax constant term that the LP solver knows nothing about, yet that constant IS dispatch cost and belongs in every consumer of get_obj_value()).
Note: cost-to-go style shifts (e.g. the boundary-cut α-rebase α' = α − c̄ in sddp_boundary_cuts.cpp) are handled at the SDDP level — they shift cut RHSs in-place and SDDPMethod adds c̄_scene to UB/LB at compute time. Those do NOT use obj_constant_raw; the field is exclusively for dispatch-side substitutions.
bool gtopt:: FlatLinearProblem:: pin_logic_rows
LpMatrixOptions::pin_logic_rows resolved at flatten() time, so LinearInterface::add_row keeps post-build SparseRow::pin_scale rows unnormalised like the bulk pass did.
std::vector<double> gtopt:: FlatLinearProblem:: row_scales
Per-row equilibration scale factors (max |coeff| per row). dual_physical = dual_LP / row_scale. Empty when row equilibration is off.
double gtopt:: FlatLinearProblem:: scale_objective
Global objective divisor applied during flatten(). obj_physical = obj_LP × scale_objective.
std::vector<std::vector<index_ t>> gtopt:: FlatLinearProblem:: sos2_sets
Type-2 Special-Ordered-Sets (SOS2) collected during LP build via LinearProblem::add_sos2. Each inner vector lists the column indices participating in one SOS2 in geometric order; weights are not stored explicitly (backends default to 1, 2, …, N). Consumed by LinearInterface::load_flat which forwards each inner vector to SolverBackend::add_sos2. Empty for the vast majority of LPs; populated only by features that need SOS2 (issue #504 line-loss L-secant chord).
VariableScaleMap gtopt:: FlatLinearProblem:: variable_scale_map
VariableScaleMap copied from LinearProblem during flatten(). LinearInterface picks this up in load_flat() so dynamically added columns can be auto-scaled.
std::optional<ColIndex> gtopt:: FlatLinearProblem:: stats_max_col
Column index of the largest / smallest |coefficient| in A, engaged only when compute_stats populated the sweep.