Loading...
Searching...
No Matches
idol::Var Class Reference

Description

Definition at line 27 of file Var.h.

Public Methods

 Var (Env &t_env, double t_lb, double t_ub, VarType t_type, double t_obj=0., std::string t_name="")
 Var (Env &t_env, double t_lb, double t_ub, VarType t_type, double t_obj, LinExpr< Ctr, double > &&t_column, std::string t_name="")
 Var (Env &t_env, double t_lb, double t_ub, VarType t_type, double t_obj, const LinExpr< Ctr, double > &t_column, std::string t_name="")
 Var (const Var &)=default
 Var (Var &&)=default
Varoperator= (const Var &)=default
Varoperator= (Var &&)=default
unsigned int index (const Model &t_model) const
const std::string & name () const
unsigned int id () const
bool is_in (const Model &t_model) const
const ValueT & get (const Annotation< ValueT > &t_annotation) const
void set (const Annotation< ValueT > &t_annotation, ArgsT &&...t_args) const

Public Static Methods

template<unsigned int N = 1, unsigned int I = 0>
static Vector< Var, N - I > make_vector (Env &t_env, const Dim< N > &t_dim, double t_lb, double t_ub, VarType t_type, double t_obj, const std::string &t_name="")

Protected Methods

auto & versions ()
void create_version (const Model &t_model, unsigned int t_index, ArgsT &&...t_args) const
void remove_version (const Model &t_model) const

Friends

class impl::Env

Constructor & Destructor Documentation

◆ Var() [1/3]

idol::Var::Var ( Env & t_env,
double t_lb,
double t_ub,
VarType t_type,
double t_obj = 0.,
std::string t_name = "" )

Constructor.

Creates a new variable in the optimization environment.

If no name is given, a unique name in the environment is given.

Parameters
t_envThe optimization environment.
t_lbThe lower bound (possibly -Inf) for the default version of the variable.
t_ubThe upper bound (possibly +Inf) for the default version of the variable.
t_typeThe type for the default version of the variable.
t_nameThe given name of the variable.

◆ Var() [2/3]

idol::Var::Var ( Env & t_env,
double t_lb,
double t_ub,
VarType t_type,
double t_obj,
LinExpr< Ctr, double > && t_column,
std::string t_name = "" )

Constructor.

Creates a new variable in the optimization environment.

If no name is given, a unique name in the environment is given.

Parameters
t_envThe optimization environment.
t_lbThe lower bound (possibly -Inf) for the default version of the variable.
t_ubThe upper bound (possibly +Inf) for the default version of the variable.
t_typeThe type for the default version of the variable.
t_columnThe column for the default version of the variable.
t_nameThe given name of the variable.

◆ Var() [3/3]

idol::Var::Var ( Env & t_env,
double t_lb,
double t_ub,
VarType t_type,
double t_obj,
const LinExpr< Ctr, double > & t_column,
std::string t_name = "" )

Constructor.

Creates a new variable in the optimization environment.

If no name is given, a unique name in the environment is given.

Parameters
t_envThe optimization environment.
t_lbThe lower bound (possibly -Inf) for the default version of the variable.
t_ubThe upper bound (possibly +Inf) for the default version of the variable.
t_typeThe type for the default version of the variable.
t_columnThe column for the default version of the variable.
t_nameThe given name of the variable.

Methods Documentation

◆ create_version()

void idol::Object< VarVersion, Var >::create_version ( const Model & t_model,
unsigned int t_index,
ArgsT &&... t_args ) const
inlineprotectedinherited

Definition at line 34 of file Object.h.

◆ get()

const ValueT & idol::Object< VarVersion, Var >::get ( const Annotation< ValueT > & t_annotation) const
inlineinherited

Returns the value of the given annotation t_annotation associated to the object.

If no value is found, the default value of the annotation is returned. If no default value was set, an exception is thrown.

Template Parameters
ValueTThe value type of the annotation.
Parameters
t_annotationThe annotation.
Returns
The value of the annotation.

Definition at line 78 of file Object.h.

◆ id()

unsigned int idol::Object< VarVersion, Var >::id ( ) const
inlinenodiscardinherited

Returns the id of the optimization object.

Returns
The id of the optimization object.

Definition at line 60 of file Object.h.

◆ is_in()

bool idol::Object< VarVersion, Var >::is_in ( const Model & t_model) const
inlinenodiscardinherited

Returns true if the optimization object is part of the model t_model, false otherwise.

Parameters
t_modelThe model.
Returns
True if the optimization object is part of the model t_model, false otherwise.

Definition at line 67 of file Object.h.

◆ make_vector()

template<unsigned int N = 1, unsigned int I = 0>
Vector< Var, N - I > idol::Var::make_vector ( Env & t_env,
const Dim< N > & t_dim,
double t_lb,
double t_ub,
VarType t_type,
double t_obj,
const std::string & t_name = "" )
inlinestatic

Creates a (nested) vector of variables.

Example:

Env env;
auto x = Var::make_vector(env, Dim<2>(m, n), 0., 1., Continuous, "x");
std::cout << x[1][4].name() << std::endl; // "x_1_4"
static Vector< Var, N - I > make_vector(Env &t_env, const Dim< N > &t_dim, double t_lb, double t_ub, VarType t_type, double t_obj, const std::string &t_name="")
Definition Var.h:104
Template Parameters
NThe dimension of the (nested) vector.
IUsed for recursion.
Parameters
t_envThe environment to store the variables.
t_dimThe number of elements in each dimension.
t_lbThe lower bound.
t_ubThe upper bound.
t_typeThe type of the variables.
t_nameThe given name of the variables.
Returns
A (nested) vector of variables.

Definition at line 104 of file Var.h.

◆ name()

const std::string & idol::Object< VarVersion, Var >::name ( ) const
inlinenodiscardinherited

Returns the name of the optimization object.

Returns
The name of the optimization object.

Definition at line 54 of file Object.h.

◆ remove_version()

void idol::Object< VarVersion, Var >::remove_version ( const Model & t_model) const
inlineprotectedinherited

Definition at line 38 of file Object.h.

◆ set()

void idol::Object< VarVersion, Var >::set ( const Annotation< ValueT > & t_annotation,
ArgsT &&... t_args ) const
inlineinherited

Sets the value of the given annotation t_annotation associated to the object.

Template Parameters
ValueTThe value type of the annotation.
ArgsTThe parameter pack types for constructing the value of the annotation.
Parameters
t_annotationThe annotation.
t_argsThe parameter pack arguments used to construct "in place" the value of the annotation.

Definition at line 96 of file Object.h.

◆ versions()

auto & idol::Object< VarVersion, Var >::versions ( )
inlinenodiscardprotectedinherited

Definition at line 29 of file Object.h.

◆ impl::Env

friend class impl::Env
friend

Definition at line 28 of file Var.h.