TempCtr

Doxygen

class TempCtr

Temporary constraint class.

This class represents a constraint which has not been built yet by a Model. It contains all the arguments needed to create a real constraint as instantiated by the Ctr class. It is made of a row (see Row) and a type (see CtrType.rst.rst).

Typically, one creates a TempCtr by using the overloaded operators <=, >= and == between variable expressions (i.e., AffExpr) and constant terms (i.e., Constant).

Example 1:

...
model.add_ctr(x + y <= 1.);
Example 2 (equivalent to Example 1):
...
model.add_ctr(TempCtr(Row(x + y, 1.), LessOrEqual));

Public Functions

TempCtr() = default

Default constructor.

Creates an empty temporary constraint. The default type is LessOrEqual.

inline TempCtr(LinExpr<Var> &&t_lhs, CtrType t_type, double t_rhs)

Constructor.

Creates a new temporary constraint.

Parameters:
  • t_row – The desired row.

  • t_type – The desired constraint type.

TempCtr(const TempCtr &t_src) = default

Copy constructor.

Parameters:

t_src – The object to copy.

TempCtr(TempCtr &&t_src) noexcept = default

Move constructor.

Parameters:

t_src – The object to move.

TempCtr &operator=(const TempCtr &t_src) = default

Copy-assignment operator.

Parameters:

t_src – The object to copy.

TempCtr &operator=(TempCtr &&t_src) noexcept = default

Move-assignment operator.

Parameters:

t_src – The object to move.

inline LinExpr<Var> &lhs()
inline const LinExpr<Var> &lhs() const
inline void set_lhs(LinExpr<Var> &&t_lhs)
inline CtrType type() const

Returns the temporary constraint type.

Returns:

The temporary constraint type.

inline double rhs() const
inline double &rhs()
inline void set_rhs(double t_rhs)
inline void set_type(CtrType t_type)

Sets the type of the temporary constraint.

Parameters:

t_type – the desired type.