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

Constructors#

VariableInstance#

VariableInstance(VariableInstanceBase impl)#

Methods#

astatus#

public String astatus()#

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

defeqn#

public int defeqn()#

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

dual#

public double dual()#

Get the dual value on defining constraint of variable substituted 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;

impl#

VariableInstanceBase impl()#

init#

public double init()#

Get the current initial guess

init0#

public double init0()#

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

lb#

public double lb()#

Returns the current lower bound. See Note on variables suffixes.

lb0#

public double lb0()#

Returns the initial lower bounds, from the var declaration

lb1#

public double lb1()#

Returns the weaker lower bound from AMPL’s presolve phase

lb2#

public double lb2()#

Returns the stronger lower bound from AMPL’s presolve phase

lrc#

public double lrc()#

Returns the reduced cost at lower bound

lslack#

public double lslack()#

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

rc#

public double rc()#

Get the reduced cost (at the nearer bound)

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 and uslack. See Note on variables suffixes.

sstatus#

public String sstatus()#

Solver status (basis status of variable)

status#

public String status()#

AMPL status if not in, otherwise solver status

ub#

public double ub()#

Returns the current upper bound. See Note on variables suffixes.

ub0#

public double ub0()#

Returns the initial upper bound, from the var declaration

ub1#

public double ub1()#

Returns the weaker upper bound from AMPL’s presolve phase

ub2#

public double ub2()#

Returns the stronger upper bound from AMPL’s presolve phase

unfix#

public void unfix()#

Unfix all instances of the current variable, equivalent to the AMPL code:

unfix varname;

urc#

public double urc()#

Returns the reduced cost at upper bound

uslack#

public double uslack()#

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

value#

public double value()#

Get the current value of this variable instance