Param

class Param

Parameter modeling-old object.

This class is used to model parameters for optimization models. More precisely, it represents a variable, or a constraint, from a model A which is considered constant in another model B.

Parameters are created using the Param constructors or by prepending a variable, or a constraint, by the ! symbol.

Example:

auto parametrized_expression = 2 * !x * y; // Here, x is viewed as a constant

Public Functions

inline explicit Param(const Var &t_var)

Constructor.

Creates a new parameter associated to a variable.

Parameters:

t_var – The variable.

inline explicit Param(const Ctr &t_ctr)

Constructor.

Creates a new parameter associated to a constraint.

Parameters:

t_var – The constraint.

Param(const Param &t_param) = default

Copy constructor.

Parameters:

t_param – The parameter to copy.

Param(Param &&t_param) noexcept = default

Move constructor.

Parameters:

t_param – The parameter to move.

Param &operator=(const Param &t_param) = default

Copy-assignment operator.

Parameters:

t_param – The parameter to copy.

Returns:

*this

Param &operator=(Param &&t_param) noexcept = default

Move-assignment operator.

Parameters:

t_param – The parameter to move.

Returns:

*this

template<class T>
inline bool is() const

Returns true if the parameter represents on object of the class T, false otherwise.

Template Parameters:

T – The type to be tested.

Returns:

True if the parameter represents on object of the class T, false otherwise.

template<class T>
inline T as() const

Returns the optimization object behind the parameter.

Example:

Var x = model.add_var(0., 1., Continuous, "x");
Param param = !x;
Var var = param.as<Var>(); // "x"

Template Parameters:

T – The type of the underlying object.

Returns:

The optimization object behind the parameter.

inline unsigned int id() const

Returns the id of the object behind the parameter.

Returns:

The id of the object behind the parameter.

inline const std::string &name() const

Returns the name of the object behind the parameter.

Returns:

The name of the object behind the parameter.