VariableInstance¶
-
public class
VariableInstance
extends BasicInstance<VariableInstanceBase>¶ A decision variable instance. Each member of this class belongs to a single
Variable
. Note that accessors available here are replicated atVariable
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 a
IllegalArgumentException
if the instance has been deleted in the underlying AMPL interpreter.
Methods¶
defeqn¶
-
public int
defeqn
()¶ Get the index in
_con
of “defining constraint” used to substitute variable out
fix¶
-
public void
fix
()¶ Fix all instances of this variable to their current value, equivalent to:
fix varname;
fix¶
-
public void
fix
(double value)¶ (for scalar variables) fix the variable to the specified value, equivalent to:
fix varname := value;
init0¶
-
public double
init0
()¶ Get the original initial guess (set by
:=
ordefault
or by a data statement)
lb¶
-
public double
lb
()¶ Returns the current lower bound. See Note on variables suffixes.
lslack¶
-
public double
lslack
()¶ Return the slack at lower bound (
val - lb
). See Note on variables suffixes.
setValue¶
-
public void
setValue
(double value)¶ Set the current value of this variable instance
Parameters: - value – Value to be set
slack¶
-
public double
slack
()¶ Returns the bound slack which is the lesser of
lslack
anduslack
. See Note on variables suffixes.
ub¶
-
public double
ub
()¶ Returns the current upper bound. See Note on variables suffixes.
unfix¶
-
public void
unfix
()¶ Unfix all instances of the current variable, equivalent to the AMPL code:
unfix varname;
uslack¶
-
public double
uslack
()¶ Return the slack at upper bound (
ub - val
). See Note on variables suffixes.