Variables

class Variable

Decision variables that appear in expressions.

Variables are used to define decision variables that are optimized.

Stream operator

Stream the variable to an output stream.

param ostr:

output stream

param arg:

variable

Public Functions

Variable()

Construct a continuous decision variable.

Variable &value(double value)

Set the initial variable value.

Returns:

the variable object.

Variable &value(const Expression &value)

Set the initial variable value.

Returns:

the variable object.

double value() const
Returns:

the initial value of the variable

Expression value_expression() const
Returns:

the expression defining the initial variable value

Variable &lower(double value)

Set the lower bound.

Returns:

the variable object.

Variable &lower(const Expression &value)

Set the lower bound.

Returns:

the variable object.

double lower() const
Returns:

the lower bound

Expression lower_expression() const
Returns:

the expression defining the variable lower bound

Variable &upper(double value)

Set the upper bound.

Returns:

the variable object.

Variable &upper(const Expression &value)

Set the upper bound.

Returns:

the variable object.

double upper() const
Returns:

the upper bound

Expression upper_expression() const
Returns:

the expression defining the variable upper bound

Variable &bounds(double lb, double ub)

Set the upper and lower bounds.

Returns:

the variable object.

Variable &bounds(const Expression &lb, double ub)

Set the upper and lower bounds.

Returns:

the variable object.

Variable &bounds(double lb, const Expression &ub)

Set the upper and lower bounds.

Returns:

the variable object.

Variable &bounds(const Expression &lb, const Expression &ub)

Set the upper and lower bounds.

Returns:

the variable object.

Variable &fixed(bool flag)

Set a flag indicating if the variable is fixed.

Returns:

the variable object.

Variable &fix(double value)

Set the variable value and declare the variable fixed.

Returns:

the variable object.

bool fixed() const
Returns:

true if the variable is fixed

Variable &name(const std::string &name)

Set the name of the variable.

Returns:

the variable object

std::string name() const
Returns:

the value of the variable.

Variable &within(VariableTypes vtype)

Set the variable type.

Returns:

the variable object

VariableTypes within() const
Returns:

the variable type.

bool is_continuous() const
Returns:

true if the variable is continuous

bool is_binary() const
Returns:

true if the variable is binary

bool is_integer() const
Returns:

true if the variable is integer

size_t id() const
Returns:

the unique integer variable ID

inline bool is_constant() const
Returns:

false because this is not a constant expression