LinearInterface class
#include <gtopt/linear_interface.hpp>
Public types
- struct DiagResidentBytes
- struct FixIntegersOutcome
- Outcome of
fix_integers_and_resolve. - struct MipPolishOutcome
- Outcome of
polish_mip(the post-MIP fixed-integer LP). - struct PricingDuals
- Duals of a post-MIP pricing LP, waiting to be published.
- enum class CloneKind: std::uint8_t { deep, shallow }
- enum class LiPhase: uint8_t { Building, Frozen, BackendReleased, Reconstructed }
Public static functions
- static auto total_kappa_queries() -> std::size_t noexcept
Constructors, destructors, conversion operators
- LinearInterface(const LinearInterface&) deleted explicit
- Copy constructor disabled.
- LinearInterface(LinearInterface&&) defaulted
- Move constructor.
- LinearInterface(std::string_view solver_name, const FlatLinearProblem& flat_lp, const std::string& plog_file = {})
- Constructs interface, loads a problem, with solver by name.
- LinearInterface(std::string_view solver_name = {}, const std::string& plog_file = {}) explicit
- Constructs interface with a solver backend by name.
- LinearInterface(std::unique_ptr<SolverBackend> backend, std::string plog_file = {}) explicit
- Constructs interface with a pre-created backend.
- ~LinearInterface() defaulted
Public functions
- auto active_cuts() const -> std::span<const SparseRow> noexcept
- auto active_cuts_size() const -> std::size_t noexcept
- auto add_col(const SparseCol& col) -> ColIndex
- Adds a new column from a SparseCol with metadata-based naming.
- auto add_col_disposable(const SparseCol& col) -> ColIndex
- Add a disposable column on a shallow clone.
- auto add_col_raw(const SparseCol& col) -> ColIndex
- Adds a new column WITHOUT extending
m_scaling_.col_scales. - auto add_cols(std::span<const SparseCol> cols) -> ColIndex
- Bulk-add columns (much faster than repeated add_col calls).
- auto add_cols_disposable(std::span<const SparseCol> cols) -> std::vector<ColIndex>
- Bulk-add disposable columns on a shallow clone.
- auto add_cols_raw(std::span<const SparseCol> cols) -> ColIndex
- Bulk-add columns WITHOUT extending
m_scaling_.col_scales. - auto add_cut_row(const SparseRow& row, double eps = 0.0) -> RowIndex
- Add a cut row AND record it for low-memory replay.
- void add_obj_constant(double c) noexcept
- auto add_row(const SparseRow& row, double eps = 0.0) -> RowIndex
- Adds a new constraint row to the problem.
- auto add_row_disposable(const SparseRow& row, double eps = 0.0) -> RowIndex
- Add a disposable row on a shallow clone.
- auto add_row_raw(const SparseRow& row, double eps = 0.0) -> RowIndex
- Add a row in LP-raw space (skip col_scale / row-max equilibration / scale_objective composition).
- void add_rows(std::span<const SparseRow> rows, double eps = 0.0)
- Bulk-add constraint rows (much faster than repeated add_row calls).
- auto add_rows_disposable(std::span<const SparseRow> rows, double eps = 0.0) -> std::vector<RowIndex>
- Bulk-add disposable rows on a shallow clone.
- void add_rows_raw(std::span<const SparseRow> rows, double eps = 0.0)
- Bulk-add constraint rows in LP-raw space (skip col_scale + per-row row-max + scale_objective composition).
- void apply_post_load_replay(const LpReplayBuffer& source)
- auto backend_scratch_bytes() const -> std::size_t noexcept
- Bytes held by the backend's getter scratch buffers (0 when released).
- auto base_numrows() const -> auto noexcept
- Get the saved base row count.
- auto cached_col_cost_size() const -> std::size_t noexcept
- auto cached_col_low_size() const -> std::size_t noexcept
- auto cached_col_sol_size() const -> std::size_t noexcept
- auto cached_col_upp_size() const -> std::size_t noexcept
- auto cached_row_dual_size() const -> std::size_t noexcept
- void clear_basis()
- void clear_replay() noexcept
- void clear_snapshot() noexcept
-
auto clone(CloneKind kind = CloneKind::
deep) const -> LinearInterface - Creates a copy of this LinearInterface via the backend's clone() method.
-
auto clone_from_flat(CloneKind kind = CloneKind::
shallow) const -> LinearInterface - Manual clone — replays this LI's saved
FlatLinearProblemthroughload_flat()on a freshLinearInterface, bypassing the backend's nativeclone()entirely. - auto col_bounds_clamp_is_noop() const -> bool noexcept
- auto col_cost_scale_type_at(ColIndex index) const -> ConstraintScaleType noexcept
- auto col_cost_scale_types() const -> std::span<const ConstraintScaleType> noexcept
- auto col_label_at(ColIndex idx) const -> const SparseColLabel* noexcept
- auto col_labels_meta_use_count() const -> auto noexcept
- auto col_scales_use_count() const -> auto noexcept
- void defer_initial_load(FlatLinearProblem flat_lp)
- void delete_rows(std::span<const int> indices)
- Deletes rows by index from the constraint matrix.
- auto diag_resident_bytes() const -> DiagResidentBytes noexcept
- auto diagnose_infeasibility(int max_items = 50) -> std::optional<std::vector<std::string>>
- auto diagnose_row(RowIndex row) const -> RowDiagnostics
- Analyze coefficient range for a single row.
- void disable_compression()
- void drop_cached_primal_only() noexcept
- void drop_formatted_label_caches() const noexcept
- void drop_label_meta_buffers() noexcept
- auto duals_unavailable() const -> bool noexcept
- void enable_compression()
- void ensure_backend()
- void ensure_duals()
- Lazily compute vertex duals via crossover if the backend lacks them (barrier without crossover). No-op when has_duals() is already true (simplex, or barrier with crossover).
- auto equilibration_method() const -> LpEquilibrationMethod noexcept
- auto fast_start_cols() const -> std::span<const int> noexcept
- void fill_col_cost(std::span<double> out) const
- void fill_col_sol(std::span<double> out) const
- void fill_row_dual(std::span<double> out) const
- auto fix_integers_and_resolve(const SolverOptions& opts = {}) -> std::expected<FixIntegersOutcome, Error>
- Fix every integer column to its MIP-optimal value, relax integrality, and re-solve as a pure LP to recover duals.
- auto flat_lp_snapshot() const -> const FlatLinearProblem* noexcept
- auto flatten_col_count() const -> auto noexcept
- auto flatten_row_count() const -> auto noexcept
-
void freeze_for_cuts(LowMemoryMode mode,
FlatLinearProblem flat_lp,
CompressionCodec codec = CompressionCodec::
zstd) - auto frozen_col_labels_meta_size() const -> auto noexcept
- auto frozen_row_labels_meta_size() const -> auto noexcept
- void generate_labels_from_maps(std::vector<std::string>& col_names, std::vector<std::string>& row_names) const
- Produce
(col_names, row_names)for the current LP by synthesising real gtopt labels on demand. - auto get_algorithm() const -> auto
- Currently configured LP algorithm.
- auto get_basis() const -> std::optional<Basis>
- auto get_coeff(RowIndex row, ColIndex column) const -> double
- Gets a physical coefficient from the constraint matrix.
- auto get_coeff_raw(RowIndex row, ColIndex column) const -> double
- Gets a raw coefficient from the constraint matrix (LP units).
- auto get_col_cost() const -> ScaledView noexcept
- Gets LP-space reduced costs scaled by
scale_objective / col_scale. - auto get_col_cost_raw() const -> std::span<const double>
- Gets raw LP reduced costs (no descaling).
- auto get_col_low() const -> ScaledView noexcept
- Gets physical lower bounds for all variable columns.
- auto get_col_low_raw() const -> std::span<const double>
- Gets raw lower bounds for all variable columns (LP units).
- auto get_col_scale(ColIndex index) const -> double noexcept
- Gets the physical-to-LP scale factor for a single column.
- auto get_col_scales() const -> const auto& noexcept
- Gets all column scale factors.
- auto get_col_sol() const -> ScaledView noexcept
- Gets physical solution values (LP × col_scale).
- auto get_col_sol_raw() const -> std::span<const double>
- Gets raw LP solution values (no descaling).
- auto get_col_upp() const -> ScaledView noexcept
- Gets physical upper bounds for all variable columns.
- auto get_col_upp_raw() const -> std::span<const double>
- Gets raw upper bounds for all variable columns (LP units).
- auto get_kappa() const -> std::optional<double>
- Gets the condition number of the basis matrix (if available).
- auto get_log_file() const -> const auto&
- auto get_log_level() const -> auto
- Current solver log verbosity level (0 = off).
- auto get_log_tag() const -> const std::string& noexcept
- auto get_numcols() const -> Index
- Gets the number of variable columns in the problem.
- auto get_numrows() const -> Index
- Gets the number of constraint rows in the problem.
- auto get_obj_coeff() const -> auto
- auto get_obj_constant() const -> double noexcept
- auto get_obj_constant_raw() const -> double noexcept
- auto get_obj_value() const -> double
- Gets the objective value in physical (unscaled) units.
- auto get_obj_value_raw() const -> double
- Gets the raw LP objective value (in solver/LP space).
- auto get_presolve() const -> auto
- Whether presolve is currently enabled.
- auto get_prob_name() const -> std::string
- auto get_row_dual() -> ScaledView
- Gets LP-space dual values, scaled by
scale_objective / row_scale. - auto get_row_dual_raw() -> std::span<const double>
- Gets raw solver dual values (no descaling).
- auto get_row_low() const -> ScaledView noexcept
- Gets physical lower bounds for all constraint rows.
- auto get_row_low_raw() const -> auto
- Gets raw lower bounds for all constraint rows (LP units).
- auto get_row_scale(RowIndex index) const -> double noexcept
- Gets the row equilibration scale factor for a single row.
- auto get_row_scales() const -> const auto& noexcept
- Gets all row equilibration scale factors.
- auto get_row_upp() const -> ScaledView noexcept
- Gets physical upper bounds for all constraint rows.
- auto get_row_upp_raw() const -> auto
- Gets raw upper bounds for all constraint rows (LP units).
- auto get_status() const -> int
- Gets the solver-specific status code.
- auto get_threads() const -> auto
- Currently configured thread count (0 = solver default).
- auto has_backend() const -> bool noexcept
- Check whether the solver backend is loaded.
- auto has_decompressed_snapshot() const -> bool noexcept
- auto has_integer_cols() const -> bool
- auto has_mip_incumbent() const -> bool
- auto has_snapshot_data() const -> bool noexcept
- True when a
FlatLinearProblemsnapshot is currently held. - auto infinity() const -> double noexcept
- auto initial_solve(const SolverOptions& solver_options = {}) -> std::expected<int, Error>
- Performs initial solve of the problem from scratch.
- void install_pricing_duals(PricingDuals pricing)
- Publish pricing duals while keeping the current primal.
- auto is_backend_released() const -> bool noexcept
- True if the solver backend has been released (low-memory mode).
- auto is_continuous(ColIndex index) const -> bool
- Checks if a variable is continuous.
- auto is_dual_infeasible() const -> bool
- Checks if the problem is dual infeasible.
- auto is_integer(ColIndex index) const -> bool
- Checks if a variable is integer.
- auto is_neg_inf(double value) const -> bool noexcept
- True if
valuerepresents negative infinity for the active solver. - auto is_optimal() const -> bool
- Checks if the solution is optimal.
- auto is_pos_inf(double value) const -> bool noexcept
- True if
valuerepresents positive infinity for the active solver. - auto is_prim_infeasible() const -> bool
- Checks if the problem is primal infeasible.
- auto is_snapshot_deduplicated() const -> bool noexcept
- auto kappa_queries() const -> std::size_t noexcept
- auto label_maker() const -> const LabelMaker& noexcept
- Returns the LabelMaker driving label generation for add_col/row.
- auto last_mip_polish() const -> const MipPolishOutcome& noexcept
- auto last_pricing() const -> const PricingOutcome& noexcept
- Outcome of the last pricing pass (reset at every solve entry point).
- auto last_solver_options() const -> const SolverOptions& noexcept
- The effective SolverOptions applied to the backend on the last
initial_solve/resolve. - void load_flat(const FlatLinearProblem& flat_lp)
- Loads a flattened linear problem into the solver.
- auto low_memory_mode() const -> LowMemoryMode noexcept
- Current low-memory mode.
- auto lp_validation_options() const -> const LpValidationOptions& noexcept
- Read-only access to the per-LP validation thresholds.
- auto lp_validation_stats() const -> const LpValidationStats& noexcept
- Read-only access to this LP's incremental validation stats.
- void materialize_labels() const
- void merge_solver_stats(const SolverStats& other) noexcept
- Fold another LP's counters into this one.
- auto mutable_lp_validation_stats() -> LpValidationStats& noexcept
- Mutable accessor to the validation stats block.
- auto mutable_solver_stats() -> SolverStats& noexcept
- Mutable accessor to the solver-counter block.
- auto normalize_bound(double value) const -> double noexcept
- auto normalize_bounds(double lowb, double uppb) const -> std::pair<double, double> noexcept
- Normalize a (lower, upper) bound pair in one call.
- auto numcols_as_index() const -> ColIndex
- See
numrows_as_index. - auto numrows_as_index() const -> RowIndex
- Typed row count — use instead of
RowIndex{li.get_numrows()}at every call site. - auto operator=(const LinearInterface&) -> LinearInterface& deleted
- Copy assignment disabled.
- auto operator=(LinearInterface&&) -> LinearInterface& defaulted
- Move assignment.
- auto pending_coeffs_size() const -> std::size_t noexcept
- auto pending_rhs_size() const -> std::size_t noexcept
- auto phase() const -> LiPhase noexcept
- auto pin_logic_rows() const -> bool noexcept
- auto polish_mip(const SolverOptions& opts) -> std::expected<MipPolishOutcome, Error>
- Polish the MIP incumbent: fix its discrete decisions and re-solve the LP (objective, primal AND duals).
- auto post_flatten_col_labels_meta_size() const -> auto noexcept
- auto post_flatten_row_labels_meta_size() const -> auto noexcept
- void reconstruct_backend()
- void record_cut_deletion(std::span<const int> deleted_indices)
- Record cut row deletions (pruning/forgetting).
- void record_cut_row(SparseRow row)
- Record a Benders cut row addition.
- void record_dynamic_col(SparseCol col)
- Record a dynamically-added column (e.g. alpha variable).
- void record_dynamic_row(SparseRow row)
- auto relax_integers() -> Index
- Relaxes every integer column to continuous (LP relaxation).
- void release_backend() noexcept
- void release_backend_scratch() const noexcept
- auto replay_buf() const -> const LpReplayBuffer& noexcept
- void reserve_active_cuts(std::size_t n)
- void reset_from(const LinearInterface& source, size_t base_rows)
- Reset this LP to a base state by copying column bounds from
sourceand deleting any rows beyondbase_rows. - auto resolve(const SolverOptions& solver_options = {}) -> std::expected<int, Error>
- Resolves the problem with updated data using warm start.
- auto resource_class() const -> ResourceClass noexcept
- void restore_active_cuts(std::vector<SparseRow> cuts) noexcept
- void restore_dynamic_cols(std::vector<SparseCol> cols) noexcept
- auto restore_integers(std::span<const int> integer_cols) -> Index
- auto row_cost_scale_type_at(RowIndex index) const -> ConstraintScaleType noexcept
- auto row_cost_scale_types() const -> std::span<const ConstraintScaleType> noexcept
- auto row_label_at(RowIndex idx) const -> const SparseRowLabel* noexcept
- auto row_scales_use_count() const -> auto noexcept
- void save_base_numrows()
- Save the current row count as the "base" model size.
- void save_snapshot(FlatLinearProblem flat_lp)
- auto scale_objective() const -> double noexcept
- Gets the global objective scaling factor.
- void set_base_numrows(Index n) noexcept
- auto set_basis(Basis basis) -> bool
- void set_binary(ColIndex index)
- Sets a variable to be binary (0-1 integer).
- void set_coeff(RowIndex row, ColIndex column, double physical_value)
- Sets a coefficient in the constraint matrix from physical units.
- void set_coeff_raw(RowIndex row, ColIndex column, double value)
- Sets (modifies) a raw coefficient in the constraint matrix.
- void set_col(ColIndex index, double physical_value)
- void set_col_bounds(std::span<const ColIndex> indices, std::span<const char> lu, std::span<const double> physical_values)
- Bulk col-bound mutation in physical (descaled) units.
- void set_col_bounds_raw(std::span<const ColIndex> indices, std::span<const char> lu, std::span<const double> values)
- Bulk col-bound mutation in LP-raw units.
- void set_col_low(ColIndex index, double physical_value)
- void set_col_low_raw(ColIndex index, double value)
- void set_col_raw(ColIndex index, double value)
- void set_col_scale(ColIndex index, double scale)
- Sets the physical-to-LP scale factor for a single column.
- void set_col_sol(std::span<const double> sol)
- void set_col_upp(ColIndex index, double physical_value)
- void set_col_upp_raw(ColIndex index, double value)
- void set_continuous(ColIndex index)
- Sets a variable to be continuous (floating-point).
- void set_equilibration_method(LpEquilibrationMethod method) noexcept
- void set_integer(ColIndex index)
- Sets a variable to be integer.
- void set_label_maker(LabelMaker lm) noexcept
- Sets the LabelMaker used to generate and gate LP col/row labels.
- void set_last_pricing(PricingOutcome outcome) noexcept
- void set_log_file(std::string_view plog_file)
- void set_log_tag(std::string tag) noexcept
-
void set_low_memory(LowMemoryMode mode,
CompressionCodec codec = CompressionCodec::
zstd) noexcept - Configure low-memory mode (off, snapshot, compress, rebuild).
- auto set_mip_start(std::span<const double> col_values, MipStartEffort effort) -> bool
- void set_name_store(LpNameSpillStore* store, std::string key) noexcept
- void set_obj_coeff(ColIndex index, double physical_value)
- Sets the objective coefficient for a column in physical units.
- void set_obj_coeff_raw(ColIndex index, double value)
- Sets the objective coefficient for a column in LP-raw units.
- void set_obj_coeffs_raw(std::span<const double> values)
- Bulk overwrite of every objective coefficient (LP-raw units).
- void set_pin_logic_rows(bool pin) noexcept
- Override
pin_logic_rows(unit tests that build an LP directly). - void set_prob_name(const std::string& pname)
- void set_row_bounds(RowIndex row, double physical_lowb, double physical_uppb)
- void set_row_bounds_raw(RowIndex row, double lowb, double uppb)
- void set_row_dual(std::span<const double> dual)
- void set_row_equal_to(RowIndex row, double physical_value)
- void set_row_equal_to_raw(RowIndex row, double value)
- void set_row_low(RowIndex index, double physical_value)
- void set_row_low_raw(RowIndex index, double value)
- void set_row_scale(RowIndex index, double scale)
- Sets the row scale factor for a single row.
- void set_row_upp(RowIndex index, double physical_value)
- void set_row_upp_raw(RowIndex index, double value)
- void set_share_label_meta(bool share) noexcept
- Release the solver backend, freeing its memory.
- void set_snapshot_dedup(std::shared_ptr<FlatLpDedupRegistry> registry, std::string key) noexcept
- void set_time_limit(double time_limit)
- Sets a time limit for the solver.
- void set_validation_options(LpValidationOptions opts) noexcept
- Install or replace this LP's validation thresholds.
- auto share_label_meta() const -> bool noexcept
- auto solve_pricing_lp(PricingMode mode, const SolverOptions& opts) -> PricingDuals
- Solve the post-MIP pricing LP for
modeon a clone. - auto solver_id() const -> std::string
- auto solver_name() const -> std::string_view noexcept
- Solver backend name (e.g. "clp", "cplex", "highs").
- auto solver_stats() const -> const SolverStats& noexcept
- Read-only access to this LP's cumulative solver counters.
- auto solver_version() const -> std::string
- auto sos2_member_cols() const -> std::span<const int> noexcept
- auto sos2_set_count() const -> std::size_t noexcept
- auto supports_set_coeff() const -> bool noexcept
- Checks whether the solver supports in-place coefficient updates.
- auto take_active_cuts() -> std::vector<SparseRow> noexcept
- auto take_dynamic_cols() -> std::vector<SparseCol> noexcept
- auto update_dynamic_col_bounds(std::string_view class_name, std::string_view variable_name, double new_lowb, double new_uppb) -> bool noexcept
- auto update_dynamic_col_bounds(std::string_view class_name, std::string_view variable_name, Uid variable_uid, double new_lowb, double new_uppb) -> bool noexcept
- auto update_dynamic_col_lowb(std::string_view class_name, std::string_view variable_name, double new_lowb) -> bool noexcept
- auto variable_scale_map() const -> const VariableScaleMap& noexcept
- VariableScaleMap moved from FlatLinearProblem during load_flat().
-
auto write_lp(const std::string& filename,
LpFileFormat format = LpFileFormat::
lp, LpFormatFallback fallback = LpFormatFallback:: other_format) const -> std::expected<std::string, Error> - Writes the model to
<filename>.lpor<filename>.mps.
Name-to-index maps (col: level >= 0, row: level >= 1)
-
auto row_name_map() const -> const row_
name_ map_ t& noexcept -
auto col_name_map() const -> const col_
name_ map_ t& noexcept - auto col_index_to_name() const -> const auto& noexcept
- auto row_index_to_name() const -> const auto& noexcept
LP coefficient statistics (populated during load_flat from
FlatLinearProblem::stats_* fields, which are computed in LinearProblem::flatten when LpMatrixOptions::compute_stats is true).
- auto lp_stats_nnz() const -> size_t noexcept
- auto lp_stats_zeroed() const -> size_t noexcept
- auto lp_stats_max_abs() const -> double noexcept
- auto lp_stats_min_abs() const -> double noexcept
- auto lp_stats_max_col() const -> std::optional<ColIndex> noexcept
- auto lp_stats_min_col() const -> std::optional<ColIndex> noexcept
- auto lp_stats_max_col_name() const -> const std::string& noexcept
- auto lp_stats_min_col_name() const -> const std::string& noexcept
- auto lp_row_type_stats() const -> const auto& noexcept
Enum documentation
enum class gtopt:: LinearInterface:: CloneKind: std::uint8_t
Selects how clone() replicates the metadata (label vectors, dedup maps, scale vectors). The backend solver handle is always cloned independently — solver internals (CPLEX env, HiGHS basis factorisation) are non-reentrant, so each clone needs its own independent backend regardless.
| Enumerators | |
|---|---|
| deep |
Each metadata structure is value-copied into the clone — the resulting clone owns an independent copy of every field. Use for bad-LP dumps where the dump must remain stable even if the source mutates afterward. Current default. |
| shallow |
Metadata structures are shared with the source via Precondition: the source must not be concurrently mutated for the lifetime of the shallow clone. In gtopt's SDDP this is enforced by |
enum class gtopt:: LinearInterface:: LiPhase: uint8_t
Lifecycle phase of the LinearInterface. Advance on every state-changing entry point so observers (debug logging, future assertion guards in plan step 4) can see what stage the LP is in.
State transitions tracked: (default) → Building ctor Building → Building load_flat (still pre-freeze) Building → Frozen freeze_for_cuts Frozen → BackendReleased release_backend Reconstructed → BackendReleased release_backend BackendReleased → Reconstructed reconstruct_backend
No transition assertions in this step — step 2 of the docs/analysis/investigations/linear_interface/linear_interface_lifecycle_plan_2026-04-30.md is pure observation; step 4 layers debug-asserted transitions on top once every call site has migrated to the canonical entry points.
Function documentation
static std::size_t gtopt:: LinearInterface:: total_kappa_queries() noexcept
Backend kappa queries made by every LinearInterface of the process. All backend get_kappa() calls go through one LinearInterface choke point, so a zero delta proves no backend was asked (kappa_mode = off).
gtopt:: LinearInterface:: LinearInterface(std::string_view solver_name,
const FlatLinearProblem& flat_lp,
const std::string& plog_file = {})
Constructs interface, loads a problem, with solver by name.
| Parameters | |
|---|---|
| solver_name | Solver identifier |
| flat_lp | Flattened linear problem to load |
| plog_file | Path to log file for solver output |
gtopt:: LinearInterface:: LinearInterface(std::string_view solver_name = {},
const std::string& plog_file = {}) explicit
Constructs interface with a solver backend by name.
| Parameters | |
|---|---|
| solver_name | Solver identifier ("clp", "cbc", "cplex", "highs") |
| plog_file | Path to log file for solver output |
gtopt:: LinearInterface:: LinearInterface(std::unique_ptr<SolverBackend> backend,
std::string plog_file = {}) explicit
Constructs interface with a pre-created backend.
| Parameters | |
|---|---|
| backend | Pre-configured solver backend |
| plog_file | Path to log file for solver output |
std::span<const SparseRow> gtopt:: LinearInterface:: active_cuts() const noexcept
Const view of the live active-cut rows tracked by the replay buffer. Used by post-install passes (e.g. the terminal-α floor helper in sddp_method_alpha.cpp) that need to walk every cut on this LP without taking it out via take_active_cuts. The returned span aliases the replay buffer's vector; the caller must not retain references across mutating operations (add_cut_row / record_cut_deletion / take_active_cuts).
std::size_t gtopt:: LinearInterface:: active_cuts_size() const noexcept
Const-accessible cut count for diagnostic logging. Read-only; avoids the take_active_cuts round-trip that would mutate.
ColIndex gtopt:: LinearInterface:: add_col(const SparseCol& col)
Adds a new column from a SparseCol with metadata-based naming.
| Parameters | |
|---|---|
| col | The sparse column specification |
| Returns | The index of the newly added column |
Generates the column name lazily from structured metadata when class_name and context are present; returns empty otherwise. Applies bounds, objective coefficient, scale and integrality (col.is_integer → set_integer; an LP-only backend relaxes it with a one-time warning). add_col_raw, add_cols and add_cols_raw honour is_integer the same way.
ColIndex gtopt:: LinearInterface:: add_col_disposable(const SparseCol& col)
Add a disposable column on a shallow clone.
| Parameters | |
|---|---|
| col | SparseCol with scale == 1.0. |
| Returns | Index of the newly added column. |
Goes DIRECTLY to the solver backend (m_backend_->add_col) — does not transit through add_col, add_col_raw, or emit_col_to_backend. Captures only the label-meta fields of col (class_name, variable_name, variable_uid, context) into a per-clone-local extras vector + dedup map. Never touches the shared m_labels_.col_labels_meta or m_scaling_.col_scales — designed for use on a clone(CloneKind::shallow) where those structures are shared read-only with the source.
Asserts col.scale == 1.0 (the elastic-filter slack convention) — non-unit scales would require extending m_scaling_.col_scales, which the disposable contract forbids.
generate_labels_from_maps consults the per-clone extras when the col index is past the end of the shared metadata, so write_lp produces gtopt-formatted labels for disposable cols identical to what the production path would emit.
Use case: SDDP elastic-filter slack cols on the cloned LP. Solve-and-discard pattern, ≤ 20 cols per call.
ColIndex gtopt:: LinearInterface:: add_col_raw(const SparseCol& col)
Adds a new column WITHOUT extending m_scaling_.col_scales.
| Parameters | |
|---|---|
| col | Sparse column with scale == 1.0. |
| Returns | The index of the newly added column. |
Same as add_col(SparseCol) but never calls set_col_scale. Asserts col.scale == 1.0 so the caller can't accidentally lose a non-unit scale. Use this for post-flatten col adds that don't need per-col scale tracking — chiefly the α-column registration in apply_post_load_replay.
Mirrors add_row_raw's contract: emit + label-meta tracking + dedup, but no per-column / per-row scale-vector mutation. This is the precondition for sharing m_scaling_.col_scales across aperture clones via std::shared_ptr — the scale vector is frozen once load_flat has populated it.
ColIndex gtopt:: LinearInterface:: add_cols(std::span<const SparseCol> cols)
Bulk-add columns (much faster than repeated add_col calls).
| Parameters | |
|---|---|
| cols | Sparse columns with physical-space cost / bounds. |
| Returns | Index of the first column added. |
Builds a CSC (Compressed Sparse Column) buffer from the provided SparseCol objects, applies bound normalisation and the scale_objective divisor on each objective coefficient, dispatches a single SolverBackend::add_cols(...) call, and then performs the per-column post-bookkeeping (column-scale registration, label-meta tracking with dedup, and optional name generation) — mirroring how add_rows(span<SparseRow>) shapes the row-bulk path.
SparseCol carries no coefficient map, so each column's CSC slice is empty (colbeg[c+1] == colbeg[c]). The bulk path's value is the single backend dispatch: each per-column call typically reallocates the backend's internal column metadata array.
Mirrors add_col(SparseCol)'s contract: every column in the batch routes through the same cost / scale_objective composition, and any non-unit col.scale extends m_scaling_.col_scales via set_col_scale (just like the singular path). Use this for batches of physical-space columns (the typical case). For LP-raw batches that must skip m_scaling_.col_scales extension, use add_cols_raw instead.
std::vector<ColIndex> gtopt:: LinearInterface:: add_cols_disposable(std::span<const SparseCol> cols)
Bulk-add disposable columns on a shallow clone.
| Parameters | |
|---|---|
| cols | SparseCols with scale == 1.0. |
| Returns | Vector of newly assigned column indices. |
Mirrors add_col_disposable for batches: each column goes directly to the solver backend with cost / scale_objective composition; label-meta is captured into the per-clone-local extras (m_post_clone_col_metas_*). Asserts every entry has scale == 1.0. Returns the freshly assigned indices in the same order as cols.
ColIndex gtopt:: LinearInterface:: add_cols_raw(std::span<const SparseCol> cols)
Bulk-add columns WITHOUT extending m_scaling_.col_scales.
| Parameters | |
|---|---|
| cols | Sparse column specifications with scale == 1.0. |
| Returns | Index of the first column added. |
Companion to add_col_raw for batches. Same cost / scale_objective composition as add_cols (i.e. col.cost is still treated as physical and divided by m_scale_objective_), but m_scaling_.col_scales is never grown — so every entry must satisfy col.scale == 1.0. Used by post-flatten cut paths that need the column scale vector to stay frozen so it can be shared across aperture clones via std::shared_ptr.
RowIndex gtopt:: LinearInterface:: add_cut_row(const SparseRow& row,
double eps = 0.0)
Add a cut row AND record it for low-memory replay.
| Parameters | |
|---|---|
| row | Cut row, physical-space coefficients. |
| eps | Coefficient filtering threshold. Callers should pass the active SDDPOptions::cut_coeff_eps so loaded and generated cuts see the same filtering. Defaults to 0 (no filtering) for compatibility with existing loaders whose signatures don't plumb cut_coeff_eps yet — follow-up refactor should thread that option through each loader's parameter list. |
| Returns | Row index assigned by the solver backend. |
Equivalent to add_row(row, eps) followed by record_cut_row(row) — every cut install site needs both so the row survives a release_backend / ensure_backend cycle by being replayed through apply_post_load_replay. Prefer this over the bare add_row + record_cut_row pair for new code. Generated-cut paths that also push into SDDPMethod::m_cut_store_ continue to use add_row + store_cut (which wraps record_cut_row internally) to avoid double-recording.
void gtopt:: LinearInterface:: add_obj_constant(double c) noexcept
Accumulate a physical-scale constant onto the LP objective.
Counterpart to LinearProblem::add_obj_constant for callers that need to add a constant AFTER load_flat. Callers always pass values in physical (post-scale_objective) units; the API divides by m_scale_objective_ internally so the running m_scaling_.obj_constant_raw stays on the same raw scale as the solver's value — get_obj_value_raw() then composes the two with a plain add. Calls accumulate (additive); pass a negative c to subtract.
Also mirrors the change into the snapshot's FlatLinearProblem::obj_constant_raw so a subsequent reconstruct via load_flat re-establishes the constant. Out-of-line because the snapshot mutation depends on LpSnapshotHolder.
RowIndex gtopt:: LinearInterface:: add_row(const SparseRow& row,
double eps = 0.0)
Adds a new constraint row to the problem.
| Parameters | |
|---|---|
| row | The constraint with physical-space coefficients. |
| eps | Epsilon value for coefficient filtering (values below are ignored). |
| Returns | The index of the newly added row |
Adds a new constraint row to the problem.
Coefficients are interpreted as physical-space by default. When the LP was built with equilibration (row_max or ruiz) and save_base_numrows() has fired (i.e. this row is a post-build cut), add_row applies, in order:
- Physical → LP column scaling:
coeff_j ← coeff_j × col_scales[j]. Bounds are not touched here. - Per-row row-max normalisation: divide coefficients and bounds by
max|coeff_j|, so the new row lands atmax|coeff| = 1, matching the structural rows processed byapply_row_max_equilibration/apply_ruiz_scalingat build time. - Composite row scale storage:
row_scale = row.scale × max|coeff|, preservingdual_phys = dual_LP × row_scale.
Otherwise (no equilibration on the LP, or this row still belongs to the structural-build phase), add_row is a pass-through — the physical space and LP space coincide, so no conversion happens.
RowIndex gtopt:: LinearInterface:: add_row_disposable(const SparseRow& row,
double eps = 0.0)
Add a disposable row on a shallow clone.
| Parameters | |
|---|---|
| row | SparseRow with scale == 1.0. |
| eps | Epsilon for coefficient filtering. |
| Returns | Index of the newly added row. |
Companion to add_col_disposable. Goes DIRECTLY to m_backend_->add_row; captures only the label-meta fields of row into a per-clone-local extras vector + dedup map. Never touches the shared m_labels_.row_labels_meta or m_scaling_.row_scales.
Asserts row.scale == 1.0 (the elastic-filter fixing-row convention).
Use case: SDDP elastic-filter fixing rows on the cloned LP.
RowIndex gtopt:: LinearInterface:: add_row_raw(const SparseRow& row,
double eps = 0.0)
Add a row in LP-raw space (skip col_scale / row-max equilibration / scale_objective composition).
| Parameters | |
|---|---|
| row | Constraint with LP-raw coefficients and LP-raw bounds. |
| eps | Epsilon for coefficient filtering. |
Companion to get_col_low_raw / get_col_sol_raw / get_row_dual_raw: callers that have already computed coefficients and bounds in the LP solver's own space (after flatten() has run) and want them inserted verbatim should use this instead of add_row. Only SparseRow::scale is composed (mirroring flatten()'s treatment of static rows); no per-column col_scale multiplication, no per-row equilibration, no scale_objective divisor.
Use case: SDDP elastic-filter fixing rows. add_row in the post-flatten ("cut phase") path applies all three transforms, which silently breaks the fixing-row semantics dep + sup − sdn = trial whenever col_scale(dep) != 1 — the slacks end up scaled out of step with the dependent column. add_row_raw preserves the unit coefficients and the LP-raw RHS.
void gtopt:: LinearInterface:: add_rows(std::span<const SparseRow> rows,
double eps = 0.0)
Bulk-add constraint rows (much faster than repeated add_row calls).
| Parameters | |
|---|---|
| rows | The sparse row representations of the constraints |
| eps | Epsilon value for coefficient filtering |
Mirrors add_row's contract for batches: when the LP is in the post-flatten cut phase (save_base_numrows() has fired) AND m_scaling_.col_scales / equilibration are active, every row in the batch is treated as physical-space and routed through the per-row compose_physical transform (col_scale × elem / scale_objective / row-max). Otherwise the bulk CSR fast path runs unchanged.
Use this for batches of physical-space rows (cuts, post-flatten user-built rows). For LP-raw batches that should bypass compose_physical, use add_rows_raw instead.
std::vector<RowIndex> gtopt:: LinearInterface:: add_rows_disposable(std::span<const SparseRow> rows,
double eps = 0.0)
Bulk-add disposable rows on a shallow clone.
| Parameters | |
|---|---|
| rows | SparseRows with scale == 1.0 (LP-raw coefficients). |
| eps | Epsilon for coefficient filtering. |
| Returns | Vector of newly assigned row indices. |
Mirrors add_row_disposable for batches: every row goes directly to the solver backend (LP-raw insertion, only SparseRow::scale composed); label-meta is captured into the per-clone-local extras (m_post_clone_row_metas_*). Asserts every entry has scale == 1.0. Returns the freshly assigned indices in the same order as rows.
void gtopt:: LinearInterface:: add_rows_raw(std::span<const SparseRow> rows,
double eps = 0.0)
Bulk-add constraint rows in LP-raw space (skip col_scale + per-row row-max + scale_objective composition).
| Parameters | |
|---|---|
| rows | The sparse row representations of the constraints (LP-raw coefficients and LP-raw bounds). |
| eps | Epsilon value for coefficient filtering. |
Companion to add_row_raw but for batches. Use when the caller already has LP-raw coefficients/bounds and wants the bulk speedup without compose_physical. Typical use: snapshot replay paths that carry LP-raw rows.
Only SparseRow::scale is composed (mirroring flatten()'s treatment of static rows). No per-column col_scale, no per-row equilibration, no scale_objective divisor.
void gtopt:: LinearInterface:: apply_post_load_replay(const LpReplayBuffer& source)
Replay the persistent SDDP state (dynamic cols + active cuts + warm-start) onto the live backend after a fresh load_flat(). Used by the compress/snapshot reconstruction path: structural rows are in the backend, and the caller-tracked state must be replayed on top so subsequent add_col/add_row calls append cleanly.
Pre-condition: the backend is live (post load_flat) and m_backend_released_ has been cleared.
The source replay buffer is the data source — callers pass either their own m_replay_ (the reconstruct_backend() path) or the SOURCE LP's m_replay_ (the clone_from_flat(with_replay=true) path, which avoids value-copying the source's entire replay buffer onto a throwaway clone). The ReplayGuard inside flips the OWN buffer's flag so nested add_cols/add_rows skip auto-recording.
auto gtopt:: LinearInterface:: base_numrows() const noexcept
Get the saved base row count.
| Returns | Base row count (0 if save_base_numrows was never called) |
|---|
std::size_t gtopt:: LinearInterface:: cached_col_low_size() const noexcept
Size of the cached column lower/upper-bound vectors. Non-zero only after a compress-mode solve snapshots the live backend bounds; reconstruct_backend() evicts them (see clear_col_bounds_cache), so this is 0 immediately after a reconstruct. Lets tests observe the col-bound cache lifecycle without a presolve-dependent value.
std::size_t gtopt:: LinearInterface:: cached_col_sol_size() const noexcept
Test-only diagnostic: number of doubles currently held in the LI-side post-solve solution-vector cache. Returns 0 when the cache is empty (off mode never populates, or compress mode after invalidate_cached_optimal_on_mutation has fired). Useful in unit tests that need to distinguish "cache dropped" from "get_col_sol_raw transparently routes to the live backend".
void gtopt:: LinearInterface:: clear_basis()
Drop the basis resident on the live backend so the next resolve starts cold (SolverBackend::clear_basis). No-op when the backend has been released (a snapshot holds no basis).
void gtopt:: LinearInterface:: clear_replay() noexcept
Drop the cut replay journal in m_replay_.
The replay buffer accumulates every dynamic column, every dynamic / cut row, and every pending bound / coefficient / RHS override applied to the LP since the last load_flat. It exists so that reconstruct_backend() can rebuild the in-memory backend after a release_backend() cycle (cuts and overrides are replayed onto the freshly-loaded flat LP).
On the end-of-life drop path (post-write_out, no future reconstruct) the journal is dead weight. On recovery hot-starts it can be sizeable — 36 800 loaded boundary cuts × ~45 cuts/cell over 816 cells = several GiB of SparseRow records that never replay again. Calling this after the cell's parquet write completes recovers that budget.
Safe to call multiple times (idempotent). Must NOT be called while a ReplayGuard is active — the caller is responsible for ensuring the cell is truly done.
void gtopt:: LinearInterface:: clear_snapshot() noexcept
Drop the compressed/uncompressed flat-LP snapshot held by this interface. Used by the SDDP simulation Pass 1 in low-memory mode to free the per-cell LP matrix right after the solve caches its primal/dual/cost vectors via release_backend() — subsequent PlanningLP::write_out reads solution values straight from the cached vectors (see Phase 2a getters) and rebuild_collections_if_ needed re-flattens from the live System element arrays, so the flat-LP snapshot is no longer needed for any downstream step.
Calling this after release_backend() is safe; the cached scalars and vectors stay intact. After this, a subsequent reconstruct_backend() would have nothing to reload from — only call when the LP is truly done.
LinearInterface gtopt:: LinearInterface:: clone(CloneKind kind = CloneKind:: deep) const
Creates a copy of this LinearInterface via the backend's clone() method.
| Returns | A new LinearInterface wrapping the cloned solver. |
|---|
The clone preserves the full LP state (variables, constraints, bounds, objective, warm-start basis). Modifications to the clone's bounds / objective do not affect the original — use this for tentative solves such as the SDDP elastic filter or aperture sub-problems.
kind == CloneKind::deep (default) replicates the historical behaviour: every metadata vector / map is value-copied. kind == CloneKind::shallow shares the metadata via shared_ptr; use for solve-and-discard clones (aperture, elastic) to save memory at peak concurrency. See CloneKind for full contract.
Thread safety: every call is serialised process-wide by a mutex inside clone(). Native clone routines (CPXcloneprob on CPLEX, the equivalent elsewhere) have process-global side effects (env, licence manager, allocator) that are not reentrant; concurrent SDDP clones crashed and deadlocked without it. clone_from_flat() is the lock-free alternative.
LinearInterface gtopt:: LinearInterface:: clone_from_flat(CloneKind kind = CloneKind:: shallow) const
Manual clone — replays this LI's saved FlatLinearProblem through load_flat() on a fresh LinearInterface, bypassing the backend's native clone() entirely.
| Returns | A new LinearInterface populated from the saved snapshot. |
|---|
Why two clone routes coexist:
clone(CloneKind)→ callsbackend().clone()(e.g.CPXcloneprob), serialised process-wide by a mutex (see the thread-safety note onclone()).clone_from_flat(kind)→ goes throughCPXcreateprob+CPXaddrows(or the equivalent on each backend). Those calls are env-local: everyCplexSolverBackendctor runs them concurrently during plugin load with no mutex, so the manual route is structurally safe to call without any lock.
Pre-condition:
has_snapshot_data()must be true — i.e. the LI has been frozen withLowMemoryMode::compress(orsnapshot) so the flat representation is retained. Throwsstd::runtime_errorotherwise.m_snapshot_must be decompressed. In SDDP this is enforced for the aperture window via the existingDecompressionGuardatsddp_aperture_pass.cpp:390, 579. Throwsstd::runtime_errorif compressed.
kind == CloneKind::shallow re-shares the source's metadata shared_ptrs into the freshly built clone after load_flat, matching the memory-saving semantics of the native shallow path. kind == CloneKind::deep keeps the freshly-built metadata that load_flat produced.
After load_flat the source's m_replay_ state (dynamic_cols, dynamic_rows, active_cuts, pending_col_bounds) is replayed onto the clone, yielding a current-state clone equivalent to what clone() would produce (α + all installed cuts), but built via the parallel-safe CPXcreateprob path. This is what the SDDP forward-pass elastic filter needs: it clones the full current LP and solves concurrently across many SDDPWorkPool threads, where the native clone() mutex would serialise them.
bool gtopt:: LinearInterface:: col_bounds_clamp_is_noop() const noexcept
True when the get_col_sol() physical-space clamp against the cached column bounds is a bitwise no-op for every column, i.e. the clamped and unclamped views of the cached primal agree bit for bit. Vacuously true when the bound cache is empty. release_backend() uses this to drop the col_low / col_upp cache (2 x 8 x ncols bytes per cell) whenever keeping it cannot change any value served while the backend is released.
ConstraintScaleType gtopt:: LinearInterface:: col_cost_scale_type_at(ColIndex index) const noexcept
Objective time-basis of a column (Power / Energy / Raw), used by OutputContext to pick the inverse cost-factor family for the column's reduced-cost readback. Out-of-range (post-flatten) indices default to Power. Populated from FlatLinearProblem::col_cost_scale_types at load_flat.
std::span<const ConstraintScaleType> gtopt:: LinearInterface:: col_cost_scale_types() const noexcept
Whole-vector view of per-column objective time-basis. Empty when not populated (bare LinearInterface / unflattened LP).
const SparseColLabel* gtopt:: LinearInterface:: col_label_at(ColIndex idx) const noexcept
Resolve a column / row index into the appropriate metadata bucket (frozen flatten or per-instance post-flatten). Returns nullptr when the index is past both buckets — which is only possible if the caller is asking about a backend column that was never tracked (e.g. add_col(name, lb, ub) paths that bypass label-meta capture).
Cheap: a bounds check + a vector index per call, no decompression on the post-flatten side. The flatten side may be in compressed form during training/SDDP; consult ensure_labels_meta_decompressed before calling if formatted strings are needed.
auto gtopt:: LinearInterface:: col_labels_meta_use_count() const noexcept
Test/diagnostic accessor: shared_ptr::use_count() of one of the wrapped metadata members. All of them are detached together in clone(deep) and shared together in clone(shallow), so any one is representative. Use cases:
- Unit tests verifying the sharing contract (after
clone(shallow)it should be 2; afterclone(deep)1; after a mutation throughdetach_for_writeit drops back to 1 on whichever member was touched). - Diagnostics logging memory-saving hit rate at peak aperture concurrency.
Reads m_labels_.col_labels_meta because that's the largest-footprint member and the most useful to track, but any of the eleven wrapped members would do.
void gtopt:: LinearInterface:: defer_initial_load(FlatLinearProblem flat_lp)
Install a flat LP snapshot without loading the backend.
Used by SystemLP::create_lp when low-memory mode is enabled at build time so the initial load_flat() call can be skipped: the snapshot is recorded, optionally compressed (level compress), and m_backend_released_ is flipped on so the next user-driven add_col / add_row / solve goes through ensure_backend() → reconstruct_backend() (which performs the single build-time load_flat).
Pre-condition: set_low_memory() must have been called first with a non-off mode — otherwise this would defeat the lazy reconstruction path because release_backend() becomes a no-op.
void gtopt:: LinearInterface:: delete_rows(std::span<const int> indices)
Deletes rows by index from the constraint matrix.
| Parameters | |
|---|---|
| indices | Row indices to delete (must be sorted ascending) |
std::optional<std::vector<std::string>> gtopt:: LinearInterface:: diagnose_infeasibility(int max_items = 50)
Diagnose the current problem's infeasibility, returning conflicting constraint labels (a minimal infeasible subsystem) or std::nullopt when the backend cannot diagnose. Delegates to SolverBackend::diagnose_infeasibility.
RowDiagnostics gtopt:: LinearInterface:: diagnose_row(RowIndex row) const
Analyze coefficient range for a single row.
| Parameters | |
|---|---|
| row | Row index to analyze |
| Returns | RowDiagnostics with coefficient statistics |
Iterates over all columns to find non-zero coefficients and reports min/max absolute values, their ratio, and associated column names. Used by kappa diagnostics to identify ill-conditioned cut rows.
void gtopt:: LinearInterface:: disable_compression()
Decompress the saved flat LP (level 2) and keep it uncompressed until enable_compression() is called. No-op if level < 2 or already decompressed.
void gtopt:: LinearInterface:: drop_cached_primal_only() noexcept
Drop the cached primal vectors (col_sol, col_cost) but keep row_dual (and the scalar caches).
release_backend() populates three primal/dual snapshots so that post-release readers can keep accessing the solution:
col_solandcol_costare read byOutputContextand the SDDP state-variable propagation paths during the iteration that produced the solve.row_dualis read across iterations byupdate_stored_cut_dualsandprune_inactive_cuts(sddp_cut_store.cpp:177, 222).
On a large hydrothermal case run the col_sol + col_cost vectors carry 0.7–2.5 GB across all (scene, phase) cells between iterations. Once the iteration's state CSV has been written and the backward pass has consumed the per-state-variable values via capture_state_variable_values, neither vector is read again until the next solve overwrites it — making them the largest "alive but unused" allocation in the SDDP loop.
Call this after save_cuts_for_iteration (state CSV) returns and before the next iteration's forward pass begins. Safe under low_memory_mode == off (no-op since the caches stay empty) and idempotent. Does NOT touch the cached row dual, obj value, kappa, numrows, numcols, or optimality flag — those remain available for inter-iteration consumers.
void gtopt:: LinearInterface:: drop_formatted_label_caches() const noexcept
Drop the formatted-label caches that write_lp populated.
generate_labels_from_maps (the one path that turns label metadata into formatted strings) writes its results into m_labels_.col_index_to_name / m_labels_.row_index_to_name (and the underlying m_labels_.col_names / m_labels_.row_names dedup maps) as a memoization layer for repeat write_lp calls — but in production SDDP write_lp runs at most once per cell (debug --lp-debug, error-LP capture). After the dump returns the caches are dead weight: ~50k strings × ~30 bytes per LP × N cells is hundreds of MB on large cases, persisting until process exit unless we drop them.
Safe to call after every write_lp because:
- The metadata source (compressed
m_*_labels_meta_compressed_) is unchanged — the nextgenerate_labels_from_maps/write_lprebuilds the formatted cache from scratch. - Production SDDP (no
--lp-debug) never populates these caches outsidewrite_lp, so the drop is a no-op. - Paths that read the cache outside
write_lp(diagnose_row,rebuild_row_name_maps,delete_rows) are size-guarded and tolerate an empty cache (un-named diagnostics vs. crash).
Idempotent and noexcept.
void gtopt:: LinearInterface:: drop_label_meta_buffers() noexcept
Drop the legacy label-metadata buffers (compressed col/row label vectors and the string pool that backed the decompressed string_views).
Historical note: prior to the release_backend cleanup these buffers held a zstd-compressed copy of the frozen flatten-side label metadata, populated by compress_labels_meta_if_needed() and decompressed on demand by ensure_labels_meta_decompressed() for write_lp / cut JSON save / OutputContext::write_out. The snapshot's flat_lp.col_labels_meta already owns the canonical copy and load_flat repopulates the live vectors before any consumer reads them, so the secondary compressed buffers are always empty in current code. This accessor stays for idempotent end-of-run cleanup and for callers that may have stashed compressed buffers via custom paths. Safe to remove in a follow-up once all in-tree callers are confirmed redundant.
bool gtopt:: LinearInterface:: duals_unavailable() const noexcept
True while the last fix_integers_and_resolve BAILED (see FixIntegersOutcome::bailed): the published primal is the MIP incumbent but no LP duals / reduced costs exist for it. While latched, get_row_dual{,_raw} and get_col_cost{,_raw} return empty views so dual-dependent outputs skip gracefully (the OutputContext emitters already treat an empty span as "not
available") instead of publishing whatever the backend's dual scratch happens to hold for a MIP. Cleared on the next initial_solve / resolve / successful fix pass.
void gtopt:: LinearInterface:: enable_compression()
Re-compress the saved flat LP (level 2). Reverses a prior disable_compression(). No-op if level < 2 or already compressed.
void gtopt:: LinearInterface:: ensure_backend()
Ensure the backend is live. For LowMemoryMode::off this is a no-op (backend is always live). For compress (and the legacy snapshot alias) it reconstructs from the saved snapshot.
Any mutation method (add_col, add_row, set_*, solve) calls this internally, so most callers don't need to invoke it directly. Useful as an explicit trigger for pure-read code paths that would otherwise read stale cached row/col counts from a released cell.
LpEquilibrationMethod gtopt:: LinearInterface:: equilibration_method() const noexcept
Equilibration method in effect for this LP (selected by opts.equilibration_method at flatten() time, persisted across load_flat). Used by add_row / add_rows to keep applying per-row scaling to post-build cuts. none when equilibration was disabled at build time — in that case add_row leaves new rows alone, preserving the historical behaviour.
std::span<const int> gtopt:: LinearInterface:: fast_start_cols() const noexcept
Integer columns relaxed by pricing_mode = "fast_start" (recorded at load_flat from FlatLinearProblem::fast_start_cols, sorted).
void gtopt:: LinearInterface:: fill_col_sol(std::span<double> out) const
Span-out solution-fill wrappers — public API delegating to the underlying SolverBackend::fill_col_sol/fill_col_cost/fill_row_dual. Used by populate_solution_cache_post_solve to write directly into the LI cache; also exposed here so tests can verify the span-out contract without reaching for the private backend() accessor.
std::expected<FixIntegersOutcome, Error> gtopt:: LinearInterface:: fix_integers_and_resolve(const SolverOptions& opts = {})
Fix every integer column to its MIP-optimal value, relax integrality, and re-solve as a pure LP to recover duals.
| Parameters | |
|---|---|
| opts | Solver options for the follow-up LP solve (the caller typically enables crossover so vertex duals are produced). |
| Returns | Outcome with the fixed-column count, the re-solve status (status absent when no integers were found), and the bailed degraded-outcome flag. |
A MIP solution carries no LP duals (shadow prices) or reduced costs. The standard recovery technique — used by CPLEX/PLEXOS and most unit-commitment tools to report LMPs — is: after the MIP is solved, FIX every integer variable to its optimal (rounded) value, relax integrality so the problem becomes a pure LP, and re-solve. The resulting LP has well-defined row duals and column reduced costs, which are the correct marginal prices given the committed integer solution.
SOS2 sets get the same treatment: their member columns (recorded at load_flat, see sos2_member_cols()) are pinned to the incumbent because an SOS declaration is inert in the pure LP re-solve — a freed λ ladder would re-optimize to SOS-infeasible vertices and the published primal would no longer be the MIP incumbent. The recovered duals are conditional on the incumbent's discrete choices, SOS segment choices included.
Pre-condition: a successful MIP resolve() / initial_solve() must have just completed on a live (or reconstructable) backend so get_col_sol_raw() returns the MIP-optimal primal vector. The MIP primal values are read into a local copy BEFORE any bound mutation (the first set_col_bounds_raw invalidates the cached solution).
For every integer column c this:
- reads its MIP value
v = round(col_sol_raw[c]), - fixes both bounds to
v(set_col_bounds_rawwith 'B'), - flips it continuous (
relax_integers()after the bound pins). It then callsresolve(opts). After the re-solve the primalcol_solis unchanged (integers pinned to the MIP values) whilerow_dual/col_costnow hold the LP duals / reduced costs.
Solver-agnostic: routes entirely through set_col_bounds_raw, relax_integers() (backend relax_all_integers), and resolve(). No backend is hard-coded.
When the LP has no integer columns this is a cheap no-op: it returns {.fixed_columns = 0} without touching bounds or re-solving, so a pure-LP solve keeps its native duals untouched.
When the backend cannot complete the pass (no incumbent, fixed-LP solve failure, or the CPLEX SOS-support verification fires) it BAILS: the live problem is restored to the MIP incumbent, this interface republishes the pre-fix primal through its cache, and the outcome carries bailed = true with duals_unavailable() latched — see FixIntegersOutcome.
const FlatLinearProblem* gtopt:: LinearInterface:: flat_lp_snapshot() const noexcept
The retained, decompressed flattened LP, or nullptr when none is held (e.g. low_memory off, or a compressed snapshot not yet re-hydrated). Used by the scip_repair MIP-start generator, which builds a second backend from this exact flat problem (column j here == raw LP column j).
auto gtopt:: LinearInterface:: flatten_col_count() const noexcept
Number of structural columns / rows captured at flatten time and still pinned in the frozen m_labels_.col_labels_meta / m_labels_.row_labels_meta vector. Indices in [0, flatten_col_count()) are flatten-side; higher indices are post-flatten additions (alpha, cuts, cascade elastic slacks, …). m_labels_.col_labels_meta may be nullptr only on a default-constructed LinearInterface before load_flat; in that case the count is 0.
void gtopt:: LinearInterface:: freeze_for_cuts(LowMemoryMode mode,
FlatLinearProblem flat_lp,
CompressionCodec codec = CompressionCodec:: zstd)
Single-call entry point for the structural-build → cut-build transition under low-memory modes. Replaces the legacy 3-call dance:
set_low_memory(mode, codec); save_snapshot(std::move(flat_lp)); save_base_numrows();
Call this once after load_flat has populated the backend with the structural rows and before any Benders cut is added. See docs/analysis/investigations/linear_interface/linear_interface_lifecycle_plan_2026-04-30.md step 1 for the rationale: the legacy three-method ordering is implicit and easy to get wrong (forgetting save_base_numrows mis-attributes structural rows as cuts; forgetting save_snapshot makes reconstruct_backend() a silent no-op). This consolidator collapses the dance into one verb.
Pre-conditions (debug-asserted):
- the backend has been loaded (
m_backend_released_ == falseORdefer_initial_loadhas populatedm_cached_numrows_), - no cut rows have been added yet (
m_active_cuts_.empty()).
auto gtopt:: LinearInterface:: frozen_col_labels_meta_size() const noexcept
Diagnostic: entries currently held in the frozen (flatten-side) label metadata. 0 when labels were dropped / spilled / cleared on release; flatten_col_count() keeps reporting the structural size regardless.
void gtopt:: LinearInterface:: generate_labels_from_maps(std::vector<std::string>& col_names,
std::vector<std::string>& row_names) const
Produce (col_names, row_names) for the current LP by synthesising real gtopt labels on demand.
| Parameters | |
|---|---|
| col_names | Output vector, resized to get_num_cols(). |
| row_names | Output vector, resized to get_num_rows(). Caches formatted labels back into m_labels_.col_index_to_name / m_labels_.row_index_to_name so subsequent calls (repeat write_lp) skip the LabelMaker pass. The caches are declared mutable so this method remains logically const. |
Sources, in priority order:
- Pre-formatted strings in
m_labels_.col_index_to_name/m_labels_.row_index_to_name(populated at flatten whenLpMatrixOptions::{col,row}_with_nameswas set — i.e.--lp-debug). Zero work if already present. - Structural metadata:
m_labels_.col_labels_meta/m_labels_.row_labels_meta(populated unconditionally at flatten). Formatted via a localLabelMaker{LpNamesLevel::all}so the result matches what--lp-debugwould have produced at flatten time. - Dynamic cols (post-flatten additions, e.g. α): synthesised from
m_dynamic_cols_[k]via the same forced-allLabelMaker. - Active cuts (post-flatten row additions): same, from
m_active_cuts_[k].
No fallback — if a col/row has neither pre-formatted name nor metadata, that indicates a LinearInterface invariant violation (e.g. a col was added without metadata, or load_flat was called with a FlatLinearProblem that pre-dates this contract). The method throws std::logic_error in that case.
Caller pays zero memory cost at flatten; synthesis happens only when this method (and therefore write_lp) actually fires.
std::optional<Basis> gtopt:: LinearInterface:: get_basis() const
Capture the current simplex basis (column + row statuses), or std::nullopt when the live backend has none — no simplex/crossover solve has produced one (a bare interior point), the backend is basis-less, or the backend has been released (a snapshot cannot reconstruct a basis). Delegates to SolverBackend::get_basis.
Status-only, so no scaling is involved (a variable being basic is scale-invariant) — unlike get_col_sol, this is a verbatim pass-through.
double gtopt:: LinearInterface:: get_coeff(RowIndex row,
ColIndex column) const
Gets a physical coefficient from the constraint matrix.
| Parameters | |
|---|---|
| row | Row index of the coefficient |
| column | Column index of the coefficient |
| Returns | The physical coefficient value |
Converts from LP to physical units: physical_coeff = raw_coeff × col_scale × row_scale
When no scaling is active, returns the raw value unchanged.
double gtopt:: LinearInterface:: get_coeff_raw(RowIndex row,
ColIndex column) const
Gets a raw coefficient from the constraint matrix (LP units).
| Parameters | |
|---|---|
| row | Row index of the coefficient |
| column | Column index of the coefficient |
| Returns | The raw coefficient value, or 0.0 if the element does not exist |
ScaledView gtopt:: LinearInterface:: get_col_cost() const noexcept
Gets LP-space reduced costs scaled by scale_objective / col_scale.
| Returns | Zero-copy lazy view per element (LP-space rc, cost_factor-folded). |
|---|
Important: despite the historical name, this does NOT return truly physical reduced costs in $/[physical-unit]/hour. The result is rc_LP × scale_objective / col_scale, which unscales:
- the global
scale_objectivedivisor; - the per-column
col_scale(uservariable_scalesand equilibration adjustments).
It does NOT unscale the per-(scenario, stage, block) cost_factor = probability × discount × duration that's folded into the LP cost coefficients via CostHelper::block_ecost / stage_ecost. Callers who need reduced costs in physical $/[unit]/hour must additionally divide by CostHelper::cost_factor(scenario, stage[, block]) for the column's context.
OutputContext::add_col_cost already applies the inverse factor to deliver truly physical reduced costs to the user-facing output stream; SDDP cut math intentionally consumes the LP-folded value here and relies on cancellation in the destination master LP.
Precondition: backend must be live.
std::span<const double> gtopt:: LinearInterface:: get_col_cost_raw() const
Gets raw LP reduced costs (no descaling).
| Returns | Span view of raw LP reduced costs |
|---|
ScaledView gtopt:: LinearInterface:: get_col_low() const noexcept
Gets physical lower bounds for all variable columns.
| Returns | ScaledView over solver column lower bounds |
|---|
Returns a zero-copy lazy view: each access computes LP_bound × col_scale on the fly. When col_scales are empty, returns raw values unchanged.
std::span<const double> gtopt:: LinearInterface:: get_col_low_raw() const
Gets raw lower bounds for all variable columns (LP units).
| Returns | Span view of raw column lower bounds |
|---|
These are the bounds as stored in the solver backend. For scaled variables, LP_bound = physical_bound / col_scale. Use get_col_low() for physical (unscaled) bounds.
double gtopt:: LinearInterface:: get_col_scale(ColIndex index) const noexcept
Gets the physical-to-LP scale factor for a single column.
| Parameters | |
|---|---|
| index | Column index |
| Returns | Scale factor (1.0 if col_scales is empty or not populated) |
physical_value = LP_value × scale. A scale of 1.0 means no scaling (LP variable == physical value). Scale factors are populated during load_flat() from FlatLinearProblem::col_scales.
const auto& gtopt:: LinearInterface:: get_col_scales() const noexcept
Gets all column scale factors.
| Returns | Const reference to the column scale vector (empty if not populated) |
|---|
ScaledView gtopt:: LinearInterface:: get_col_sol() const noexcept
Gets physical solution values (LP × col_scale).
| Returns | ScaledView over solver solution memory |
|---|
Returns a zero-copy lazy view: each access computes LP_value × col_scale on the fly. When col_scales are empty, returns raw values unchanged.
When the last solve converged to optimality (is_optimal() true), the returned view additionally clamps each element to the column's physical bound box [col_low[i], col_upp[i]]. The clamp is applied after descaling so no further scale multiplication can re-introduce the bound violation. This scrubs solver-tolerance noise that would otherwise propagate into subsequent phases as set_col_low_raw(dep, sol+eps) = set_col_upp_raw(dep, sol+eps) and make the next-phase LP trivially infeasible. Callers that need the exact solver output (e.g. Chinneck IIS on an elastic clone where relaxed bounds would falsely "fix" the value) use get_col_sol_raw().
Precondition: backend must be live. Callers under low-memory modes should invoke ensure_backend() first if reading after a release.
std::span<const double> gtopt:: LinearInterface:: get_col_sol_raw() const
Gets raw LP solution values (no descaling).
| Returns | Span view of raw LP solution values |
|---|
Returns solver values as-is, in LP units. Use this for SDDP state propagation, cut generation, and any internal LP algebra that operates in scaled coordinates.
ScaledView gtopt:: LinearInterface:: get_col_upp() const noexcept
Gets physical upper bounds for all variable columns.
| Returns | ScaledView over solver column upper bounds |
|---|
Returns a zero-copy lazy view: each access computes LP_bound × col_scale on the fly.
std::span<const double> gtopt:: LinearInterface:: get_col_upp_raw() const
Gets raw upper bounds for all variable columns (LP units).
| Returns | Span view of raw column upper bounds |
|---|
std::optional<double> gtopt:: LinearInterface:: get_kappa() const
Gets the condition number of the basis matrix (if available).
| Returns | Condition number kappa, or std::nullopt if the backend cannot compute one (e.g. no basis after barrier without crossover, backend does not expose the query, or the native API reported failure). |
|---|
Callers must NOT treat a missing value as 1.0 — that silently poisons any std::max-based aggregation across a (scene, phase) grid. Use std::optional::value_or, the bool-convert, or explicit has_value() checks instead.
Index gtopt:: LinearInterface:: get_numcols() const
Gets the number of variable columns in the problem.
| Returns | Number of columns (see get_numrows rationale). |
|---|
Index gtopt:: LinearInterface:: get_numrows() const
Gets the number of constraint rows in the problem.
| Returns | Number of rows (signed Index to match LinearProblem's API and the solver backends — every solver C API uses int, and the strong-index RowIndex constructor takes Index). |
|---|
double gtopt:: LinearInterface:: get_obj_constant() const noexcept
Current accumulated objective constant on this interface (physical units, i.e. raw × scale_objective). Zero on a freshly-loaded LP with no add_obj_constant calls; otherwise reflects the sum of LinearProblem::add_obj_constant (forwarded via flatten()) plus any post-flatten LinearInterface::add_obj_constant calls. Returns physical scale for API symmetry with the mutator, even though the underlying storage is raw-scale m_scaling_.obj_constant_raw.
double gtopt:: LinearInterface:: get_obj_constant_raw() const noexcept
Raw-scale view of the accumulated constant (LP units). Useful for diagnostics that need to inspect what gets added to get_obj_value_raw() directly. Equal to get_obj_constant() / scale_objective.
double gtopt:: LinearInterface:: get_obj_value() const
Gets the objective value in physical (unscaled) units.
| Returns | Physical objective value (post-descaling) |
|---|
Returns raw_obj × scale_objective, converting from LP space back to physical cost units. Equivalent to the old manual descaling get_obj_value_raw() * options.scale_objective().
double gtopt:: LinearInterface:: get_obj_value_raw() const
Gets the raw LP objective value (in solver/LP space).
| Returns | Raw LP objective value (pre-descaling) |
|---|
Returns the value the LP solver reports directly, before scale_objective is reversed. Use get_obj_value() when callers need physical / cost units; use this only for tests and diagnostics that need to inspect the LP-side value the solver actually returned.
ScaledView gtopt:: LinearInterface:: get_row_dual()
Gets LP-space dual values, scaled by scale_objective / row_scale.
| Returns | Zero-copy lazy view per element (LP-space dual, cost_factor-folded). |
|---|
Important: despite the historical name, this does NOT return truly physical shadow prices in $/[physical-unit]/hour. The result is raw_dual × scale_objective / composite_row_scale, which unscales:
- the global
scale_objectivedivisor applied at flatten; - row-max equilibration (
max|coeff|); - any explicit
SparseRow::scale(used for column-side neutralization, e.g. cancelling a state-variable column'svar_scale).
It does NOT unscale the per-(scenario, stage, block) cost_factor = probability × discount × duration that's folded into the LP cost coefficients via CostHelper::block_ecost / stage_ecost. Callers who need shadow prices in physical $/[unit]/hour must additionally divide by CostHelper::cost_factor(scenario, stage[, block]).
Two production paths already do this:
OutputContext::add_row_dual(block-level rows): multiplies byblock_icost_factors() = 1 / cost_factor(s, t, b).OutputContext::add_row_dual(stage-level rows): multiplies byscenario_stage_icost_factors() = 1 / cost_factor(s, t).
Internal SDDP cut math intentionally consumes the LP-folded value here: the cut's RHS and coefficients are uniformly folded, so the cut bounds the folded value function of the destination master LP — no unit cancellation is required (docs/formulation/sddp-cut-validity.md §2). See benders_cut.cpp for the cut convention.
Precondition: backend must be live.
std::span<const double> gtopt:: LinearInterface:: get_row_dual_raw()
Gets raw solver dual values (no descaling).
| Returns | Span view of raw solver dual values |
|---|
Returns solver duals as-is. Use this for internal LP algebra that operates in solver coordinates (e.g. cut coefficient computation where row equilibration is accounted for separately).
ScaledView gtopt:: LinearInterface:: get_row_low() const noexcept
Gets physical lower bounds for all constraint rows.
| Returns | ScaledView over solver row lower bounds |
|---|
When row equilibration is active, the raw bounds are multiplied by the per-row scale factor to recover physical units: physical_bound = LP_bound × row_scale. When row scales are empty, returns raw values unchanged.
auto gtopt:: LinearInterface:: get_row_low_raw() const
Gets raw lower bounds for all constraint rows (LP units).
| Returns | Span view of raw row lower bounds |
|---|
When row equilibration is active, these are the equilibrated bounds (divided by the per-row scale factor). Use get_row_low() for physical (unscaled) bounds.
double gtopt:: LinearInterface:: get_row_scale(RowIndex index) const noexcept
Gets the row equilibration scale factor for a single row.
| Parameters | |
|---|---|
| index | Row index |
| Returns | Scale factor (1.0 if row_scales is empty or not populated) |
Row equilibration divides each row by s = max|coeff|, so the LP dual is π_LP = s × π_phys. get_row_scale() returns s.
const auto& gtopt:: LinearInterface:: get_row_scales() const noexcept
Gets all row equilibration scale factors.
| Returns | Const reference to the row scale vector (empty if not populated) |
|---|
ScaledView gtopt:: LinearInterface:: get_row_upp() const noexcept
Gets physical upper bounds for all constraint rows.
| Returns | ScaledView over solver row upper bounds |
|---|
auto gtopt:: LinearInterface:: get_row_upp_raw() const
Gets raw upper bounds for all constraint rows (LP units).
| Returns | Span view of raw row upper bounds |
|---|
int gtopt:: LinearInterface:: get_status() const
Gets the solver-specific status code.
| Returns | Status code (interpretation depends on solver) |
|---|
bool gtopt:: LinearInterface:: has_backend() const noexcept
Check whether the solver backend is loaded.
| Returns | true if load_flat() has been called and release_backend() has not |
|---|
bool gtopt:: LinearInterface:: has_decompressed_snapshot() const noexcept
True iff the snapshot's flat_lp vectors are currently decompressed (i.e. matbeg is populated). This is a stronger condition than has_snapshot_data() — under LowMemoryMode::compress the snapshot may be present but compressed, in which case clone_from_flat will throw. Callers that want to dispatch on the parallel-safe clone_from_flat route must check this first and either fall back to clone() (mutex-serialised) or wrap the call in a DecompressionGuard (linear_interface_decompress_guard.hpp) to re-hydrate the flat_lp for the duration of the clone.
bool gtopt:: LinearInterface:: has_integer_cols() const
True iff at least one column is currently flagged integer. Cheap linear scan; short-circuits on the first integer column. Used to gate the fix-integers dual-recovery pass so pure-LP solves pay nothing.
bool gtopt:: LinearInterface:: has_mip_incumbent() const
True when the last solve was a MIP that holds an integer-feasible incumbent (optimal or stopped at a limit) — see SolverBackend::has_mip_incumbent. False when the backend is released or cannot tell.
double gtopt:: LinearInterface:: infinity() const noexcept
Solver's representation of +infinity for variable bounds.
Safe to call even when the backend has been released (low-memory modes): the value is cached at ctor time and on every successful load_flat. Used by the rebuild callback's flatten_from_collections pass, which needs infinity before the backend is repopulated.
std::expected<int, Error> gtopt:: LinearInterface:: initial_solve(const SolverOptions& solver_options = {})
Performs initial solve of the problem from scratch.
| Parameters | |
|---|---|
| solver_options | Options controlling the solve process |
| Returns | Expected with solver status code (0 = optimal) or error |
void gtopt:: LinearInterface:: install_pricing_duals(PricingDuals pricing)
Publish pricing duals while keeping the current primal.
Call AFTER a successful polish_mip: the current primal (the MIP dispatch, polished) is kept and the row duals / reduced costs are replaced by pricing's. The values are written to the LI solution cache, which every reader consults first (under LowMemoryMode::off this is a deliberate, pricing-scoped exception to I6, dropped again at the next solve entry point). Always records pricing.outcome in last_pricing(); installs nothing when outcome.applied is fixed or the vector sizes do not match.
bool gtopt:: LinearInterface:: is_continuous(ColIndex index) const
Checks if a variable is continuous.
| Parameters | |
|---|---|
| index | Column index to check |
| Returns | True if continuous, false otherwise |
bool gtopt:: LinearInterface:: is_dual_infeasible() const
Checks if the problem is dual infeasible.
| Returns | True if dual infeasible, false otherwise |
|---|
bool gtopt:: LinearInterface:: is_integer(ColIndex index) const
Checks if a variable is integer.
| Parameters | |
|---|---|
| index | Column index to check |
| Returns | True if integer, false otherwise |
bool gtopt:: LinearInterface:: is_optimal() const
Checks if the solution is optimal.
| Returns | True if optimal solution found, false otherwise |
|---|
bool gtopt:: LinearInterface:: is_prim_infeasible() const
Checks if the problem is primal infeasible.
| Returns | True if primal infeasible, false otherwise |
|---|
bool gtopt:: LinearInterface:: is_snapshot_deduplicated() const noexcept
True when the compressed snapshot is stored as a delta against a shared cross-scene base (see FlatLpDedupRegistry).
std::size_t gtopt:: LinearInterface:: kappa_queries() const noexcept
Backend kappa queries since construction (testing / profiling: pins the one-query-per-solve contract).
const MipPolishOutcome& gtopt:: LinearInterface:: last_mip_polish() const noexcept
Outcome of the last polish_mip since the last solve (default / not attempted when none ran).
const SolverOptions& gtopt:: LinearInterface:: last_solver_options() const noexcept
The effective SolverOptions applied to the backend on the last initial_solve / resolve.
Includes backend-optimal defaults, user overlays, and the scale_objective fold applied to the reduced-cost optimality tolerance (optimal_eps). Primarily for diagnostics / tests.
void gtopt:: LinearInterface:: load_flat(const FlatLinearProblem& flat_lp)
Loads a flattened linear problem into the solver.
| Parameters | |
|---|---|
| flat_lp | The flattened problem representation |
| Exceptions | |
| std::runtime_error | if the problem cannot be loaded |
If the backend was previously released, it is automatically recreated from the saved solver name before loading.
const LpValidationStats& gtopt:: LinearInterface:: lp_validation_stats() const noexcept
Read-only access to this LP's incremental validation stats.
Stats are accumulated by every add_col / add_row / set_* write that lands on the LP after set_validation_options(...) is called. The default-constructed LpValidationOptions has enable.value_or(true) → tracking is on out of the box.
void gtopt:: LinearInterface:: materialize_labels() const
Force label synthesis into the internal caches + name→index maps without producing output vectors. Useful for callers that subsequently read row_name_map() / col_name_map() or row_index_to_name() / col_index_to_name() and need them populated under the lazy add_col / add_row path.
void gtopt:: LinearInterface:: merge_solver_stats(const SolverStats& other) noexcept
Fold another LP's counters into this one.
Used by elastic-filter paths that resolve a clone()d LP and discard it: call this on the original with clone.solver_stats() before the clone is destroyed so the solve attempts it made still show up in the final report.
SolverStats& gtopt:: LinearInterface:: mutable_solver_stats() noexcept
Mutable accessor to the solver-counter block.
Exposed for out-of-class instrumentation — specifically SDDPMethod::backward_pass_single_phase, which bumps the six bwd_*_s timers plus bwd_step_count on the previous-phase LP as it installs each optimality cut. Callers are expected to be single-writer threads for the underlying LP (same contract as every other mutating method on LinearInterface).
double gtopt:: LinearInterface:: normalize_bound(double value) const noexcept
Normalize a bound value: map gtopt::DblMax to the solver's infinity.
SparseCol/SparseRow use std::numeric_limits<double>::max() as default unbounded markers, but solver backends (e.g. HiGHS) may use a smaller infinity threshold (e.g. 1e30). This method translates at the LinearInterface boundary so that formulation code and solver agree.
RowIndex gtopt:: LinearInterface:: numrows_as_index() const
Typed row count — use instead of RowIndex{li.get_numrows()} at every call site.
get_numrows() already returns Index, so this just wraps the strong-type ctor. Matches the typed API used across the rest of the LP layer (add_row → RowIndex, delete_row → RowIndex, …) so idiomatic call sites stay inside strong-index space.
std::size_t gtopt:: LinearInterface:: pending_coeffs_size() const noexcept
Companion to active_cuts_size — count of post-snapshot raw LP coefficient overrides recorded via set_coeff_raw. Surfaced for the LI release diagnostic trace and unit tests that assert the replay channel is wired (the large hydrothermal case p51 regression guard).
std::size_t gtopt:: LinearInterface:: pending_rhs_size() const noexcept
Companion to pending_coeffs_size for row-RHS overrides recorded via set_rhs_raw.
bool gtopt:: LinearInterface:: pin_logic_rows() const noexcept
LpMatrixOptions::pin_logic_rows recorded for this LP (set by load_flat): while true, add_row / add_rows keep SparseRow::pin_scale rows at row factor 1.
std::expected<MipPolishOutcome, Error> gtopt:: LinearInterface:: polish_mip(const SolverOptions& opts)
Polish the MIP incumbent: fix its discrete decisions and re-solve the LP (objective, primal AND duals).
| Parameters | |
|---|---|
| opts | Options for the fixed-integer LP (time limit = the polish slice of the caller's budget). |
Runs fix_integers_and_resolve(opts) after ANY MIP stop that holds an incumbent — proven optimal, or stopped at a time / node / memory / solution limit (SolverBackend::has_mip_incumbent). A non-optimal incumbent's continuous part is often far from optimal for its own integer decisions; the fixed-integer LP returns the best dispatch for them, with consistent duals. No-op (attempted == false) on a pure LP. The outcome is also kept in last_mip_polish() until the next solve.
auto gtopt:: LinearInterface:: post_flatten_col_labels_meta_size() const noexcept
Diagnostic: entries held in the per-instance post-flatten label metadata (alpha, cut rows, elastic slacks, …). Must track the number of post-load_flat additions, never the structural size.
void gtopt:: LinearInterface:: reconstruct_backend()
Reconstruct backend from saved flat LP + dynamic cols + active cuts. Cold-start: the barrier method (default solver algorithm) gains nothing from a starting solution, so no warm-start vectors are accepted. Pre-solve readers of get_col_sol*() consume the cached vectors via the m_backend_solution_fresh_ gate.
void gtopt:: LinearInterface:: record_dynamic_row(SparseRow row)
Record a structural row added after the initial flatten/load_flat (typically cascade elastic-target constraints). No-op under LowMemoryMode::off. The recorded row is replayed in apply_post_load_replay BEFORE save_base_numrows() so the structural-vs-cut boundary correctly classifies it as structural — this is what distinguishes it from record_cut_row, which records post-baseline rows for the SDDP cut store.
Index gtopt:: LinearInterface:: relax_integers()
Relaxes every integer column to continuous (LP relaxation).
| Returns | Number of columns relaxed from integer to continuous. |
|---|
Iterates all columns and, for each currently flagged as integer, calls set_continuous(col). Used by the SDDP/Benders aperture path: the "master" LP may carry binary commitment variables (e.g. UC.jl-converted MIP), but the per-aperture subproblem clones must be LP — Benders cuts are only valid for convex subproblems.
Cheap: a single linear sweep with one solver call per integer column. No LP rebuild is needed. Idempotent: a second call is a no-op (no columns are flagged as integer after the first call). Returns the number of columns flipped to continuous; 0 when the problem was already a pure LP.
void gtopt:: LinearInterface:: release_backend_scratch() const noexcept
Free the backend's pointer-getter scratch buffers (see SolverBackend::release_scratch). Invalidates every span previously returned by the raw getters (get_col_sol_raw, get_col_low_raw, …) when they point into backend scratch. Safe in every low-memory mode; no-op when the backend is released or keeps no scratch.
const LpReplayBuffer& gtopt:: LinearInterface:: replay_buf() const noexcept
Const accessor for the embedded LP replay buffer.
Used by regression tests to assert on replay-buffer state (dynamic cols/rows, active cuts, pending col bounds) without granting mutable access to the buffer.
void gtopt:: LinearInterface:: reserve_active_cuts(std::size_t n)
Pre-reserve capacity for active cuts. Cut loaders that know the expected row count ahead of time can call this before their add_row + record_cut_row loop to avoid log-N reallocations.
void gtopt:: LinearInterface:: reset_from(const LinearInterface& source,
size_t base_rows)
Reset this LP to a base state by copying column bounds from source and deleting any rows beyond base_rows.
| Parameters | |
|---|---|
| source | The original (unmodified) LP to copy bounds from |
| base_rows | Number of structural rows to keep (delete beyond) |
Used by the clone pool to reuse a cached LP clone across aperture solves without re-allocating the underlying solver.
std::expected<int, Error> gtopt:: LinearInterface:: resolve(const SolverOptions& solver_options = {})
Resolves the problem with updated data using warm start.
| Parameters | |
|---|---|
| solver_options | Options controlling the solve process |
| Returns | Expected with solver status code (0 = optimal) or error |
ResourceClass gtopt:: LinearInterface:: resource_class() const noexcept
Dominant resource class of the backend (cpu for every solver that doesn't declare otherwise; gpu for cuOpt). Cached once at construction from the plugin's SolverResourceDescriptor so the per-solve read is lock-free. SolverTier stamps this onto the work pool's task requirements to gate GPU solves on the process-global GPU token bucket.
void gtopt:: LinearInterface:: restore_active_cuts(std::vector<SparseRow> cuts) noexcept
Restore previously-taken active cuts (rollback path on rebuild failure). Replaces any current active-cuts buffer.
void gtopt:: LinearInterface:: restore_dynamic_cols(std::vector<SparseCol> cols) noexcept
Restore previously-taken dynamic columns (rollback path on rebuild failure). Replaces any current dynamic-cols buffer.
Index gtopt:: LinearInterface:: restore_integers(std::span<const int> integer_cols)
| Returns | Number of columns restored to integer. |
|---|
Re-mark the given columns as integer, undoing a prior relax_integers(). integer_cols must be the snapshot of indices that were integer BEFORE the relaxation (taken first, since relaxation hides integrality). Delegates to SolverBackend::restore_integers (a single problem-type flip on CPLEX, a per-column loop otherwise).
ConstraintScaleType gtopt:: LinearInterface:: row_cost_scale_type_at(RowIndex index) const noexcept
Objective time-basis of a row (Power / Energy / Raw), used by OutputContext to pick the inverse cost-factor family for the row's dual readback. Out-of-range (post-flatten / cut) indices default to Power. Populated from FlatLinearProblem::row_cost_scale_types.
std::span<const ConstraintScaleType> gtopt:: LinearInterface:: row_cost_scale_types() const noexcept
Whole-vector view of per-row objective time-basis. Empty when not populated (bare LinearInterface / unflattened LP).
void gtopt:: LinearInterface:: save_base_numrows()
Save the current row count as the "base" model size.
All rows added after this point are considered cuts and are eligible for pruning. Must be called once after the structural LP is built, before any Benders cuts are added.
compress (and the legacy snapshot alias) pre-seed m_cached_numrows_ via defer_initial_load, so get_numrows() returns the correct value without a reconstruct — preserving the invariant that save_base_numrows does not flip the released flag.
void gtopt:: LinearInterface:: save_snapshot(FlatLinearProblem flat_lp)
Save a flat LP snapshot for future reconstruction. Call from create_lp() — the LinearInterface decides whether to keep based on the configured level.
double gtopt:: LinearInterface:: scale_objective() const noexcept
Gets the global objective scaling factor.
| Returns | The objective scale factor (1.0 if not set) |
|---|
obj_physical = obj_LP × scale_objective. Set during load_flat() from FlatLinearProblem::scale_objective.
void gtopt:: LinearInterface:: set_base_numrows(Index n) noexcept
Set the base row count explicitly (used after a rebuild restores state without re-querying the live backend).
bool gtopt:: LinearInterface:: set_basis(Basis basis)
Install basis as an advanced (dual/primal simplex) start for the next resolve. The basis may have been captured from a related LP (the SDDP case: cuts appended rows since capture); this reconciles it to the current dimensions via reconcile_basis (appended rows → basic slack, appended cols → nonbasic at lower, surplus → truncated) before handing an exact-sized basis to the backend. Combine with SolverOptions::advanced_basis = true and algorithm = LPAlgo::dual. Returns false if the backend cannot accept a basis (a benign skip).
void gtopt:: LinearInterface:: set_binary(ColIndex index)
Sets a variable to be binary (0-1 integer).
| Parameters | |
|---|---|
| index | Column index to modify |
void gtopt:: LinearInterface:: set_coeff(RowIndex row,
ColIndex column,
double physical_value)
Sets a coefficient in the constraint matrix from physical units.
| Parameters | |
|---|---|
| row | Row index of the coefficient |
| column | Column index of the coefficient |
| physical_value | Physical coefficient value |
Converts from physical to LP units: raw_coeff = physical_coeff / col_scale / row_scale
void gtopt:: LinearInterface:: set_coeff_raw(RowIndex row,
ColIndex column,
double value)
Sets (modifies) a raw coefficient in the constraint matrix.
| Parameters | |
|---|---|
| row | Row index of the coefficient |
| column | Column index of the coefficient |
| value | Raw coefficient value (LP units) |
The value is stored as-is in LP units.
void gtopt:: LinearInterface:: set_col_bounds(std::span<const ColIndex> indices,
std::span<const char> lu,
std::span<const double> physical_values)
Bulk col-bound mutation in physical (descaled) units.
Each physical_values[i] is divided by col_scale[indices[i]] before being routed through set_col_bounds_raw, mirroring the per-element set_col_low(idx, phys) / set_col_upp(idx, phys) descale: raw = physical / col_scale.
±infinity handling: values that already represent a solver-side unbounded marker — ±DblMax, ± solver infinity(), or ± std::numeric_limits<double>::infinity() — are passed through to the raw setter UNCHANGED (not divided by col_scale). Dividing a finite solver-infinity (e.g. HiGHS 1e30) by a non-unit scale would yield a huge-but-finite value that normalize_bound could no longer map back to the solver's signed infinity, producing an incorrect tight bound. The raw setter's normalize_bound then maps the pass-through value to the active solver's signed infinity.
void gtopt:: LinearInterface:: set_col_bounds_raw(std::span<const ColIndex> indices,
std::span<const char> lu,
std::span<const double> values)
Bulk col-bound mutation in LP-raw units.
Parallel arrays of length indices.size():
indices[i]— target column.lu[i]— 'L' (lower), 'U' (upper), or 'B' (both).values[i]— raw LP value (normalised vianormalize_boundso±DblMax/±std::infmap to the solver's signed infinity).
One dispatch into SolverBackend::set_col_bounds_bulk — CPLEX collapses it to a single CPXchgbds call. Per element the method runs the same bookkeeping the singular set_col_low_raw / set_col_upp_raw setters do: validation hooks (note_bound), replay-buffer pending-bound capture (so a release_backend → reconstruct_backend cycle re-applies the override), and cached-solution invalidation.
Companion to set_obj_coeffs_raw(span) and the row-side add_rows_raw(span) bulk APIs. Empty input is a safe no-op; size mismatch between the three spans throws std::invalid_argument.
void gtopt:: LinearInterface:: set_col_scale(ColIndex index,
double scale)
Sets the physical-to-LP scale factor for a single column.
| Parameters | |
|---|---|
| index | Column index |
| scale | Physical-to-LP scale factor (physical = LP × scale) |
Use this for columns added dynamically (via add_col) that need a non-unit scale. Grows the internal scale vector as needed.
void gtopt:: LinearInterface:: set_continuous(ColIndex index)
Sets a variable to be continuous (floating-point).
| Parameters | |
|---|---|
| index | Column index to modify |
void gtopt:: LinearInterface:: set_equilibration_method(LpEquilibrationMethod method) noexcept
Override the equilibration method recorded for this LP. Normally set by load_flat from FlatLinearProblem::equilibration_method; this setter exists for unit tests that build an LP directly via add_col / add_row (no flatten pass) and still want to exercise the add_equilibrated_row path.
void gtopt:: LinearInterface:: set_integer(ColIndex index)
Sets a variable to be integer.
| Parameters | |
|---|---|
| index | Column index to modify |
void gtopt:: LinearInterface:: set_label_maker(LabelMaker lm) noexcept
Sets the LabelMaker used to generate and gate LP col/row labels.
| Parameters | |
|---|---|
| lm | The LabelMaker to use (stored by value) |
The LabelMaker carries the LpNamesLevel that controls which labels are produced for add_col() / add_row() and whether duplicate names are treated as errors. It is normally installed automatically by load_flat() (which copies it from FlatLinearProblem::label_maker) but can also be set explicitly via this setter for tests or specialized callers.
void gtopt:: LinearInterface:: set_last_pricing(PricingOutcome outcome) noexcept
Record a pricing outcome without installing duals (e.g. the default fixed mode, whose prices are the polish duals).
void gtopt:: LinearInterface:: set_log_tag(std::string tag) noexcept
Set a human-readable log tag (e.g. "SDDP Forward [i0 s1 p2]") that prefixes solver warnings emitted by initial_solve() / resolve(). When empty, warnings fall back to get_prob_name(). Callers are expected to set this before each solve so fallback messages carry the same context as the surrounding SDDP/monolithic info logs.
Takes the tag by value so set_log_tag(sddp_log(...)) (which returns the lightweight SDDPLogTag aggregate with an implicit operator std::string()) materialises the string ONCE and moves it into m_log_tag_ — the previous string_view signature forced callers to wrap as std::string(sddp_log(...)) and then assign(string_view) re-allocated, totalling 2 allocs + 1 free per call. Now: 1 alloc (in operator std::string) + 1 move (zero-alloc when the SBO buffer matches). std::format(...) callers and string-literal callers (via const char* → string implicit ctor) keep working unchanged.
bool gtopt:: LinearInterface:: set_mip_start(std::span<const double> col_values,
MipStartEffort effort)
Inject a starting integer (MIP-start / warm incumbent) solution into the backend. col_values is a dense RAW-space vector (size get_numcols()) — build it from get_col_sol_raw(), never the descaled get_col_sol(). Delegates to SolverBackend::set_mip_start; returns the backend's accept flag (false on LP-only / unsupporting backends — a benign skip).
void gtopt:: LinearInterface:: set_name_store(LpNameSpillStore* store,
std::string key) noexcept
Attach the run-lifetime async metadata store and this cell's spill key. Set by create_linear_interface after it spills (and drops) this LP's label metadata; generate_labels_from_maps reloads from the store (on demand, cached) when the live label vectors are empty. Non-owning.
void gtopt:: LinearInterface:: set_obj_coeff(ColIndex index,
double physical_value)
Sets the objective coefficient for a column in physical units.
| Parameters | |
|---|---|
| index | Column index. |
| physical_value | Objective coefficient in physical units. |
Composes the same physical → LP transform that flatten() / add_col(SparseCol) apply to the cost field: raw = physical_value × col_scale[index] / scale_objective
When col_scale[index] == 1 and scale_objective == 1 (the common bare-LinearInterface / unflattened case), this is equivalent to writing physical_value to the backend directly.
void gtopt:: LinearInterface:: set_obj_coeff_raw(ColIndex index,
double value)
Sets the objective coefficient for a column in LP-raw units.
| Parameters | |
|---|---|
| index | Column index. |
| value | LP-raw objective coefficient. |
Writes value to the backend verbatim — no col_scale / scale_objective composition. Companion to the raw bound setters (set_col_low_raw, set_rhs_raw) and the raw accessor get_obj_coeff() (which returns the backend's raw obj vector).
void gtopt:: LinearInterface:: set_obj_coeffs_raw(std::span<const double> values)
Bulk overwrite of every objective coefficient (LP-raw units).
values MUST have size equal to the current get_numcols(); the implementation overwrites every coefficient in place. Routes directly to SolverBackend::set_obj_coeffs, which most plugins implement via a single native bulk call (CPLEX CPXchgobj, HiGHS changeColsCost, OSI setObjective, MindOpt / Gurobi *setdblattrarray). Plugins without a native bulk call fall back to the per-column loop in the base class — same wall-clock cost as the old per-column wrapper but expressed as a single call site.
Use case: SDDP elastic-clone Phase-1 zero-objective override (benders_cut.cpp), which previously spun a set_obj_coeff_raw loop over all N cols of the clone for every infeasible cell.
void gtopt:: LinearInterface:: set_row_scale(RowIndex index,
double scale)
Sets the row scale factor for a single row.
| Parameters | |
|---|---|
| index | Row index |
| scale | Row scale factor (physical_rhs = LP_rhs × scale) |
Use this for rows added dynamically (via add_row) that need a non-unit scale. Grows the internal scale vector as needed.
void gtopt:: LinearInterface:: set_share_label_meta(bool share) noexcept
Release the solver backend, freeing its memory.
All LinearInterface metadata (scales, name maps, variable_scale_map, base_numrows, stats) is preserved. When low_memory_level >= 2, the saved flat LP numeric vectors are compressed before release. The backend can be recreated by a subsequent call to reconstruct_backend() or load_flat(). Alias (true, default) or deep-copy (false) the label metadata of the flat LP on every subsequent load_flat.
void gtopt:: LinearInterface:: set_snapshot_dedup(std::shared_ptr<FlatLpDedupRegistry> registry,
std::string key) noexcept
Attach the cross-cell snapshot dedup registry and this cell's key (see FlatLpDedupRegistry). Must precede the first compression (note defer_initial_load compresses under compress); later calls only affect cells not yet compressed. is_snapshot_deduplicated() reports whether the stored snapshot actually uses a shared base.
void gtopt:: LinearInterface:: set_time_limit(double time_limit)
Sets a time limit for the solver.
| Parameters | |
|---|---|
| time_limit | Maximum solve time in seconds |
void gtopt:: LinearInterface:: set_validation_options(LpValidationOptions opts) noexcept
Install or replace this LP's validation thresholds.
Typically wired up at construction time from LpMatrixOptions::validation. Mutates only m_validation_options_; existing accumulator state is preserved.
PricingDuals gtopt:: LinearInterface:: solve_pricing_lp(PricingMode mode,
const SolverOptions& opts)
Solve the post-MIP pricing LP for mode on a clone.
Pre-condition: a MIP solve just completed and holds an incumbent; call BEFORE polish_mip / fix_integers_and_resolve (the polish relaxes integrality on the live backend — CPLEX even switches the problem type — so the integer set must be read first). This LP is never mutated: the pricing problem is built on a clone():
- every integer column NOT relaxed by
modeis pinned to its rounded incumbent value; - every SOS2 member is pinned to its incumbent value (an SOS declaration is inert in a pure LP);
- integrality is dropped and the clone is solved as an LP.
relaxedrelaxes every integer column;fast_startrelaxes the columns registered byFlatLinearProblem::fast_start_cols;fixedsolves nothing (the polish IS the fixed pricing LP).
A pricing LP that is not optimal (or a clone / solve error) yields outcome.applied = fixed, outcome.fallback = true and a reason — never an error: the caller keeps the fixed (polish) prices.
std::string gtopt:: LinearInterface:: solver_id() const
Solver identifier: "name/version" (e.g. "highs/1.13.1"). Safe to call even when the backend has been released.
const SolverStats& gtopt:: LinearInterface:: solver_stats() const noexcept
Read-only access to this LP's cumulative solver counters.
Counters are incremented by load_flat, initial_solve, resolve, and ensure_duals. Aggregation across LPs (e.g. for end-of-run reporting) is done by the caller via SolverStats::operator+=.
std::string gtopt:: LinearInterface:: solver_version() const
Solver library version string (e.g. "1.17.3"). Safe to call even when the backend has been released.
std::span<const int> gtopt:: LinearInterface:: sos2_member_cols() const noexcept
Flattened member-column indices of every SOS2 set pushed to the backend during load_flat (source of truth: FlatLinearProblem::sos2_sets). SOS members are CONTINUOUS columns, so the fix-integers dual-recovery pass must pin them to the MIP incumbent explicitly — an SOS declaration is inert in a pure LP re-solve and a freed λ ladder re-optimizes to SOS-infeasible vertices. Passed to SolverBackend::fix_mip_and_resolve_duals by fix_integers_and_resolve. Empty for the vast majority of LPs.
std::size_t gtopt:: LinearInterface:: sos2_set_count() const noexcept
Number of SOS2 sets pushed to the backend during load_flat. Read directly from the source FlatLinearProblem::sos2_sets vector at load time; remains constant for the lifetime of this LinearInterface (gtopt does not add dynamic SOS2 declarations post-load). Used by issue #504 unit tests to pin the schema → LP-build → backend forward path without inventing a solver-specific SOS2 query. 0 for the vast majority of LPs.
bool gtopt:: LinearInterface:: supports_set_coeff() const noexcept
Checks whether the solver supports in-place coefficient updates.
| Returns | true if set_coeff() is functional |
|---|
std::vector<SparseRow> gtopt:: LinearInterface:: take_active_cuts() noexcept
Move out the active Benders cuts so the caller can preserve them across a destructive rebuild.
std::vector<SparseCol> gtopt:: LinearInterface:: take_dynamic_cols() noexcept
Move out the recorded dynamic columns (alpha) so the caller can preserve them across a destructive rebuild.
bool gtopt:: LinearInterface:: update_dynamic_col_bounds(std::string_view class_name,
std::string_view variable_name,
double new_lowb,
double new_uppb) noexcept
Two-sided bound update for a dynamic column — used by the SDDP bound_alpha path which relaxes both the pinned lowb = 0 and uppb = 0 bootstrap in a single call. Semantics mirror update_dynamic_col_lowb: no-op under LowMemoryMode::off, returns true iff a matching (class_name, variable_name) entry was found in m_dynamic_cols_ and both bounds overwritten.
bool gtopt:: LinearInterface:: update_dynamic_col_bounds(std::string_view class_name,
std::string_view variable_name,
Uid variable_uid,
double new_lowb,
double new_uppb) noexcept
uid-discriminated two-sided bound update — used by CutSharingMode::multicut, where the N future-cost columns (varphi_0..N-1) share the α class/variable name and differ only by variable_uid = sddp_alpha_uid + source_scene. The name-only overload above always matches varphi_0; this one matches the requested variable_uid. Returns true iff the entry was found.
bool gtopt:: LinearInterface:: update_dynamic_col_lowb(std::string_view class_name,
std::string_view variable_name,
double new_lowb) noexcept
Update the lowb on the first m_dynamic_cols_ entry matching (class_name, variable_name) so that a subsequent snapshot reload (apply_post_load_replay) restores the column with the new lower bound rather than the original one. Returns true iff a matching entry was found and updated. No-op under LowMemoryMode::off (where m_dynamic_cols_ stays empty) — the live backend is the sole authority and needs no dynamic-col mirror.
std::expected<std::string, Error> gtopt:: LinearInterface:: write_lp(const std::string& filename,
LpFileFormat format = LpFileFormat:: lp,
LpFormatFallback fallback = LpFormatFallback:: other_format) const
Writes the model to <filename>.lp or <filename>.mps.
| Parameters | |
|---|---|
| filename | Path stem of the file to write (without extension) |
| format | Requested format: LpFileFormat::lp (default) or LpFileFormat::mps. |
| fallback | What to do when the backend cannot write format: other_format (default, for diagnostic dumps) writes the other format and logs a warning; strict (for an explicit user request) returns an error naming the backend. |
| Returns | The path of the file written (stem plus extension), or an error when no file could be written. An empty filename writes nothing and returns an empty path. |
const auto& gtopt:: LinearInterface:: col_index_to_name() const noexcept
Column index → name vector (empty string for unnamed columns). Populated alongside col_name_map when names are enabled.
const auto& gtopt:: LinearInterface:: row_index_to_name() const noexcept
Row index → name vector (empty string for unnamed rows). Populated alongside row_name_map when names are enabled.