Variable¶

class
amplpy.
Variable
(_impl)¶ Bases:
Entity
.Represents an AMPL decision variable. Note that, in case of a scalar variable, all the properties of the variable instance can be accessed through methods like
value()
. The methods have the same name of the corresponding AMPL suffixes. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes.All these methods throw a TypeError if called for a non scalar objective and an RuntimeError if called on an entity which has been deleted in the underlying intepreter.
To gain access to all the values in an entity (for all instances and all suffixes for that entities), see
getValues()
and theDataFrame
class.
__init__
(_impl)¶ x.__init__(…) initializes x; see help(type(x)) for signature

value
()¶ Get the current value of this variable.

fix
(value=None)¶ Fix all instances of this variable to a value if provided or to their current value otherwise.
 Args:
 value: value to be set.

unfix
()¶ Unfix all instances of this variable.

setValue
(value)¶ Set the current value of this variable (does not fix it), equivalent to the AMPL command let.
 Args:
 value: value to be set.

astatus
()¶ Get the AMPL status (fixed, presolved, or substituted out).

defeqn
()¶ Get the index in _con of “defining constraint” used to substitute variable out.

dual
()¶ Get the dual value on defining constraint of variable substituted out.

init
()¶ Get the current initial guess.

init0
()¶ Get the original initial guess (set by := or`default` or by a data statement).

lb
()¶ Returns the current lower bound. See Note on variables suffixes.

ub
()¶ Returns the current upper bound. See Note on variables suffixes.

lb0
()¶ Returns the initial lower bounds, from the var declaration.

ub0
()¶ Returns the initial upper bound, from the var declaration.

lb1
()¶ Returns the weaker lower bound from AMPL’s presolve phase.

ub1
()¶ Returns the weaker upper bound from AMPL’s presolve phase.

lb2
()¶ Returns the stronger lower bound from AMPL’s presolve phase.

ub2
()¶ Returns the stronger upper bound from AMPL’s presolve phase.

lrc
()¶ Returns the reduced cost at lower bound.

urc
()¶ Returns the reduced cost at upper bound.

lslack
()¶ Return the slack at lower bound (
val  lb
). See Note on variables suffixes.

uslack
()¶ Return the slack at upper bound (
ub  val
). See Note on variables suffixes.

rc
()¶ Get the reduced cost (at the nearer bound).

slack
()¶ Returns the bound slack which is the lesser of
lslack()
anduslack()
. See Note on variables suffixes.

sstatus
()¶ Solver status (basis status of variable).

status
()¶ AMPL status if not in, otherwise solver status.

__module__
= 'amplpy.variable'¶
