9#ifndef DELPI_ENABLED_QSOPTEX
10#error QSopt_ex is not enabled. Please enable it by adding "--//tools:enable_qsoptex" to the bazel command.
17#include "delpi/libs/gmp.h"
18#include "delpi/libs/qsopt_ex.h"
19#include "delpi/solver/LpSolver.h"
20#include "delpi/symbolic/Expression.h"
21#include "delpi/symbolic/Variable.h"
22#include "delpi/util/concepts.h"
31 explicit QsoptexLpSolver(
Config config = {},
const std::string& class_name =
"QsoptexLpSolver");
32 ~QsoptexLpSolver()
override;
34 [[nodiscard]]
int num_columns()
const override;
35 [[nodiscard]]
int num_rows()
const override;
37 [[nodiscard]]
Column column(
int column_idx)
const override;
38 [[nodiscard]]
Row row(
int row_idx)
const override;
39 ColumnIndex
AddColumn(
const Variable&
var,
const mpq_class& obj,
const mpq_class& lb,
const mpq_class& ub)
override;
40 RowIndex AddRow(
const std::vector<Expression::Addend>& addends,
const mpq_class& lb,
const mpq_class& ub)
override;
41 RowIndex AddRow(
const Expression::Addends& lhs,
FormulaKind sense,
const mpq_class& rhs)
override;
60 template <TypedIterable<std::pair<const Variable, mpq_
class>> T>
61 int AddRow(
const T& addends,
char sense,
const mpq_class& rhs);
68 template <TypedIterable<std::pair<const Variable, mpq_
class>> T>
103 void UpdateInfeasible();
Simple dataclass used to store the configuration of the program.
const Variable & var(const int column) const
Shorthand notation to get the real variable linked with column column.
LpSolver(mpq_class ninfinity, mpq_class infinity, Config config={}, const std::string &class_name="LpSolver")
Construct a new LpSolver object with the given config.
void SetObjective(int column, const mpq_class &value) override
The the objective coefficient of the given column to the given value.
void SetRowCoeff(int row, const T &literal_monomials)
Parse a sequence of literal_monomials and set the coefficient for each decisional variable appearing ...
void UpdateFeasible()
Use the result from the lp solver to update the solution vector and objective value.
qsopt_ex::MpqArray ray_
Ray of the last infeasible solution.
void UpdateStats(unsigned int precision)
Update the lp stats from the QSopt_ex solver.
void SetVarCoeff(int row, const Variable &var, const mpq_class &value) const
Set the coefficients to apply to var on a specific row.
void EnsureSenseCore() override
Make sure the LP solvers are aware of the sense of the LP problem (minimisation or maximisation).
ColumnIndex AddColumn(const Variable &var, const mpq_class &obj, const mpq_class &lb, const mpq_class &ub) override
Add a new bounded column to the LP problem, ensuring that the variable var is in the range and has t...
void SetBound(Variable var, const mpq_class &lb, const mpq_class &ub) override
Set the bounds of a var in the LP problem to the given lb and ub.
void SetCoefficient(RowIndex row, ColumnIndex column, const mpq_class &value) override
Set the coefficient of the row constraint to apply at the column decisional variable.
QSbasis basis_
Last basis.
qsopt_ex::MpqArray x_
Solution vector.
mpq_QSprob qsx_
QSopt_ex LP solver.
Column column(int column_idx) const override
Get the column at the given column_idx index.
LpResult SolveCore() override
Internal method that optimises the LP problem with the given delta.
Row row(int row_idx) const override
Get the row at the given row_idx index.
A wrapper around an array of mpq_t elements.
Global namespace for the delpi library.
LpResult
Possible outcomes of the LP solver.
FormulaKind
Kinds of symbolic formulas.
Convenient structure representing a column in the LP solver.
Structure representing a row in the LP solver in the form of a linear combination of variables.