VariableInstance¶
-
class
VariableInstance
: public ampl::BasicInstance<internal::VariableInstance>¶ A decision variable instance.
Each member of this class belongs to a single Variable. Note that accessors available here are replicated at Variable level for ease of use when dealing with scalar variables.
All AMPL suffixes for an algebraic variable are available through methods with the same name in this class. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes.
All the accessors in this class throw an std::runtime_error if the instance has been deleted in the underlying AMPL interpreter.
Public Functions
-
double
value
() const¶ Get the current value of this variable.
-
void
fix
()¶ Fix all instances of this variable to their current value.
-
void
fix
(double value)¶ Fix all instances of this variable to the specified value.
-
void
unfix
()¶ Unfix this variable instances.
-
void
setValue
(double value)¶ Set the current value of this variable (does not fix it), equivalent to the AMPL command
let
- Parameters
value
: Value to be set
-
std::string
astatus
() const¶ Get the AMPL status (fixed, presolved, or substituted out)
-
int
defeqn
() const¶ Get the index in
_con
of “defining constraint” used to substitute variable out.
-
double
dual
() const¶ Get the dual value on defining constraint of variable substituted out.
-
double
init
() const¶ Get the current initial guess.
-
double
init0
() const¶ Get the original initial guess (set by
:=
ordefault
or by a data statement)
-
double
lb
() const¶ Returns the current lower bound. See Note on variables suffixes.
-
double
ub
() const¶ Returns the current upper bound. See Note on variables suffixes.
-
double
lb0
() const¶ Returns the initial lower bounds, from the var declaration.
-
double
ub0
() const¶ Returns the initial upper bound, from the var declaration.
-
double
lb1
() const¶ Returns the weaker lower bound from AMPL’s presolve phase.
-
double
ub1
() const¶ Returns the weaker upper bound from AMPL’s presolve phase.
-
double
lb2
() const¶ Returns the stronger lower bound from AMPL’s presolve phase.
-
double
ub2
() const¶ Returns the stronger upper bound from AMPL’s presolve phase.
-
double
lrc
() const¶ Returns the reduced cost at lower bound.
-
double
urc
() const¶ Returns the reduced cost at upper bound.
-
double
lslack
() const¶ Return the slack at lower bound (
val - lb
). See Note on variables suffixes.
-
double
uslack
() const¶ Return the slack at upper bound (
ub - val
). See Note on variables suffixes.
-
double
rc
() const¶ Get the reduced cost (at the nearer bound)
-
double
slack
() const¶ Returns the bound slack which is the lesser of lslack() and uslack(). See Note on variables suffixes.
-
std::string
sstatus
() const¶ Solver status (basis status of variable)
-
std::string
status
() const¶ AMPL status if not
in
, otherwise solver status
-
std::string
toString
() const¶ Returns a string representation of this VariableInstance object.
The format is as follows:
'var' name attrs ';'
where
name
is the string returned by the VariableInstance::name() method andattrs
represent attributes similar to those used in variable declarations.If the lower bound (
lb
) is equal to the upper bound (ub
), the attributes contain'=' lb
.If the lower bound is not equal to the upper bound and
Double.NEGATIVE_INFINITY
, the attributes contain'>=' lb
.If the upper bound is not equal to the lower bound and
Double.POSITIVE_INFINITY
, the attributes contain'<=' ub
.If the variable is integer, the attributes contain
'integer'
.If the variable is binary, the attributes contain
'binary'
.
-
double