Class Constraint
Represents a constraint in a mathematical model formulation.
Inheritance
Inherited Members
Namespace: OPTANO.Modeling.Optimization
Assembly: Optimization.dll
Syntax
[DataContract]
[Serializable]
public class Constraint : ICanAsAConstraintRegisterAModel, IHaveName
Constructors
Constraint(Expression, String, Double, Double, Nullable<LazyConstraintLevel>)
Initializes a new instance of the Constraint class.
Declaration
public Constraint(Expression expression, string name = null, double lowerBound = -Infinity, double upperBound = Infinity, LazyConstraintLevel? lazinessLevel = default(LazyConstraintLevel? ))
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.String | name | The unique name for this constraint. If the name is |
System.Double | lowerBound | The lower bound. |
System.Double | upperBound | The upper bound. |
System.Nullable<LazyConstraintLevel> | lazinessLevel | The laziness level of the constraint. Default: NotLazy. Currently only supported in GurobiSolver 8.x |
Properties
Expression
Expression of this constraint.
Declaration
[DataMember]
public Expression Expression { get; set; }
Property Value
Type | Description |
---|---|
Expression |
LazyConstraintLevel
Gets the laziness level of the constraint. Currently only supported in GurobiSolver 8.x
Declaration
[DataMember]
public LazyConstraintLevel? LazyConstraintLevel { get; }
Property Value
Type | Description |
---|---|
System.Nullable<LazyConstraintLevel> |
LowerBound
Lower bound (left hand side) of this constraint.
Declaration
[DataMember]
public double LowerBound { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Name
Gets or sets the unique name of this constraint.
Setter will always
call OPTANO.Modeling.Optimization.ModelScope.GetCleanName(System.String,OPTANO.Modeling.Optimization.Enums.NameType).
Name will be changed if System.String.IsNullOrWhiteSpace(System.String)(value
), or if NameHandlingStyle != Manual.
Declaration
[DataMember]
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
UpperBound
Upper bound (right hand side) of this constraint.
Declaration
[DataMember]
public double UpperBound { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
Equals(Expression, Expression)
Compares the specified expressions.
Declaration
public static Constraint Equals(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Constraint | A Constraint with lower and upper bound of zero:
|
Equals(Expression, Double)
Compares the expression to a constant.
Declaration
public static Constraint Equals(Expression expression1, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Constraint | A Constraint with lower and upper bound of zero |
GreaterThanOrEqual(Expression, Expression)
Compares two expressions whether the first expression is greater or equal the second expression.
Declaration
public static Constraint GreaterThanOrEqual(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Constraint | A Constraint with lower bound of zero |
GreaterThanOrEqual(Expression, Double)
Compares the expression to a constant whether its greater or equal.
Declaration
public static Constraint GreaterThanOrEqual(Expression expression1, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Constraint | A Constraint with lower bound of zero |
Implies(Constraint)
If this constraint is fulfilled, the conclusion
also needs to be fulfilled.
I.e. a 'common' logical implication
.
Equivalent to !this | conclusion.
Declaration
public Implication Implies(Constraint conclusion)
Parameters
Type | Name | Description |
---|---|---|
Constraint | conclusion | Right hand side of the Implication |
Returns
Type | Description |
---|---|
Implication | An implication. |
LessThanOrEqual(Expression, Expression)
Compares two expressions whether the first expression is lower or equal the second expression.
Declaration
public static Constraint LessThanOrEqual(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Constraint | A Constraint with upper bound of zero |
LessThanOrEqual(Expression, Double)
Compares the expression to a constant whether its less or equal.
Declaration
public static Constraint LessThanOrEqual(Expression expression1, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Constraint | A Constraint with upper bound of zero |
ToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Overrides
Where(Constraint)
This constraint should only hold if the provided premise also holds, in other words:
premise
implies
'this'.
Declaration
public Implication Where(Constraint premise)
Parameters
Type | Name | Description |
---|---|---|
Constraint | premise | The premise. |
Returns
Type | Description |
---|---|
Implication | The Where(Constraint). |
Operators
BitwiseOr(Constraint, Constraint)
Use this operator if you either want constraint1 or constraint2 or both to evaluate to true in a feasible solution.
Declaration
public static Or operator |(Constraint constraint1, Constraint constraint2)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint1 | The constraint1. |
Constraint | constraint2 | The constraint2. |
Returns
Type | Description |
---|---|
Or | The result of the operator. |
BitwiseOr(List<Constraint>, Constraint)
Use this operator if you either want the constraintGroup or constraint2 or both to evaluate to true in a feasible solution.
Declaration
public static Or operator |(List<Constraint> constraintGroup, Constraint constraint2)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<Constraint> | constraintGroup | The constraints. |
Constraint | constraint2 | The constraint2. |
Returns
Type | Description |
---|---|
Or | The result of the operator. |
LogicalNot(Constraint)
Negates a constraint. If you have l<x<u, then this will be transformed into x>u+epsilon and x<l-epsilon
Declaration
public static Not operator !(Constraint constraint)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint | The constraint. |
Returns
Type | Description |
---|---|
Not | A Not representing the negated constraint. |