VariableInstance

class VariableInstance

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 https://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes.

All the accessors in this class throw an error if the instance has been deleted in the underlying AMPL interpreter.

VariableInstance.name()

Returns the name of this instance.

Returns

Name of the instance.

VariableInstance.toString()

Returns a string representation of this instance.

Returns

String representation of this instance.

VariableInstance.value()

Get the current value of this variable.

Returns

Value of the variable.

VariableInstance.fix(value=NULL)

Fix all instances of this variable to their current value, or to the specified value if provided.

Parameters

value (float) – The value the variable must be set to.

Returns

NULL.

VariableInstance.unfix()

Unfix this variable instances.

Returns

NULL.

VariableInstance.setValue()

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

Parameters

value (float) – Value to be set.

Returns

NULL.

VariableInstance.astatus()

Get the variable status (fixed, presolved, or substituted out).

Returns

Variable status.

Return type

str

VariableInstance.defeqn()

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

Returns

Index of the defining constraint.

Return type

int

VariableInstance.dual()

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

Returns

Dual value.

Return type

float

VariableInstance.init()

Get the current initial guess.

Returns

The initial guess.

Return type

float

VariableInstance.init0()

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

Returns

The original initial guess.

Return type

float

VariableInstance.lb()

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

Returns

The current lower bound.

Return type

float

VariableInstance.ub()

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

Returns

The current upper bound.

Return type

float

VariableInstance.lb0()

Returns the initial lower bound, from the var declaration.

Returns

The intial lower bound.

Return type

float

VariableInstance.ub0()

Returns the initial upper bound, from the var declaration.

Returns

The intial upper bound.

Return type

float

VariableInstance.lb1()

Returns the weaker lower bound from AMPL’s presolve phase.

Returns

The weaker lower bound.

Return type

float

VariableInstance.ub1()

Returns the weaker upper bound from AMPL’s presolve phase.

Returns

The weaker upper bound.

Return type

float

VariableInstance.lb2()

Returns the stronger lower bound from AMPL’s presolve phase.

Returns

The stronger lower bound.

Return type

float

VariableInstance.ub2()

Returns the stronger upper bound from AMPL’s presolve phase.

Returns

The stronger upper bound.

Return type

float

VariableInstance.lrc()

Returns the reduced cost at lower bound.

Returns

The reduced cost at lower bound.

Return type

float

VariableInstance.urc()

Returns the reduced cost at upper bound.

Returns

The reduced cost at upper bound.

Return type

float

VariableInstance.lslack()

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

Returns

The slack at lower bound.

Return type

float

VariableInstance.uslack()

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

Returns

The slack at upper bound.

Return type

float

VariableInstance.rc()

Get the reduced cost (at the nearer bound).

Returns

The reduced cost.

Return type

float

VariableInstance.slack()

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

Returns

The smaller slack.

Return type

float

VariableInstance.sstatus()

Solver status (basis status of variable).

Returns

The basis status of the variable.

Return type

str

VariableInstance.status()

AMPL status if not in, otherwise solver status

Returns

The status of the variable.

Return type

str