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
- Assemblies
AMPL
Inheritance Hierarchy¶
System.Object
ampl.Entities.Entity{VariableInstance}
Syntax¶
[ClassInterface(ClassInterfaceType.None)]
public class Variable : Entity<VariableInstance>, IEnumerable<VariableInstance>, IEnumerable, IVariable
- class ampl.Entities.Variable
Properties¶
- ampl.Entities.Variable.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; }
- ampl.Entities.Variable.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; }
- ampl.Entities.Variable.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; }
- ampl.Entities.Variable.Init¶
Get the current initial guess (valid for scalar variables only)
- Return type
System.Double
public double Init { get; }
- ampl.Entities.Variable.Init0¶
Get the original initial guess (set by
:=
or by adefault
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
public VariableInstance this[Tuple t] { get; }
- ampl.Entities.Variable.Lb¶
Get the current lower bound (valid for scalar variables only)
- Return type
System.Double
public double Lb { get; }
- ampl.Entities.Variable.Lb0¶
Get the initial lower bound (valid for scalar variables only)
- Return type
System.Double
public double Lb0 { get; }
- ampl.Entities.Variable.Lb1¶
Get the weaker lower bound from AMPL's presolve phase (valid for scalar variables only)
- Return type
System.Double
public double Lb1 { get; }
- ampl.Entities.Variable.Lb2¶
Get the stronger lower bound from AMPL's presolve phase (valid for scalar variables only)
- Return type
System.Double
public double Lb2 { get; }
- ampl.Entities.Variable.Lrc¶
Get the reduced cost at lower bound (valid for scalar variables only)
- Return type
System.Double
public double Lrc { get; }
- ampl.Entities.Variable.Lslack¶
Get the slack at lower bound
val - lb
(valid for scalar variables only)- Return type
System.Double
public double Lslack { get; }
- ampl.Entities.Variable.Rc¶
Get the reduced cost at the nearer bound (valid for scalar variables only)
- Return type
System.Double
public double Rc { get; }
- ampl.Entities.Variable.Slack¶
Get the bound slack which is the lesser of
ampl.Entities.Variable.Lslack
orampl.Entities.Variable.Uslack
(valid for scalar variables only)- Return type
System.Double
public double Slack { get; }
- ampl.Entities.Variable.Sstatus¶
Solver status (basis status of variable). Valid for scalar variables only.
- Return type
System.String
public string Sstatus { get; }
- ampl.Entities.Variable.Status¶
AMPL status if not
in
, otherwise solver status (valid for scalar variables only)- Return type
System.String
public string Status { get; }
- ampl.Entities.Variable.Ub¶
Get the current upper bound (valid for scalar variables only)
- Return type
System.Double
public double Ub { get; }
- ampl.Entities.Variable.Ub0¶
Get the initial upper bound (valid for scalar variables only)
- Return type
System.Double
public double Ub0 { get; }
- ampl.Entities.Variable.Ub1¶
Get the weaker upper bound from AMPL's presolve phase (valid for scalar variables only)
- Return type
System.Double
public double Ub1 { get; }
- ampl.Entities.Variable.Ub2¶
Get the stronger upper bound from AMPL's presolve phase (valid for scalar variables only)
- Return type
System.Double
public double Ub2 { get; }
- ampl.Entities.Variable.Urc¶
Get the reduced cost at upper bound (valid for scalar variables only)
- Return type
System.Double
public double Urc { get; }
- ampl.Entities.Variable.Uslack¶
Get the slack at upper bound
ub - val
(valid for scalar variables only)- Return type
System.Double
public double Uslack { get; }
- ampl.Entities.Variable.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
public VariableInstance Get(params object[] index)
- Get(ampl.Tuple)
Get the instance with the specified index
- Return type
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<VariableInstance>
public override IEnumerator<VariableInstance> GetEnumerator()
- Unfix()¶
Unfix all instances of this variable
public void Unfix()