VariableInstance

public class VariableInstance extends Instance<Variable>

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 a IllegalStateException if the instance has been deleted in the underlying AMPL interpreter.

Methods

public String astatus()

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

public int defeqn()

Get the index in _con of “defining constraint” used to substitute variable out

public double dual()

Get the dual value on defining constraint of variable substituted out

public void fix()

Fix this variable instance to its current value

public void fix(double value)

Fix this variable instance to the specified value

public double init()

Get the current initial guess

public double init0()

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

public double lb()

Returns the current lower bound

public double lb0()

Returns the initial lower bounds, from the var declaration

public double lb1()

Returns the weaker lower bound from AMPL’s presolve phase

public double lb2()

Returns the stronger lower bound from AMPL’s presolve phase

public double lrc()

Returns the reduced cost at lower bound

public double lslack()

Return the slack at lower bound (val - lb)

public String name()

Returns the variable name with possible subscripts as printed by the display statement.

public double rc()

Get the reduced cost (at the nearer bound)

public void setValue(double value)

Set the current value of this variable instance (does not fix it), equivalent to the AMPL command let

Parameters:
  • value – Value to be set
public double slack()

Returns the bound slack which is the lesser of lslack and uslack.

public String sstatus()

Solver status (basis status of variable)

public String status()

AMPL status if not in, otherwise solver status

public String toString()

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 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'.

public double ub()

Returns the current upper bound.

public double ub0()

Returns the initial upper bound, from the var declaration

public double ub1()

Returns the weaker upper bound from AMPL’s presolve phase

public double ub2()

Returns the stronger upper bound from AMPL’s presolve phase

public void unfix()

Unfix this variable instance

public double urc()

Returns the reduced cost at upper bound

public double uslack()

Return the slack at upper bound (ub - val)

public double value()

Get the current value of this variable instance