Row
-
class Row : public idol::impl::Row
Row modeling-old object.
This class is used to represent an optimization model’s row. It is made of a right hand-side and a set of
{ Var, Constant }
pairs representing the coefficient (Constant
) of the row in each column (Var
). Such pairs are called left hand-side terms.The whole left hand-side is stored as an
Expr<Var, Var>
while the whole right hand-side is stored as aConstant
.Example:
auto constraint = model.add_ctr(x + y <= 1.); const auto& row = model.get_ctr_row(constraint); // Row(x + y, 1.)
Public Functions
-
Row() = default
-
inline Row(Expr<Var, Var> &&t_lhs, Expr<Var, Var> &&t_rhs)
Constructor.
Creates a new row with a left hand-side
t_lhs
and a right hand-sidet_rhs
.- Parameters:
t_lhs – The left hand-side.
t_rhs – The right hand-side.
-
inline Row(Expr<Var, Var> &&t_lhs, const Expr<Var, Var> &t_rhs)
Constructor.
Creates a new row with a left hand-side
t_lhs
and a right hand-sidet_rhs
.- Parameters:
t_lhs – The left hand-side.
t_rhs – The right hand-side.
-
inline Row(const Expr<Var, Var> &t_lhs, Expr<Var, Var> &&t_rhs)
Constructor.
Creates a new row with a left hand-side
t_lhs
and a right hand-sidet_rhs
.- Parameters:
t_lhs – The left hand-side.
t_rhs – The right hand-side.
-
inline Row(const Expr<Var, Var> &t_lhs, const Expr<Var, Var> &t_rhs)
Constructor.
Creates a new row with a left hand-side
t_lhs
and a right hand-sidet_rhs
.- Parameters:
t_lhs – The left hand-side.
t_rhs – The right hand-side.
-
Row &operator=(const Row &t_src) = default
Copy-assignment operator.
- Parameters:
t_src – The row to copy.
- Returns:
*this
-
Row &operator=(Row &&t_src) noexcept = default
Move-assignment operator.
- Parameters:
t_src – The row to move.
- Returns:
*this
-
Row fix(const Solution::Primal &t_primals) const
Creates a new row in which all
Param
in eachConstant
are replaced by their corresponding values int_primals
- Parameters:
t_primals – the primal values for the parameters.
- Returns:
the new row.
-
Row fix(const Solution::Dual &t_duals) const
Creates a new row in which all
Param
in eachConstant
are replaced by their corresponding values int_duals
- Parameters:
t_primals – the dual values for the parameters.
- Returns:
the new row.
-
double value(const Solution::Primal &t_primals) const
Returns the value of the row if the value of each variable is taken in
t_primals
, i.e., the difference between the left and the right hand-side.If parameters are encountered, an exception is thrown.
- Parameters:
t_primals – The primal values.
- Returns:
The value of the row.
-
bool is_violated(const Solution::Primal &t_primals, CtrType t_type, double t_tolerance = Tolerance::Feasibility) const
Returns true if the point stored in
t_primals
violates the constraint formed by the row and a constraint typet_type
with tolerancet_tolerance
.- Parameters:
t_primals – The primal values.
t_type – The type of the constraint.
t_tolerance – The tolerance for feasibility.
- Returns:
True if the given point violates the row.
-
inline Constant &rhs()
Returns the right hand-side of the row.
- Returns:
The right hand-side of the row.
-
inline const Constant &rhs() const
Returns the right hand-side of the row.
- Returns:
The right hand-side of the row.
-
inline LinExpr<Var> &linear()
Returns the linear part of the left hand-side of the row.
- Returns:
The linear part of the left hand-side of the row.
-
inline const LinExpr<Var> &linear() const
Returns the linear part of the left hand-side of the row.
- Returns:
The linear part of the left hand-side of the row.
-
inline QuadExpr<Var, Var> &quadratic()
Returns the quadratic part of the left hand-side of the row.
- Returns:
The quadratic part of the left hand-side of the row.
-
inline const QuadExpr<Var, Var> &quadratic() const
Returns the quadratic part of the left hand-side of the row.
- Returns:
The quadratic part of the left hand-side of the row.
-
inline void set_linear(LinExpr<Var> &&t_lin_expr)
Sets the linear part of the left hand-side of the row.
- Parameters:
t_lin_expr – The new linear part of the right hand-side.
-
inline void set_linear(const LinExpr<Var> &t_lin_expr)
Sets the linear part of the left hand-side of the row.
- Parameters:
t_lin_expr – The new linear part of the right hand-side.
-
inline void set_quadratic(QuadExpr<Var, Var> &&t_quad_expr)
Sets the quadratic part of the left hand-side of the row.
- Parameters:
t_lin_expr – The new quadratic part of the right hand-side.
-
inline void set_quadratic(const QuadExpr<Var, Var> &t_quad_expr)
Sets the quadratic part of the left hand-side of the row.
- Parameters:
t_lin_expr – The new quadratic part of the right hand-side.
-
inline void set_rhs(Constant &&t_rhs)
Sets the right hand-side of the row.
- Parameters:
t_rhs – The new right hand-side of the row.
-
inline void set_rhs(const Constant &t_rhs)
Sets the right hand-side of the row.
- Parameters:
t_rhs – The new right hand-side of the row.
-
inline Row &operator+=(const Row &t_rhs)
Adds another row to the row (both the left and right hand-sides are added).
- Parameters:
t_rhs – The row to add.
- Returns:
*this
-
inline Row &operator-=(const Row &t_rhs)
Subtracts another row to the row (both the left and right hand-sides are subtracted).
- Parameters:
t_rhs – The row to subtarct.
- Returns:
*this
-
inline Row &operator*=(double t_rhs)
Multiplies all the entries of the row by a given factor (both the left and right hand-sides are multiplied).
- Parameters:
t_rhs – The factor used for multiplication.
- Returns:
*this
-
double scale_to_integers(unsigned int t_n_significant_digits)
-
void multiply_with_precision_by_power_of_10(unsigned int t_exponent, unsigned int t_n_significant_digits)
-
double gcd() const
-
Row() = default