idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
idol::Param Class Reference

#include <Param.h>

Collaboration diagram for idol::Param:
Collaboration graph

Public Member Functions

 Param (const Var &t_var)
 
 Param (const Ctr &t_ctr)
 
 Param (const Param &t_param)=default
 
 Param (Param &&t_param) noexcept=default
 
Paramoperator= (const Param &t_param)=default
 
Paramoperator= (Param &&t_param) noexcept=default
 
template<class T >
bool is () const
 
template<class T >
as () const
 
unsigned int id () const
 
const std::string & name () const
 

Detailed Description

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

Definition at line 35 of file Param.h.

Constructor & Destructor Documentation

◆ Param() [1/4]

idol::Param::Param ( const Var t_var)
inlineexplicit

Constructor.

Creates a new parameter associated to a variable.

Parameters
t_varThe variable.

Definition at line 44 of file Param.h.

◆ Param() [2/4]

idol::Param::Param ( const Ctr t_ctr)
inlineexplicit

Constructor.

Creates a new parameter associated to a constraint.

Parameters
t_varThe constraint.

Definition at line 52 of file Param.h.

◆ Param() [3/4]

idol::Param::Param ( const Param t_param)
default

Copy constructor.

Parameters
t_paramThe parameter to copy.

◆ Param() [4/4]

idol::Param::Param ( Param &&  t_param)
defaultnoexcept

Move constructor.

Parameters
t_paramThe parameter to move.

Member Function Documentation

◆ as()

template<class T >
T idol::Param::as ( ) const
inline

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"
T as() const
Definition Param.h:99
Template Parameters
TThe type of the underlying object.
Returns
The optimization object behind the parameter.

Definition at line 99 of file Param.h.

◆ id()

unsigned int idol::Param::id ( ) const
inline

Returns the id of the object behind the parameter.

Returns
The id of the object behind the parameter.

Definition at line 105 of file Param.h.

◆ is()

template<class T >
bool idol::Param::is ( ) const
inline

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

Template Parameters
TThe type to be tested.
Returns
True if the parameter represents on object of the class T, false otherwise.

Definition at line 85 of file Param.h.

◆ name()

const std::string & idol::Param::name ( ) const
inline

Returns the name of the object behind the parameter.

Returns
The name of the object behind the parameter.

Definition at line 111 of file Param.h.

◆ operator=() [1/2]

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

Copy-assignment operator.

Parameters
t_paramThe parameter to copy.
Returns
*this

◆ operator=() [2/2]

Param & idol::Param::operator= ( Param &&  t_param)
defaultnoexcept

Move-assignment operator.

Parameters
t_paramThe parameter to move.
Returns
*this