SparseCol class
#include <gtopt/sparse_col.hpp>
Represents a variable column in a linear program.
This class provides a fluent interface for setting variable properties including bounds, objective coefficients, integrality constraints, and a physical-to-LP scale factor.
The scale field records the relationship between the LP variable and the corresponding physical quantity:
physical_value = LP_value × scale
For example, a voltage angle column with scale_theta = 10000 (θ_LP = 10000 · θ) stores scale = 0.0001 because theta_physical = theta_LP × 0.0001. A reservoir energy column with energy_scale = 100000 stores scale = 100000 because volume_physical = volume_LP × 100000. All scales follow the same convention — no inversions.
The scale is used by:
- Output rescaling: primal
x_phys = x_LP × scale, reduced costrc_phys = rc_LP / scale. - User constraints (PAMPL):
LinearProblem::get_col_scale()returns the scale so that constraint coefficients are correctly adjusted. - Cross-element references (e.g. ReservoirSeepageLP reading reservoir volume scale to convert seepage slope to LP units).
All methods are constexpr to enable compile-time construction of problems.
Public functions
Public variables
- std::string_view class_name
- Element class (e.g. "Bus", "Reservoir").
- LpContext context
- LP hierarchy context (scenario, stage, block, ...).
- double cost
- Objective coefficient (default: 0.0).
- ConstraintScaleType cost_scale_type
- bool is_integer
- is integer-constrained (default: false)
- bool is_state
- double lowb
- Physical lower bound (default: 0.0).
- bool pin_scale
- double scale
- double uppb
- Physical upper bound (default: +infinity).
- std::string_view variable_name
- Variable name (e.g. "theta", "energy").
- Uid variable_uid
- Element UID for per-element lookup.
Function documentation
Variable documentation
std::string_view gtopt:: SparseCol:: class_name
Element class (e.g. "Bus", "Reservoir").
Optional metadata for automatic VariableScaleMap resolution. When class_name is non-empty and scale is still 1.0, LinearProblem::add_col() looks up the scale from its VariableScaleMap. If class_name is empty (default), no lookup is performed.
ConstraintScaleType gtopt:: SparseCol:: cost_scale_type
Time-basis of this column's objective coefficient, used to choose the inverse factor family when the LP reduced cost is read back to physical units in OutputContext. Primal-in and dual-out are inverse by construction per element:
Power→ objective × (prob·disc·duration); readback ÷ same (DEFAULT — instantaneous-power $/MWh reduced cost, current behaviour).Energy→ objective × (prob·disc); readback ÷ (prob·disc) (STOCK / commodity, e.g. stored-energy state $/MWh-stored, $/CMD — duration-INdependent, must NOT carry the per-block 1/duration term).Raw→ objective × 1; readback ÷ 1 (face-value money, e.g.alpha_fcf, VoRS penalties — no prob/disc/duration descale).
bool gtopt:: SparseCol:: is_state
True when the column is a state variable used in cascade/SDDP cut I/O. Column names are available when LpNamesLevel::all is set; state variable I/O uses the StateVariable map (ColIndex-based) directly. Set via SystemContext::add_state_col().
bool gtopt:: SparseCol:: pin_scale
When true, the column is exempt from EVERY equilibration / rescaling pass: the LinearProblem::add_col auto-scaler skips the VariableScaleMap lookup, and apply_ruiz_scaling pins the column factor at 1.0. Use for semantically binary or [0, 1]-bounded variables that lose their meaning when rescaled — LP-relaxed commitment status / startup / shutdown indicators (where is_integer = false under --no-mip would otherwise let Ruiz expand the bound to [0, ‖col‖₂]). The MIP path (is_integer = true) is already covered by the auto-scaler's integer guard; pin_scale extends the same exemption to LP-relax-of-integer columns and to never-integer-declared [0, 1] variables (startup/shutdown). See task #50 for rationale.
double gtopt:: SparseCol:: scale
Physical-to-LP scale: physical_value = LP_value × scale (default: 1.0 = no scaling)