TempCtr

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., Expr) 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));

Subclassed by idol::CtrVersion

Public Functions

TempCtr() = default

Default constructor.

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

inline TempCtr(Row &&t_row, CtrType t_type)

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 const Row &row() const

Returns the row of the temporary constraint (see Row).

Returns:

The row of the temporary constraint.

inline Row &row()

Returns the row of the temporary constraint (see Row).

Returns:

The row of the temporary constraint.

inline CtrType type() const

Returns the temporary constraint type.

Returns:

The temporary constraint type.

inline void set_type(CtrType t_type)

Sets the type of the temporary constraint.

Parameters:

t_type – the desired type.

bool is_violated(const Solution::Primal &t_solution) const

Returns true if the temporary constraint is violated by the given solution, false otherwise.

Parameters:

t_solution – The solution to check.