SolverBackend class
#include <gtopt/solver_backend.hpp>
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
- auto add_col(double lb, double ub, double obj) -> void pure virtual
- auto add_row(int num_elements, const int* columns, const double* elements, double rowlb, double rowub) -> void pure virtual
- auto apply_options(const SolverOptions& opts) -> void pure virtual
- auto clear_log_filename() -> void virtual
- Stop file-based logging started by set_log_filename.
- auto clone() const -> std::unique_ptr<SolverBackend> pure virtual
- auto close_log() -> void 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
- auto delete_rows(int num, const int* indices) -> void pure virtual
- auto get_algorithm() const -> LPAlgo pure virtual
- Query the currently configured LP algorithm.
- auto get_coeff(int row, int col) const -> double pure virtual
- auto get_kappa() const -> double pure virtual
- Condition number of the current basis (1.0 if unavailable)
- 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 infinity() const -> double pure virtual noexcept
- Solver's representation of +infinity.
- auto initial_solve() -> void 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 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) -> void pure virtual
- auto obj_coefficients() const -> const double* pure virtual
- auto obj_value() const -> double pure virtual
- auto open_log(FILE* file, int level) -> void 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).
- auto push_names(const std::vector<std::string>& col_names, const std::vector<std::string>& row_names) -> void pure virtual
- auto reduced_cost() const -> const double* pure virtual
- auto resolve() -> void pure 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 set_coeff(int row, int col, double value) -> void pure virtual
- auto set_col_lower(int index, double value) -> void pure virtual
- auto set_col_solution(const double* sol) -> void pure virtual
- auto set_col_upper(int index, double value) -> void pure virtual
- auto set_continuous(int index) -> void pure virtual
- auto set_integer(int index) -> void pure virtual
- auto set_log_filename(const std::string&, int) -> void virtual
- Redirect solver log output to a file by name.
- auto set_obj_coeff(int index, double value) -> void pure virtual
- auto set_prob_name(const std::string& name) -> void pure virtual
- auto set_row_bounds(int index, double lb, double ub) -> void pure virtual
- auto set_row_lower(int index, double value) -> void pure virtual
- auto set_row_price(const double* price) -> void pure virtual
- auto set_row_upper(int index, double value) -> void 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_set_coeff() const -> bool pure virtual noexcept
- auto write_lp(const char* filename) -> void pure virtual
Function documentation
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.
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.
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).