gtopt::SolverBackend class

Abstract interface for LP/MIP solver backends.

Each solver plugin (CLP, CBC, CPLEX, HiGHS, …) provides a concrete implementation of this class. LinearInterface delegates all solver operations through this interface, enabling runtime solver selection via dlopen-loaded plugins.

Constructors, destructors, conversion operators

SolverBackend() defaulted
SolverBackend(const SolverBackend&) deleted
SolverBackend(SolverBackend&&) defaulted
~SolverBackend() defaulted virtual

Public functions

void add_col(double lb, double ub, double obj) pure virtual
void add_cols(int num_cols, const int* colbeg, const int* colind, const double* colval, const double* collb, const double* colub, const double* colobj) pure virtual
void add_row(int num_elements, const int* columns, const double* elements, double rowlb, double rowub) pure virtual
void add_rows(int num_rows, const int* rowbeg, const int* rowind, const double* rowval, const double* rowlb, const double* rowub) pure virtual
void add_sos2(std::span<const int> columns) virtual
void apply_options(const SolverOptions& opts) pure virtual
void clear_basis() virtual
void clear_log_filename() virtual
Stop file-based logging started by set_log_filename.
auto clone() const -> std::unique_ptr<SolverBackend> pure virtual
void close_log() pure virtual
auto col_lower() const -> const double* pure virtual
auto col_solution() const -> const double* pure virtual
auto col_upper() const -> const double* pure virtual
void delete_rows(int num, const int* indices) pure virtual
auto diagnose_infeasibility(int) -> std::optional<std::vector<std::string>> virtual
void disengage_robust_solve() pure virtual noexcept
void engage_robust_solve() pure virtual
void fill_col_cost(std::span<double> out) const virtual
void fill_col_lower(std::span<double> out) const virtual
void fill_col_sol(std::span<double> out) const virtual
void fill_col_upper(std::span<double> out) const virtual
void fill_row_dual(std::span<double> out) const virtual
auto fix_mip_and_resolve_duals(const SolverOptions& opts, std::span<const int> sos_member_cols) -> int virtual
auto get_algorithm() const -> LPAlgo pure virtual
Query the currently configured LP algorithm.
auto get_basis() const -> std::optional<Basis> virtual
auto get_coeff(int row, int col) const -> double pure virtual
auto get_kappa() const -> std::optional<double> pure virtual
Condition number of the current basis.
auto get_log_level() const -> int pure virtual
Query the current solver log verbosity level (0 = off).
auto get_num_cols() const -> int pure virtual
auto get_num_rows() const -> int pure virtual
auto get_presolve() const -> bool pure virtual
Query whether presolve is currently enabled.
auto get_prob_name() const -> std::string pure virtual
auto get_threads() const -> int pure virtual
Query the currently configured thread count (0 = solver default).
auto has_mip_incumbent() const -> bool virtual
auto infinity() const -> double pure virtual noexcept
Solver's representation of +infinity.
void initial_solve() pure virtual
auto is_abandoned() const -> bool pure virtual
auto is_continuous(int index) const -> bool pure virtual
auto is_integer(int index) const -> bool pure virtual
auto is_proven_dual_infeasible() const -> bool pure virtual
auto is_proven_optimal() const -> bool pure virtual
auto is_proven_primal_infeasible() const -> bool pure virtual
auto last_solve_effort() const -> SolveEffort virtual
void load_problem(int ncols, int nrows, const int* matbeg, const int* matind, const double* matval, const double* collb, const double* colub, const double* obj, const double* rowlb, const double* rowub) pure virtual
auto obj_coefficients() const -> const double* pure virtual
auto obj_value() const -> double pure virtual
void open_log(FILE* file, int level) pure virtual
auto operator=(const SolverBackend&) -> SolverBackend& deleted
auto operator=(SolverBackend&&) -> SolverBackend& defaulted
auto optimal_options() const -> SolverOptions pure virtual
Return backend-optimal default options (benchmarked).
void push_names(const std::vector<std::string>& col_names, const std::vector<std::string>& row_names) pure virtual
auto raw_status() const -> std::pair<int, std::string> virtual
auto reduced_cost() const -> const double* pure virtual
auto relax_all_integers() -> int virtual
void release_scratch() const virtual noexcept
void resolve() pure virtual
auto restore_integers(std::span<const int> integer_cols) -> int virtual
auto row_lower() const -> const double* pure virtual
auto row_price() const -> const double* pure virtual
auto row_upper() const -> const double* pure virtual
auto scratch_bytes() const -> std::size_t virtual noexcept
auto set_basis(const Basis&) -> bool virtual
void set_coeff(int row, int col, double value) pure virtual
void set_col_bounds_bulk(int num, const int* indices, const char* lu, const double* values) virtual
void set_col_lower(int index, double value) pure virtual
void set_col_solution(const double* sol) pure virtual
void set_col_upper(int index, double value) pure virtual
void set_continuous(int index) pure virtual
void set_integer(int index) pure virtual
void set_log_filename(const std::string&, int) virtual
Redirect solver log output to a file by name.
auto set_mip_start(std::span<const double>, MipStartEffort) -> bool virtual
void set_obj_coeff(int index, double value) pure virtual
void set_obj_coeffs(const double* values, int num_cols) virtual
void set_obj_offset(double) virtual noexcept
void set_prob_name(const std::string& name) pure virtual
void set_row_bounds(int index, double lb, double ub) pure virtual
void set_row_bounds_bulk(int num, const int* indices, const char* lu, const double* lo, const double* up) virtual
void set_row_lower(int index, double value) pure virtual
void set_row_price(const double* price) pure virtual
void set_row_upper(int index, double value) pure virtual
auto solver_name() const -> std::string_view pure virtual noexcept
Human-readable solver name (e.g. "clp", "highs").
auto solver_version() const -> std::string pure virtual
Solver library version string (e.g. "1.17.3", "22.1.1").
auto supports_mip() const -> bool pure virtual noexcept
True if this backend can solve mixed-integer problems.
auto supports_set_coeff() const -> bool pure virtual noexcept
auto write_lp(const char* filename, LpFileFormat format) -> bool pure virtual
Write the model to <filename>.lp or <filename>.mps.

