Follow us on Twitter and LinkedIn to get the latest updates from the dev team!
This class represents an algebraic or logical constraint. In case the constraint is scalar, its values can be accessed via properties like ampl.Entities.Constraint.Body and ampl.Entities.Constraint.Dual. All the AMPL suffixes for constraints (see http://www.ampl.com/NEW/suffbuiltin.html) are available through methods of this class with the same name (and methods of ampl.ConstraintInstance for indexed constraints). Note that, since this class represents both algebraic and logical constraints, some suffixes might not be available for every entity. An ArgumentException is thrown if one of such methods is called for a non-scalar constraint and if a method corresponding to a suffix which is not supported by the type of the constraint is called. 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.ConstraintInstance can be accessed via the indexing operator, via the method ampl.Entities.Constraint.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.
ampl.Entities.Constraint.Body
ampl.Entities.Constraint.Dual
ampl.ConstraintInstance
ArgumentException
ArgumentOutOfRangeException
ampl.Entities.Constraint.Get
ampl.Entities.Entity.GetValues()
ampl.DataFrame
ampl.Entities
AMPL
Inheritance Hierarchy
Syntax
Properties
Methods
System.Object
ampl.Entities.Entity
ampl.Entities.Entity{ConstraintInstance}
ampl.Entities.Constraint
[ClassInterface(ClassInterfaceType.None)] public class Constraint : Entity<ConstraintInstance>, IEnumerable<ConstraintInstance>, IEnumerable, IConstraint
Get the current AMPL status (dropped, presolved, or substituted out)
System.String
public string Astatus { get; }
Get the current value of the constraint's body
System.Double
public double Body { get; }
Get the index in _var of "defined variable" substituted out by the constraint
_var
System.Int32
public int Defvar { get; }
Get the current initial guess for the constraint's public dual variable
public double Dinit { get; }
Get the original initial guess for the constraint's public dual variable
public double Dinit0 { get; }
Get and set the current value of the constraint's public dual variable. Setting this property is equivalent to the AMPL statement: let c := dual; Note that dual values are often reset by the underlying AMPL interpreter by the presolve functionalities triggered by some methods. A possible workaround is to set the option presolve; to false (see AMPL.SetOption).
let c := dual;
presolve;
false
public double Dual { get; set; }
Check if the constraint is a logical constraint. The available suffixes differ between logical and non logical constraints. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes for algebraic constraints. The suffixes available for logical constraints are marked on the method description by "Valid only for logical constraints".
System.Boolean
True if logical
public bool IsLogical { get; }
Get the current value of the constraint's lower bound
public double Lb { get; }
Get the constraint lower bound sent to the solver (reflecting adjustment for fixed variables)
public double Lbs { get; }
Get the current public dual value associated with the lower bound
public double Ldual { get; }
Get the slack at lower bound body - lb
body - lb
public double Lslack { get; }
Constraint slack (the lesser of lslack and uslack)
public double Slack { get; }
Get the solver status (basis status of constraint's %slack or artificial variable)
public string Sstatus { get; }
Get the AMPL status if not in, otherwise solver status
in
public string Status { get; }
Get the current value of the constraint's upper bound
public double Ub { get; }
Get the constraint upper bound sent to the solver (reflecting adjustment for fixed variables)
public double Ubs { get; }
Get the current public dual value associated with the upper bounds
public double Udual { get; }
Get the slack at upper bound ub - body
ub - body
public double Uslack { get; }
Get the AMPL val suffix. Valid only for logical constraints.
public double Val { get; }
Drop all instances in this constraint entity, corresponding to the AMPL code: drop constraintname;
drop constraintname;
public void Drop()
ConstraintInstance
public ConstraintInstance Get(params object[] index)
public override ConstraintInstance Get(Tuple t = null)
System.Collections.Generic.IEnumerator<ConstraintInstance>
public override IEnumerator<ConstraintInstance> GetEnumerator()
Restore all instances in this constraint entity, corresponding to the AMPL code: restore constraintname;
restore constraintname;
public void Restore()