.. java:import:: com.ampl Variable.Integrality VariableInstance ================ .. java:package:: com.ampl :noindex: .. java:type:: public class VariableInstance extends Instance A decision variable instance. Each member of this class belongs to a single \ :java:ref:`Variable`\ . Note that accessors available here are replicated at \ :java:ref:`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 a :java:ref:`IllegalStateException` if the instance has been deleted in the underlying AMPL interpreter. Constructors ------------ VariableInstance ^^^^^^^^^^^^^^^^ .. java:constructor:: VariableInstance(Variable map, Object key) :outertype: VariableInstance Constructs a new variable with the lower bound, upper bound and value equal to the specified value. Initial guess is set to zero. Note that this method doesn't add the variable to the entity. Methods ------- astatus ^^^^^^^ .. java:method:: public String astatus() :outertype: VariableInstance Get the AMPL status (fixed, presolved, or substituted out) copyFrom ^^^^^^^^ .. java:method:: void copyFrom(Instance from) :outertype: VariableInstance defeqn ^^^^^^ .. java:method:: public int defeqn() :outertype: VariableInstance Get the index in \ ``_con``\ of "defining constraint" used to substitute variable out dual ^^^^ .. java:method:: public double dual() :outertype: VariableInstance Get the dual value on defining constraint of variable substituted out fix ^^^ .. java:method:: public void fix() :outertype: VariableInstance Fix this variable instance to its current value fix ^^^ .. java:method:: public void fix(double value) :outertype: VariableInstance Fix this variable instance to the specified value init ^^^^ .. java:method:: public double init() :outertype: VariableInstance Get the current initial guess init0 ^^^^^ .. java:method:: public double init0() :outertype: VariableInstance Get the original initial guess (set by \ ``:=``\ or \ ``default``\ or by a data statement) lb ^^ .. java:method:: public double lb() :outertype: VariableInstance Returns the current lower bound. See :ref:`secVariableSuffixesNotes`. lb0 ^^^ .. java:method:: public double lb0() :outertype: VariableInstance Returns the initial lower bounds, from the var declaration lb1 ^^^ .. java:method:: public double lb1() :outertype: VariableInstance Returns the weaker lower bound from AMPL's presolve phase lb2 ^^^ .. java:method:: public double lb2() :outertype: VariableInstance Returns the stronger lower bound from AMPL's presolve phase lrc ^^^ .. java:method:: public double lrc() :outertype: VariableInstance Returns the reduced cost at lower bound lslack ^^^^^^ .. java:method:: public double lslack() :outertype: VariableInstance Return the slack at lower bound (\ ``val - lb``\ ). See :ref:`secVariableSuffixesNotes`. name ^^^^ .. java:method:: @Override public String name() :outertype: VariableInstance Returns the variable name with possible subscripts as printed by the \ ``display``\ statement. rc ^^ .. java:method:: public double rc() :outertype: VariableInstance Get the reduced cost (at the nearer bound) setValue ^^^^^^^^ .. java:method:: public void setValue(double value) :outertype: VariableInstance Set the current value of this variable instance (does not fix it), equivalent to the AMPL command \ ``let``\ :param value: Value to be set slack ^^^^^ .. java:method:: public double slack() :outertype: VariableInstance Returns the bound slack which is the lesser of :java:ref:`lslack` and :java:ref:`uslack`. See :ref:`secVariableSuffixesNotes`. sstatus ^^^^^^^ .. java:method:: public String sstatus() :outertype: VariableInstance Solver status (basis status of variable) status ^^^^^^ .. java:method:: public String status() :outertype: VariableInstance AMPL status if not \ ``in``\ , otherwise solver status toString ^^^^^^^^ .. java:method:: @Override public String toString() :outertype: VariableInstance Returns a string representation of this :java:ref:`VariableInstance` object. The format is as follows: .. parsed-literal:: 'var' name attrs ';' where ``name`` is the string returned by the :java:ref:`VariableInstance.name()` method and ``attrs`` 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'``. ub ^^ .. java:method:: public double ub() :outertype: VariableInstance Returns the current upper bound. See :ref:`secVariableSuffixesNotes`. ub0 ^^^ .. java:method:: public double ub0() :outertype: VariableInstance Returns the initial upper bound, from the var declaration ub1 ^^^ .. java:method:: public double ub1() :outertype: VariableInstance Returns the weaker upper bound from AMPL's presolve phase ub2 ^^^ .. java:method:: public double ub2() :outertype: VariableInstance Returns the stronger upper bound from AMPL's presolve phase unfix ^^^^^ .. java:method:: public void unfix() :outertype: VariableInstance Unfix this variable instance urc ^^^ .. java:method:: public double urc() :outertype: VariableInstance Returns the reduced cost at upper bound uslack ^^^^^^ .. java:method:: public double uslack() :outertype: VariableInstance Return the slack at upper bound (\ ``ub - val``\ ). See :ref:`secVariableSuffixesNotes`. value ^^^^^ .. java:method:: public double value() :outertype: VariableInstance Get the current value of this variable instance