LinearProblem class
#include <gtopt/linear_problem.hpp>
Main class for building and manipulating linear planning problems.
This class provides functionality to construct a linear problem by adding variables (columns) and constraints (rows), setting coefficients, and converting to solver-ready formats.
Public types
- using cols_t = std::vector<SparseCol>
-
using index_t = FlatLinearProblem::
index_t - using rows_t = std::vector<SparseRow>
- using SparseMatrix = std::vector<SparseVector>
-
using SparseVector = flat_
map<ColIndex, double>
Public static variables
Public functions
- auto add_col(SparseCol&& col) -> constexpr ColIndex
- auto add_row(SparseRow&& row) -> constexpr RowIndex
- auto col_at(this Self&& self, ColIndex index) -> constexpr auto&&
- auto flatten(const LpMatrixOptions& opts = {}) -> FlatLinearProblem
- auto get_coeff(RowIndex row, ColIndex col) const -> constexpr double
- auto get_col_lowb(ColIndex index) const -> constexpr auto
- auto get_col_scale(ColIndex index) const -> constexpr auto
- auto get_col_uppb(ColIndex index) const -> constexpr auto
-
auto get_numcols() const -> constexpr index_
t -
auto get_numrows() const -> constexpr index_
t - auto infinity() const -> constexpr double noexcept
- Current infinity value (DblMax if not explicitly set).
- auto LinearProblem(std::string name = {}) -> constexpr explicit noexcept
-
auto reserve(size_
t est_cols, size_ t est_rows) -> constexpr void - auto row_at(this Self&& self, RowIndex index) -> constexpr auto&&
- auto set_coeff(RowIndex row, ColIndex col, double coeff) -> constexpr void
- auto set_infinity(double inf) -> constexpr void noexcept
Function documentation
FlatLinearProblem gtopt:: LinearProblem:: flatten(const LpMatrixOptions& opts = {})
| Parameters | |
|---|---|
| opts | LP build options |
| Returns | Flat representation of the problem |
Builds the flat (column-major) LP representation
constexpr auto gtopt:: LinearProblem:: get_col_lowb(ColIndex index) const
| Parameters | |
|---|---|
| index | Column index |
| Returns | Lower bound value |
Gets the lower bound of a column
constexpr auto gtopt:: LinearProblem:: get_col_scale(ColIndex index) const
| Parameters | |
|---|---|
| index | Column index |
| Returns | Scale factor (1.0 = no scaling) |
Gets the physical-to-LP scale factor of a column. physical_value = LP_value × scale.
constexpr auto gtopt:: LinearProblem:: get_col_uppb(ColIndex index) const
| Parameters | |
|---|---|
| index | Column index |
| Returns | Upper bound value |
Gets the upper bound of a column
constexpr index_ t gtopt:: LinearProblem:: get_numcols() const
| Returns | Number of columns (variables) in the problem |
|---|
constexpr index_ t gtopt:: LinearProblem:: get_numrows() const
| Returns | Number of rows (constraints) in the problem |
|---|
constexpr gtopt:: LinearProblem:: LinearProblem(std::string name = {}) explicit noexcept
| Parameters | |
|---|---|
| name | Problem name |
Constructs a new linear problem
constexpr void gtopt:: LinearProblem:: reserve(size_ t est_cols,
size_ t est_rows)
| Parameters | |
|---|---|
| est_cols | Estimated number of columns (variables) |
| est_rows | Estimated number of rows (constraints) |
Pre-reserves capacity for columns, rows, and coefficients. Call before the build loop to avoid repeated reallocations.
constexpr void gtopt:: LinearProblem:: set_infinity(double inf) noexcept
| Parameters | |
|---|---|
| inf | Target infinity value (e.g. LinearInterface::infinity()) |
Sets the infinity value used for bound normalization.
When set to a value smaller than DblMax (e.g. from the solver backend's infinity()), add_col()/add_row() will clamp DblMax bounds to ±infinity. This ensures that flattened LP vectors never contain raw DblMax values, avoiding noisy solver warnings (e.g. HiGHS "bounds >= 1e20 treated as +Infinity").