Class ExtensionMethods
Some ExtensionsMethods that extend the Model and its fields.
Inheritance
Inherited Members
Namespace: OPTANO.Modeling.Optimization
Assembly: Optimization.dll
Syntax
public static class ExtensionMethods
Fields
UnhandledVariableGroupName
Name of variable group of all unhandled variables
Declaration
public const string UnhandledVariableGroupName = "unhandledVariable"
Field Value
Type | Description |
---|---|
System.String |
Methods
IsAlmost(Double, Double, Double[])
Checks if the System.Double value
is equal to one of the parameters compareValue
or optionalCompareValues
, with respect to a tolerance
of EPSILON.
Declaration
public static bool IsAlmost(this double value, double compareValue, params double[] optionalCompareValues)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value. |
System.Double | compareValue | The compare Value. |
System.Double[] | optionalCompareValues | The optional compare values. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsInRange(Double, Double, Double)
Checks if the System.Double value
is in the range
of [
, with respect to EPSILON.minValue
, maxValue
]
Declaration
public static bool IsInRange(this double value, double minValue, double maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value. |
System.Double | minValue | The minimum value of the |
System.Double | maxValue | The maximum value of the |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsLowerBoundConstraint(Constraint)
Checks if the constraint's LowerBound is not
System.Double.NegativeInfinity.
Declaration
public static bool IsLowerBoundConstraint(this Constraint constraint)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint | The constraint. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsRangeConstraint(Constraint)
Checks if the constraint
is a range constraint
.
I.e. LowerBound > System.Double.NegativeInfinity
and
UpperBound < System.Double.PositiveInfinity
Declaration
public static bool IsRangeConstraint(this Constraint constraint)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint | The constraint. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsRelevant(Constraint)
Checks if the given constraint is relevant for the model. Relevant means that the constraint's expression contains (at least) one variable with a non-zero factor, or that its bounds are contradictory.
I.e. 0 <= 1 <= 0 is still relevant to the model even though it does not contain a non-zero factor variable. However, the part "1 <= 0" still affects the model, since it causes the model to be infeasible.
This method is also used in AddConstraintIfRelevant(Constraint) and
Declaration
public static bool IsRelevant(this Constraint constraint)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint | The constraint to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsUpperBoundConstraint(Constraint)
Checks if the constraint's UpperBound is not
System.Double.PositiveInfinity.
Declaration
public static bool IsUpperBoundConstraint(this Constraint constraint)
Parameters
Type | Name | Description |
---|---|---|
Constraint | constraint | The constraint. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ParseToEnumMember<TEnumType>(String, Boolean)
Tries to parse the given memberName
into a member of the specified System.Enum TEnumType
.
If memberName
is not a member of TEnumType
, default(
will be returned.TEnumType
Declaration
public static TEnumType ParseToEnumMember<TEnumType>(this string memberName, bool ignoreCase = true)
where TEnumType : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
System.String | memberName | The member name. |
System.Boolean | ignoreCase | Specifies, if the case should be ignored. |
Returns
Type | Description |
---|---|
TEnumType | The member of the |
Type Parameters
Name | Description |
---|---|
TEnumType | The target System.Enum type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown, if |
WriteCSV(HashSet<VariableStatisticRow>, String)
Writes the Variable Statitics into CSV files
Declaration
public static void WriteCSV(this HashSet<VariableStatisticRow> result, string folder)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.HashSet<VariableStatisticRow> | result | The variable statistics to export |
System.String | folder | folder, to place the files. |