Variable Class

Represents an AMPL variable. Note that, in case of a scalar variable, all the properties (corresponding to AMPL suffixes) of the variable instance can be accessed through corresponding properties on the Variable itself. The properties have the same name of the corresponding AMPL suffixes. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes. An ArgumentException is thrown if one of such methods is called for a non-scalar variable. An ArgumentOutOfRangeException is thrown if any property of an entity which has been deleted from the underlying interpreter is accessed. The instances, represented by the class ampl.VariableInstance can be accessed via the indexing operator, via the method ampl.Entities.Variable.Get or via the iterator provided. To gain access to all the values in an entity (for all instances and all suffixes for that entities), see ampl.Entities.Entity.GetValues and the ampl.DataFrame class.

Namespace
ampl.Entities
Assemblies
  • AMPL

Inheritance Hierarchy

Syntax

public class Variable : Entity<VariableInstance>, IEnumerable<VariableInstance>, IEnumerable
class ampl.Entities.Variable

Properties

Astatus()

Get the AMPL status of this variable (fixed, presolved or substituted) (valid for scalar variables only)

Return type:System.String
public string Astatus { get; }
Defeqn()

Get the index in _con of “definining constraint” used to substitute this variable out (valid for scalar variables only)

Return type:System.Int32
public int Defeqn { get; }
Dual()

Get the dual value on the defining constraint of this variable (valid for scalar variables only)

Return type:System.Double
public double Dual { get; }
Init()

Get the current initial guess (valid for scalar variables only)

Return type:System.Double
public double Init { get; }
Init0()

Get the original initial guess (set by := or by a default instruction or a data statement (valid for scalar variables only)

Return type:System.Double
public double Init0 { get; }
ampl.Entities.Variable.Item[ampl.Tuple]

Get the instance with the specified index

Return type:ampl.VariableInstance
public VariableInstance this[Tuple t] { get; }
Lb()

Get the current lower bound (valid for scalar variables only)

Return type:System.Double
public double Lb { get; }
Lb0()

Get the initial lower bound (valid for scalar variables only)

Return type:System.Double
public double Lb0 { get; }
Lb1()

Get the weaker lower bound from AMPL’s presolve phase (valid for scalar variables only)

Return type:System.Double
public double Lb1 { get; }
Lb2()

Get the stronger lower bound from AMPL’s presolve phase (valid for scalar variables only)

Return type:System.Double
public double Lb2 { get; }
Lrc()

Get the reduced cost at lower bound (valid for scalar variables only)

Return type:System.Double
public double Lrc { get; }
Lslack()

Get the slack at lower bound val - lb (valid for scalar variables only)

Return type:System.Double
public double Lslack { get; }
Rc()

Get the reduced cost at the nearer bound (valid for scalar variables only)

Return type:System.Double
public double Rc { get; }
Slack()

Get the bound slack which is the lesser of ampl.Entities.Variable.Lslack or ampl.Entities.Variable.Uslack (valid for scalar variables only)

Return type:System.Double
public double Slack { get; }
Sstatus()

Solver status (basis status of variable). Valid for scalar variables only.

Return type:System.String
public string Sstatus { get; }
Status()

AMPL status if not in, otherwise solver status (valid for scalar variables only)

Return type:System.String
public string Status { get; }
Ub()

Get the current upper bound (valid for scalar variables only)

Return type:System.Double
public double Ub { get; }
Ub0()

Get the initial upper bound (valid for scalar variables only)

Return type:System.Double
public double Ub0 { get; }
Ub1()

Get the weaker upper bound from AMPL’s presolve phase (valid for scalar variables only)

Return type:System.Double
public double Ub1 { get; }
Ub2()

Get the stronger upper bound from AMPL’s presolve phase (valid for scalar variables only)

Return type:System.Double
public double Ub2 { get; }
Urc()

Get the reduced cost at upper bound (valid for scalar variables only)

Return type:System.Double
public double Urc { get; }
Uslack()

Get the slack at upper bound ub - val (valid for scalar variables only)

Return type:System.Double
public double Uslack { get; }
Value()

Get or set the current value of this variable (valid for scalar variables only)

Return type:System.Double
public double Value { get; set; }

Methods

Fix()

Fix all instances of this variable to their current value

public void Fix()
Fix(System.Double)

Fix this variable to the specified value (valid for scalar variables only)

Arguments:
  • value (System.Double) – Value to fix the variable to
public void Fix(double value)
Get(System.Object[])

Get the instance with the specified index

Return type:ampl.VariableInstance
public VariableInstance Get(params object[] index)
Get(ampl.Tuple)

Get the instance with the specified index

Return type:ampl.VariableInstance
public override VariableInstance Get(Tuple t = null)
GetEnumerator()

Get an enumerator to iterate through the instances in this entity

Return type:System.Collections.Generic.IEnumerator<System.Collections.Generic.IEnumerator`1>{ampl.VariableInstance<ampl.VariableInstance>}
public override IEnumerator<VariableInstance> GetEnumerator()
Unfix()

Unfix all instances of this variable

public void Unfix()