Class Solution
Represents a solution of a Model.
Inheritance
Inherited Members
Namespace: OPTANO.Modeling.Optimization
Assembly: Optimization.dll
Syntax
[DataContract]
public class Solution : IComparable<Solution>, IEquatable<Solution>, IEquatable<IDictionary<string, double>>
Constructors
Solution(Model, TimeSpan, ModelStatus, SolutionStatus, IDictionary<String, Double>, IDictionary<String, Double>, IDictionary<String, Double>, ConflictingSet, Int64)
Initializes a new instance of the Solution class.
Declaration
public Solution(Model model, TimeSpan overallWallTime, ModelStatus modelStatus, SolutionStatus status = SolutionStatus.NoSolutionValues, IDictionary<string, double> variableValues = null, IDictionary<string, double> dualVariableValues = null, IDictionary<string, double> objectiveValues = null, ConflictingSet conflictingSet = null, long numberOfExploredNodes = 0L)
Parameters
Type | Name | Description |
---|---|---|
Model | model | The model. |
System.TimeSpan | overallWallTime | Overall wall clock time taken for solving. |
ModelStatus | modelStatus | Status of the solved model instance. |
SolutionStatus | status | Status of the new solution instance. |
System.Collections.Generic.IDictionary<System.String, System.Double> | variableValues | Name and solution value for each variable in the solved model instance, or |
System.Collections.Generic.IDictionary<System.String, System.Double> | dualVariableValues | Name and solution value for each dual variable in the solved model instance, or |
System.Collections.Generic.IDictionary<System.String, System.Double> | objectiveValues | Name and solution value for each objective in the solved model instance, or |
ConflictingSet | conflictingSet | The irreducible infeasible set (IIS). |
System.Int64 | numberOfExploredNodes | The number of explored nodes. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Model mustn't be |
Properties
BestBound
Gets or sets the best bound for the last (or default) element from OrderedPriorityLevels.
Declaration
public double BestBound { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
ConflictingSet
Gets the conflicting set. To enable the computation of the IIS, make sure to enable it in the respective SolverConfiguration. Note that not all solvers support this computation.
Declaration
public ConflictingSet ConflictingSet { get; }
Property Value
Type | Description |
---|---|
ConflictingSet |
DualVariableValues
Gets the dual variable values.
Unique name and solution value for each dual variable in the solved model instance, or null
if the status of this solution instance is NoSolutionValues
.
Not supported by all Solvers.
Declaration
public IDictionary<string, double> DualVariableValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Double> |
Gap
Gets the solution gap for the last (or default) element from OrderedPriorityLevels. For single stage optimization, this is the same as the classical mip gap.
Declaration
public double Gap { get; }
Property Value
Type | Description |
---|---|
System.Double |
IsInterruptedByUser
Gets a value indicating whether the user interrupted a multi hierarchical solve. See also SolverBase.InterruptMultiHierarchicalOptimization and SetMultiHierarchicalInterruptionCallback(SolverBase.InterruptMultiHierarchicalOptimization).
Declaration
public bool IsInterruptedByUser { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MergedObjectiveNamesByPrioLevel
Gets a dictionary that contains the name for the (merged) objectives that were optimized in the priority level that is used as Key in the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public IDictionary<int, string> MergedObjectiveNamesByPrioLevel { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Int32, System.String> |
ModelName
Gets the name of the model.
Declaration
public string ModelName { get; }
Property Value
Type | Description |
---|---|
System.String |
ModelStatus
Gets the model status.
Declaration
public ModelStatus ModelStatus { get; }
Property Value
Type | Description |
---|---|
ModelStatus |
NumberOfExploredNodes
Gets or sets the number of explored nodes.
Declaration
public long NumberOfExploredNodes { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
ObjectiveValues
Unique name and solution value for each objective in the solved model instance, or null
if the status of this solution instance is NoSolutionValues
.
Declaration
public IDictionary<string, double> ObjectiveValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Double> |
OrderedPriorityLevels
Gets the ordered set of priority levels.
Declaration
public IEnumerable<int> OrderedPriorityLevels { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
OverallWallTime
Gets the overall wall time.
Declaration
public TimeSpan OverallWallTime { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
Status
Status of this solution instance.
Declaration
public SolutionStatus Status { get; }
Property Value
Type | Description |
---|---|
SolutionStatus |
VariableValues
Unique name and solution value for each variable in the solved model instance, or null
if the status of this solution instance is NoSolutionValues
.
Declaration
public IDictionary<string, double> VariableValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Double> |
Methods
ClearValues()
Removes the variable values and objective values from this solution instance and sets the status to NoSolutionValues
.
Declaration
public virtual void ClearValues()
CompareTo(Solution)
Compares the objective values of this solution instance to other
s.
Declaration
public int CompareTo(Solution other)
Parameters
Type | Name | Description |
---|---|---|
Solution | other | Solution instance to compare to. |
Returns
Type | Description |
---|---|
System.Int32 | If the objective values are compared, the return value indicates dominance of solution quality (i.e. zero indicates indifference). |
Implements
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If this solution instance has status |
System.ArgumentException | If |
Equals(Solution)
Indicates whether the objective values of this solution instance are equal to other
s.
Declaration
public bool Equals(Solution other)
Parameters
Type | Name | Description |
---|---|---|
Solution | other | The Solution to compare to. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Implements
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | If this solution instance has status |
System.ArgumentException | If |
Equals(IDictionary<String, Double>)
Indicates whether the variable values of this solution instance are equal to otherVariableValues
.
Declaration
public bool Equals(IDictionary<string, double> otherVariableValues)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.Double> | otherVariableValues | The variable values to compare to. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Implements
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | If this solution instance has status |
System.ArgumentException | If the solutions' variable names do not fit to each other. |
GetBestBound(Int32)
Gets the bound for the given priority level.
Declaration
public double GetBestBound(int priorityLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | priorityLevel | The priority level. |
Returns
Type | Description |
---|---|
System.Double | The best bound or System.Double.NaN, if |
GetMipGap(Int32)
Gets the MipGap for the given priorityLevel
.
Currently only works for Unsupported.
Declaration
public double GetMipGap(int priorityLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | priorityLevel | The hierarchy level |
Returns
Type | Description |
---|---|
System.Double | The respective mip gap. |
GetNameForMergedObjective(Int32)
Gets the name of the (merged, in case of Multi-Hierarchical optimization) Objective
for the given prioLevel
.
The name can be used as input for GetObjectiveValue(String).
Declaration
public string GetNameForMergedObjective(int prioLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | prioLevel | The PriorityLevel for which the (merged) objective name should be retrieved. |
Returns
Type | Description |
---|---|
System.String | The name of the (merged) objective that was optimized in stage |
GetObjectiveValue(Int32)
Gets the objective value for the given prioLevel
.
Declaration
public double GetObjectiveValue(int prioLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | prioLevel | The prio level. |
Returns
Type | Description |
---|---|
System.Double | The objective value, or System.Double.NaN, if the |
GetObjectiveValue(String)
Returns the solution value of the objective named name
, or null
if the status of this solution instance is NoSolutionValues
.
Declaration
public double? GetObjectiveValue(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the objective. |
Returns
Type | Description |
---|---|
System.Nullable<System.Double> | The objective value. |
GetVariableValue(String)
Returns the solution value of the variable named name
, or null
if the status of this solution instance is NoSolutionValues
.
Declaration
public double? GetVariableValue(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the variable. |
Returns
Type | Description |
---|---|
System.Nullable<System.Double> | The variable value. |
SetVariableValuesInModel()
Copies the solution values into the Variables, if automatic copying is enabled.
Declaration
protected void SetVariableValuesInModel()