Function documentation

void gtopt::SolverBackend::add_cols(int num_cols, const int* colbeg, const int* colind, const double* colval, const double* collb, const double* colub, const double* colobj) pure virtual

Parameters
num_cols Number of columns to add
colbeg Column-start offsets into colind/colval (size num_cols+1, colbeg[num_cols] == nnz)
colind Row indices for non-zeros (size colbeg[num_cols])
colval Non-zero coefficient values (size colbeg[num_cols])
collb Column lower bounds (size num_cols)
colub Column upper bounds (size num_cols)
colobj Column objective coefficients (size num_cols)

Bulk column addition in CSC (Compressed Sparse Column) format.

Mirrors add_rows for columns: a single solver call replaces what would otherwise be num_cols per-column add_col invocations, avoiding repeated reallocation of the backend's internal column metadata. Columns added by this path are continuous LP variables; callers needing integer columns should follow up with set_integer(idx).

void gtopt::SolverBackend::add_rows(int num_rows, const int* rowbeg, const int* rowind, const double* rowval, const double* rowlb, const double* rowub) pure virtual

Parameters
num_rows Number of rows to add
rowbeg Row-start offsets into rowind/rowval (size num_rows+1)
rowind Column indices for non-zeros
rowval Non-zero coefficient values
rowlb Row lower bounds (size num_rows)
rowub Row upper bounds (size num_rows)

Bulk row addition in CSR (Compressed Sparse Row) format.

void gtopt::SolverBackend::add_sos2(std::span<const int> columns) virtual

Parameters
columns Column indices, ordered to match the geometric breakpoint sequence (v_1, v_2, …, v_L). Must be non-empty; size < 2 is a no-op (SOS2 over a single column is vacuous).

Declare a Type-2 Special-Ordered-Set (SOS2) over the given column indices. SOS2 enforces that at most TWO of the listed columns can be non-zero in any feasible MIP solution, and that the two non-zero columns must be adjacent in the listed order. This is the canonical MIP encoding of piecewise-linear functions over a convex partition (Beale & Tomlin 1970; Vielma 2015 §3).

