Constraint Class ================ This class represents an algebraic or logical constraint. In case the constraint is scalar, its values can be accessed via properties like :dn:prop:`ampl.Entities.Constraint.Body` and :dn:prop:`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 :dn:class:`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 :dn:class:`ampl.ConstraintInstance` can be accessed via the indexing operator, via the method :dn: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 :dn:method:`ampl.Entities.Entity.GetValues()` and the :dn:class:`ampl.DataFrame` class. Namespace :dn:ns:`ampl.Entities` Assemblies * AMPL ---- .. contents:: :local: Inheritance Hierarchy --------------------- * :dn:cls:`System.Object` * :dn:cls:`ampl.Entities.Entity` * :dn:cls:`ampl.Entities.Entity{ConstraintInstance}` * :dn:cls:`ampl.Entities.Constraint` Syntax ------ .. code-block:: csharp [ClassInterface(ClassInterfaceType.None)] public class Constraint : Entity, IEnumerable, IEnumerable, IConstraint .. dn:class:: ampl.Entities.Constraint :hidden: .. dn:class:: ampl.Entities.Constraint Properties ---------- .. dn:class:: ampl.Entities.Constraint :noindex: :hidden: .. dn:property:: ampl.Entities.Constraint.Astatus Get the current AMPL status (dropped, presolved, or substituted out) :rtype: System.String .. code-block:: csharp public string Astatus { get; } .. dn:property:: ampl.Entities.Constraint.Body Get the current value of the constraint's body :rtype: System.Double .. code-block:: csharp public double Body { get; } .. dn:property:: ampl.Entities.Constraint.Defvar Get the index in `_var` of "defined variable" substituted out by the constraint :rtype: System.Int32 .. code-block:: csharp public int Defvar { get; } .. dn:property:: ampl.Entities.Constraint.Dinit Get the current initial guess for the constraint's public dual variable :rtype: System.Double .. code-block:: csharp public double Dinit { get; } .. dn:property:: ampl.Entities.Constraint.Dinit0 Get the original initial guess for the constraint's public dual variable :rtype: System.Double .. code-block:: csharp public double Dinit0 { get; } .. dn:property:: ampl.Entities.Constraint.Dual 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). :rtype: System.Double .. code-block:: csharp public double Dual { get; set; } .. dn:property:: ampl.Entities.Constraint.IsLogical 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". :rtype: System.Boolean :return: True if logical .. code-block:: csharp public bool IsLogical { get; } .. dn:property:: ampl.Entities.Constraint.Lb Get the current value of the constraint's lower bound :rtype: System.Double .. code-block:: csharp public double Lb { get; } .. dn:property:: ampl.Entities.Constraint.Lbs Get the constraint lower bound sent to the solver (reflecting adjustment for fixed variables) :rtype: System.Double .. code-block:: csharp public double Lbs { get; } .. dn:property:: ampl.Entities.Constraint.Ldual Get the current public dual value associated with the lower bound :rtype: System.Double .. code-block:: csharp public double Ldual { get; } .. dn:property:: ampl.Entities.Constraint.Lslack Get the slack at lower bound `body - lb` :rtype: System.Double .. code-block:: csharp public double Lslack { get; } .. dn:property:: ampl.Entities.Constraint.Slack Constraint slack (the lesser of lslack and uslack) :rtype: System.Double .. code-block:: csharp public double Slack { get; } .. dn:property:: ampl.Entities.Constraint.Sstatus Get the solver status (basis status of constraint's %slack or artificial variable) :rtype: System.String .. code-block:: csharp public string Sstatus { get; } .. dn:property:: ampl.Entities.Constraint.Status Get the AMPL status if not `in`, otherwise solver status :rtype: System.String .. code-block:: csharp public string Status { get; } .. dn:property:: ampl.Entities.Constraint.Ub Get the current value of the constraint's upper bound :rtype: System.Double .. code-block:: csharp public double Ub { get; } .. dn:property:: ampl.Entities.Constraint.Ubs Get the constraint upper bound sent to the solver (reflecting adjustment for fixed variables) :rtype: System.Double .. code-block:: csharp public double Ubs { get; } .. dn:property:: ampl.Entities.Constraint.Udual Get the current public dual value associated with the upper bounds :rtype: System.Double .. code-block:: csharp public double Udual { get; } .. dn:property:: ampl.Entities.Constraint.Uslack Get the slack at upper bound `ub - body` :rtype: System.Double .. code-block:: csharp public double Uslack { get; } .. dn:property:: ampl.Entities.Constraint.Val Get the AMPL val suffix. Valid only for logical constraints. :rtype: System.Double .. code-block:: csharp public double Val { get; } Methods ------- .. dn:class:: ampl.Entities.Constraint :noindex: :hidden: .. dn:method:: ampl.Entities.Constraint.Drop() Drop all instances in this constraint entity, corresponding to the AMPL code: `drop constraintname;` .. code-block:: csharp public void Drop() .. dn:method:: ampl.Entities.Constraint.Get(System.Object[]) :type index: System.Object[] :rtype: ConstraintInstance .. code-block:: csharp public ConstraintInstance Get(params object[] index) .. dn:method:: ampl.Entities.Constraint.Get(ampl.Tuple) :type t: ampl.Tuple :rtype: ConstraintInstance .. code-block:: csharp public override ConstraintInstance Get(Tuple t = null) .. dn:method:: ampl.Entities.Constraint.GetEnumerator() :rtype: System.Collections.Generic.IEnumerator{ConstraintInstance} .. code-block:: csharp public override IEnumerator GetEnumerator() .. dn:method:: ampl.Entities.Constraint.Restore() Restore all instances in this constraint entity, corresponding to the AMPL code: `restore constraintname;` .. code-block:: csharp public void Restore()