In gtopt this is consumed by the tangent_signed_flow L-secant upper bound (issue #504): with L > 1 segment columns v_l and Σ v_l ≥ |f|, the SOS2 enforces fill-order (v_1 saturates before v_2 starts) so the piecewise chord becomes tight at every breakpoint.

Index ordering in columns MUST match the geometric order of the underlying breakpoints. Weights default to 1, 2, 3, …, N in the backend implementation — gtopt does NOT expose custom SOS2 weights since the segment widths are already encoded in the column upper bounds.

Backend support matrix:

  • CPLEX — overrides with CPXaddsos (sostype 2)
  • Gurobi — overrides with GRBaddsos (GRB_SOS_TYPE2)
  • HiGHS — overrides with Highs_addSos when linked against HiGHS ≥ 1.6 (older versions: default fallback fires)
  • CBC/OSI — no SOS2 entry point on the OSI bridge gtopt uses; default fallback fires
  • MindOpt — TBD; default fallback fires

Default implementation throws std::runtime_error so a misconfigured LP (loss_use_sos2 = true against an unsupporting plugin) surfaces at LP-build time rather than silently dropping the SOS2 declaration. Backends that DO support SOS2 override this method.

void gtopt::SolverBackend::clear_basis() virtual

Discard any basis / solver state resident from earlier solves so the next solve starts cold. Needed after an abandoned solve: a backend that warm-starts implicitly from its resident basis (HiGHS reuses it and skips presolve) would otherwise restart from the same, possibly corrupted, basis. Default: no-op (backends that only warm-start on request, e.g. CPLEX ADVIND, have nothing to drop).

void gtopt::SolverBackend::clear_log_filename() virtual

Stop file-based logging started by set_log_filename.

Backends override to close/detach their native log file. Default is a no-op.

std::optional<std::vector<std::string>> gtopt::SolverBackend::diagnose_infeasibility(int) virtual

Returns Conflicting constraint labels, or std::nullopt if unsupported.

Diagnose why the current problem is infeasible, returning a human-readable list of the conflicting constraints (a minimal infeasible subsystem). Used by the MIP-start relaxation pre-pass when the LP relaxation comes back infeasible and the user requested feasopt diagnosis.

Backends: CPLEX overrides via the conflict refiner (CPXrefineconflict + CPXgetconflict). Others return std::nullopt (diagnosis unsupported); the caller then reports only that the relaxation is infeasible.

void gtopt::SolverBackend::disengage_robust_solve() pure virtual noexcept

Restore parameters captured by engage_robust_solve. No-op when engage was never called. Safe to call from a destructor.

void gtopt::SolverBackend::engage_robust_solve() pure virtual

Switch the solver into a high-effort, numerically-conservative mode for the next solve. Each backend internally:

  • Saves whichever native parameters it modifies.
  • Loosens the optimality / feasibility / barrier tolerances (typical: × 10).
  • Enables solver-specific robustness knobs (CPLEX: NUMERICALEMPHASIS=1, PERIND=1, REPEATPRESOLVE=3; HiGHS: enable the high-accuracy IPM + scaling; CBC/CLP: tightened pivot tolerances).

May be called repeatedly — implementations should treat successive engages as additional "× 10" loosenings (or no-op, at the implementer's discretion) so the fallback chain can escalate. Always paired with disengage_robust_solve() via the RobustSolveGuard RAII helper.

int gtopt::SolverBackend::fix_mip_and_resolve_duals(const SolverOptions& opts, std::span<const int> sos_member_cols) virtual

Parameters
opts Solver options for the follow-up LP solve (the caller typically enables crossover so a barrier backend produces clean vertex duals).
sos_member_cols Flattened member-column indices of every SOS set previously declared via add_sos2 (the caller — LinearInterface — records them at load_flat; the backend does not track SOS membership itself). Empty for the vast majority of MIPs.
Returns Number of pinned columns (integers + SOS members): 0 = pure LP / nothing to do (caller's existing duals already valid); > 0 = fixed and re-solved (caller must refresh its solution cache from the backend); < 0 = no incumbent / failed fixed-LP solve (state restored per the bail contract: MIP primal preserved, duals unavailable).

Fix every discrete decision to its incumbent (MIP-optimal) value and re-solve as an LP to recover row duals / reduced costs, warm-started where the backend supports it. Called right after a MIP resolve() on the live backend; the fixed LP is a throwaway whose only product is the committed-solution duals.

"Discrete decision" covers BOTH integer/binary columns AND the support of every SOS set: SOS-member columns are CONTINUOUS and an SOS declaration is inert in a pure LP re-solve, so leaving the members free would let the fixed LP re-optimize them WITHOUT the adjacency constraint. Concretely, for the SOS2 λ-form line-loss ladder under a negative bus-dual pair-sum, λ mass migrates to NON-ADJACENT breakpoints (SOS2-infeasible) and the loss column re-inflates to its envelope ceiling — silently replacing the SOS2-feasible MIP incumbent in the published solution. Pinning the SOS members to the incumbent keeps the documented dual semantic: duals are conditional on the incumbent's discrete choices — SOS segment choices included.

Output is the COMMITTED-solution duals (integers and SOS members pinned to the incumbent), identical to the portable default path — only wall-clock differs.

Also the post-MIP POLISH: LinearInterface::polish_mip calls it after ANY MIP stop that holds an incumbent (has_mip_incumbent), not only after a proven-optimal one, so a MIP stopped by its time limit reports the best dispatch for its incumbent's integer decisions (the fixed-LP primal + objective) together with duals.

Default (portable) path: gather integer columns via is_integer, read the current column solution (col_solution), pin each integer column to std::round(value) on both bounds, pin each SOS-member column to its (continuous) incumbent value, relax_all_integers, apply_options(opts), then resolve(). This default is already warm on Clp/OSI (its resolve() retains the basis) and correct everywhere. CPLEX overrides with the single-call CPXPROB_FIXEDMILP fast path (fixes integers AND the SOS support AND installs the incumbent-node basis, then a warm dual-simplex re-solve — no barrier, no crossover).

Bail contract (return -1): the implementation must leave the live problem holding the MIP incumbent — original bounds and integrality restored, col_solution() returning the incumbent primal — because under LowMemoryMode::off the live backend is the single source of truth for every downstream read (invariant I6). Duals are UNAVAILABLE after a bail; the caller must not publish them. The portable path below implements this by restoring the pinned bounds + integrality and re-installing the incumbent via set_col_solution; the CPLEX override flips the problem type back from CPXPROB_FIXEDMILP (which restores bounds, ctypes AND the retained incumbent natively).

std::optional<Basis> gtopt::SolverBackend::get_basis() const virtual

Capture the current simplex basis (column + row statuses).

Returns std::nullopt when no basis is available — the LP was not solved by simplex/crossover (a bare interior point has no basis), or the backend is basis-less (cuOpt PDLP). On success the result has col_status.size() == get_num_cols() and row_status.size() == get_num_rows().

Default: unsupported (nullopt). A basis is an (n+m) status vector — no matrix data, no solution values.

std::optional<double> gtopt::SolverBackend::get_kappa() const pure virtual

Condition number of the current basis.

Returns std::nullopt when the backend cannot compute it (e.g. no basis after a barrier solve without crossover, the underlying query failed, or the backend does not expose a basis-conditioning query at all). Callers MUST NOT interpret a missing value as 1.0 — doing so silently poisons any std::max-based aggregation across a (scene, phase) grid.

bool gtopt::SolverBackend::has_mip_incumbent() const virtual

True when the last solve was a MIP that stopped holding an integer-feasible incumbent that col_solution() returns — whatever the termination status: optimal, or stopped early by a time / node / memory / solution limit or an abort with an incumbent in hand (CPLEX CPXMIP_TIME_LIM_FEAS, HiGHS primal_solution_status == feasible, Gurobi / MindOpt SolCount > 0, SCIP best solution, CBC best solution, cuOpt FEASIBLE_FOUND).

Gates the post-MIP polish (LinearInterface::polish_mip): when a MIP is NOT proven optimal its incumbent's continuous part can be far from the best dispatch for the incumbent's integer decisions, so gtopt fixes the integers and re-solves the LP. Without an incumbent there is nothing to fix.

Default false: a backend that cannot tell keeps the legacy behaviour (no polish after a non-optimal stop). Pure-LP backends never override it.

SolveEffort gtopt::SolverBackend::last_solve_effort() const virtual

Report the most recent solve's effort (wall seconds + deterministic ticks). Default {0,0} means "not provided" — the LinearInterface solve layer then substitutes its own measured wall time (and ticks = seconds). Backends with native instrumentation override: CPLEX uses CPXgettime + CPXgetdettime; backends without ticks set ticks == seconds; backends without native time measure it themselves.

SolverOptions gtopt::SolverBackend::optimal_options() const pure virtual

Return backend-optimal default options (benchmarked).

Called by LinearInterface before merging user-supplied options. Each backend returns its empirically best configuration; the caller overlays user-provided options on top so explicit settings always win.

std::pair<int, std::string> gtopt::SolverBackend::raw_status() const virtual

Solver-native termination status of the last solve, code and name (CPLEX CPXgetstat / CPXgetstatstring, HiGHS model status), for logs: e.g. {5, "optimal with unscaled infeasibilities"}. Default {-1, "n/a"} for backends that do not report one.

int gtopt::SolverBackend::relax_all_integers() virtual

Returns Number of columns flipped to continuous, or -1 if the backend cannot determine the count cheaply (caller logs informationally; correctness does not depend on the value).

Relax every integer column to continuous in a single backend call. Hot path: invoked once per aperture clone in LinearInterface::relax_integers(), called immediately before the per-clone backward-pass resolve in source/sddp_aperture.cpp (above clone.resolve(aperture_opts)).

Default fallback enumerates get_numcols() and calls set_continuous(i) only on columns where is_integer(i) is true, returning the number of columns flipped. Plugins SHOULD override when the native API offers a real one-call path — those overrides drop both per-call dispatch overhead and any internal per-element MIP→LP bookkeeping the solver may do.

void gtopt::SolverBackend::release_scratch() const virtual noexcept

Free the scratch storage behind the pointer-getters above.

Backends whose C API writes into a caller-owned buffer (CPLEX, Gurobi, MindOpt) keep one numcols / numrows vector per getter so the returned pointer outlives the call. Those vectors are refilled on every call and carry no state, but they stayed allocated for the backend's lifetime: on the CEN 2y SDDP case (936 live cells under low_memory = off) they held ~0.8 GiB. LinearInterface calls this once a pass has finished reading a cell; every pointer previously returned by a getter is invalidated. Default: no-op (OSI and HiGHS return pointers into solver-owned memory and keep no scratch).

int gtopt::SolverBackend::restore_integers(std::span<const int> integer_cols) virtual

Returns Number of columns restored to integer.

Re-mark the given columns as integer, undoing a prior relax_all_integers(). The inverse operation: callers that relaxed every integer to solve an LP relaxation in place (MIP-start pipeline) use this to restore integrality before the real MIP solve.

integer_cols is the snapshot of column indices that were integer BEFORE relaxation (relaxation hides integrality, so the snapshot must be taken first). Default fallback re-calls set_integer per column. Plugins SHOULD override when the native API offers a one-call restore — CPLEX flips the problem type back to MILP/MIQP, which restores every column's saved ctype in a single call (the ~10⁵-column per-call loop is otherwise a real cost on PLEXOS-scale UC MIPs).

std::size_t gtopt::SolverBackend::scratch_bytes() const virtual noexcept

Bytes currently held by the getter scratch buffers (diagnostics and tests). Default 0 for backends without scratch.

bool gtopt::SolverBackend::set_basis(const Basis&) virtual

Install a simplex basis as an advanced start for the next solve.

PRECONDITION: basis is sized to the CURRENT problem (col_status.size() == get_num_cols(), row_status.size() == get_num_rows()). LinearInterface::set_basis reconciles a basis captured from a related LP (cuts appended rows) to these dimensions via reconcile_basis before calling here, so the backend only maps statuses to native and installs them; a size mismatch is rejected (returns false) rather than guessed.

Pairs with SolverOptions::advanced_basis (→ CPLEX ADVIND=1) and LPAlgo::dual so dual simplex resumes from the seed.

Default: unsupported (false) — a benign skip, like set_mip_start.

void gtopt::SolverBackend::set_col_bounds_bulk(int num, const int* indices, const char* lu, const double* values) virtual

Bulk column-bound mutation: parallel arrays of length num. lu[i] ∈ {'L','U','B'} per CPLEX convention (lower / upper / both). Default fallback is a per-element loop over set_col_lower / set_col_upper, matching set_obj_coeffs shape. Plugins SHOULD override when the native API is genuinely batched (CPXchgbds with cnt > 1, HighsLp::col_{lower,upper}, etc.) — those drop the per- call dispatch overhead and often skip per-element bookkeeping.

Hot in LinearInterface::apply_post_load_replay's pending_col_bounds loop and the SDDP forward-pass propagate_trial_values step.

void gtopt::SolverBackend::set_log_filename(const std::string&, int) virtual

Redirect solver log output to a file by name.

Backends override this to use their native file-based logging API (e.g. CPXsetlogfilename for CPLEX, log_file option for HiGHS). The default implementation is a no-op — backends that only support FILE*-based logging via open_log/close_log need not override.

The first argument is the full path to the log file (without .log extension); the second is the verbosity level (0 = off, >0 = enabled).

bool gtopt::SolverBackend::set_mip_start(std::span<const double>, MipStartEffort) virtual

Returns true if the backend accepted/installed the start, else false.

Inject a starting integer (MIP-start / warm incumbent) solution.

Unlike set_col_solution (an LP-basis/primal warm start that branch-and- cut discards), this installs a named MIP start the solver seeds B&C with — the mechanism that lets a good external commitment bypass a solver's costly node-0 heuristic incumbent.

col_values is a DENSE vector in RAW LP column space (length == get_num_cols()), the inverse of col_solution() — callers building it from a LinearInterface MUST use the raw (un-descaled) solution accessor. effort selects how hard the backend validates / completes / repairs the start (see MipStartEffort).

Backend support:

  • CPLEX — CPXaddmipstarts with the matching CPX_MIPSTART_* level.
  • Gurobi / MindOpt / HiGHS — their native dense Start / col_value attribute (effort is best-effort or ignored).
  • OSI/CBC, cuOpt — not wired; default below.

Default implementation is a benign no-op returning false (LP-only or unsupporting backends): a missing MIP start is a skipped optimisation, not an error (contrast add_sos2, which is load-time-fatal).

void gtopt::SolverBackend::set_obj_coeffs(const double* values, int num_cols) virtual

Bulk update of all objective coefficients. values MUST have size equal to the current number of columns; the implementation overwrites every coefficient. Default fallback is a per-column loop over set_obj_coeff(i, values[i]) so plugins that don't ship a native bulk API (or where the native bulk call has the same per-element cost) can opt out with one virtual. Plugins SHOULD override when the native API is genuinely batched (CPXchgobj, HighsLp::col_cost, CoinPackedVector) — those drop the per-call dispatch overhead and often skip per-element bookkeeping.

void gtopt::SolverBackend::set_obj_offset(double) virtual noexcept

Install a constant additive term on the objective — the solver's NATIVE objective offset. Reported objective value becomes Σ cⱼ xⱼ + raw_offset (all backends normalise sign internally so the term is added; CLP, which subtracts its stored offset, negates).

Semantics: ABSOLUTE set in the RAW (scaled) objective units the backend solves in — the caller pushes the running total, NOT a delta. LinearInterface::add_obj_constant accumulates the total in m_scaling_.obj_constant_raw and calls this with the new absolute value, so two successive add_obj_constant calls end with a single set_obj_offset carrying their sum.

Why native (not folded post-solve): CPLEX / Gurobi / HiGHS compute the MIP relative optimality gap against the reported objective. Folding a large boundary-cut / α-rebase constant only after the solve leaves the solver's objective near zero, inflating the relative gap into a phantom 100-170 % that stalls UC MIPs. Handing the constant to the native offset makes the solver's gap reflect the true objective.

Backends store the value so clone() preserves it and re-apply it at load/build (several backends reset the native problem on load_problem). Default is a no-op for ABI/future compatibility, but every shipped plugin overrides it: LinearInterface::get_obj_value_raw() reads the objective straight from the backend (it no longer re-adds m_scaling_.obj_constant_raw), so a backend that leaves this unimplemented would silently drop the constant.

void gtopt::SolverBackend::set_row_bounds_bulk(int num, const int* indices, const char* lu, const double* lo, const double* up) virtual

Bulk row-bound mutation: parallel arrays of length num. lu[i] ∈ {'L','U','B'} per CPLEX convention (lower / upper / both). Default fallback is a per-element loop over set_row_lower / set_row_upper / set_row_bounds. Plugins SHOULD override when the native API is genuinely batched (CPXchgrhs/CPXchgrngval for equality and ranged RHS, HighsLp::row_{lower,upper}, etc.).

Hot in LinearInterface::update_lp_for_phase row-RHS recomputation across many constraints in one phase.

bool gtopt::SolverBackend::supports_mip() const pure virtual noexcept

True if this backend can solve mixed-integer problems.

Returns true when the backend supports integer variables (set_integer) and a branch-and-bound / branch-and-cut solver capable of resolving them to optimality. Pure LP backends such as CLP return false; CBC, CPLEX, HiGHS, and MindOpt return true.

Tests that exercise integer variables should skip when this query returns false on every loaded plugin (see SolverRegistry::has_mip_solver).

bool gtopt::SolverBackend::write_lp(const char* filename, LpFileFormat format) pure virtual

Write the model to <filename>.lp or <filename>.mps.

Returns true when the file was written.

filename is the path stem (without extension); the backend appends the extension of format (lp_file_extension()). The row/column names pushed through push_names() and the integrality of the columns are kept.

Every backend handles both formats explicitly: when its native library cannot write format it returns false without touching the filesystem. false is also returned when the native writer reports an error. The caller (LinearInterface::write_lp) checks the file, and decides whether to report an error or fall back to the other format.