2using LotSizingDataModel.Solution;
3using LotSizingDataModel.Solution.Common;
4using LotSizingDataModel.Solution.Metadata;
32 LotSizingSolution solution,
35 ArgumentNullException.ThrowIfNull(
38 ArgumentNullException.ThrowIfNull(
43 SolutionGenerationMetadata metadata =
44 solution.GenerationMetadata;
47 SolutionMethodKind.ExactOptimization;
50 "Mathematical optimization";
52 metadata.MethodVersion =
55 metadata.ImplementationName =
58 metadata.ImplementationVersion =
61 metadata.TerminationReason =
65 metadata.DurationSeconds =
68 metadata.IterationCount =
71 metadata.CreatedAtUtc =
92 return terminationReason
switch
95 TerminationReason.OptimalityProven,
98 TerminationReason.Completed,
101 TerminationReason.TimeLimit,
104 TerminationReason.IterationLimit,
107 TerminationReason.ResourceLimit,
110 TerminationReason.ResourceLimit,
113 TerminationReason.EvaluationLimit,
116 TerminationReason.TargetReached,
119 TerminationReason.TargetReached,
122 TerminationReason.TargetReached,
125 TerminationReason.UserInterrupted,
128 TerminationReason.Completed,
131 TerminationReason.Completed,
134 TerminationReason.Completed,
137 TerminationReason.Error,
140 TerminationReason.Error,
143 TerminationReason.Error,
146 TerminationReason.Error,
149 TerminationReason.Error,
152 TerminationReason.Unknown
156 private static string BuildComment(
168 $
"Objective={FormatNullable(solveResult.ObjectiveValue)}; " +
169 $
"BestBound={FormatNullable(solveResult.BestBound)}; " +
170 $
"RelativeGap={FormatNullable(solveResult.RelativeGap)}; " +
171 $
"AbsoluteGap={FormatNullable(solveResult.AbsoluteGap)}.";
174 private static string FormatNullable(
177 return value.HasValue
178 ? value.Value.ToString(
180 System.Globalization.CultureInfo.InvariantCulture)
Stores the solver result for a solver-independent mathematical model.
double? RelativeGap
Gets or sets the relative optimality gap.
void EnsureValid()
Validates the mathematical-model solve result.
double? ObjectiveValue
Gets or sets the objective value.
SolverTerminationReason TerminationReason
Gets or sets the termination reason.
long? IterationCount
Gets or sets the number of simplex or barrier iterations, when available.
string FormulationId
Gets or sets the identifier of the formulation that generated the mathematical model.
string SolverName
Gets or sets the solver name.
string SolverVersion
Gets or sets the solver version.
TimeSpan SolveDuration
Gets or sets the solver wall-clock duration.
double? BestBound
Gets or sets the best objective bound.
double? AbsoluteGap
Gets or sets the absolute optimality gap.
SolverTerminationReason
Describes why a solver execution terminated.
@ UserInterrupted
The execution was interrupted by the user or by a cancellation request.
@ LicenseError
The solver could not run because a valid license was unavailable.
@ MemoryLimit
The configured memory limit was reached.
@ RelativeGapLimit
The configured relative optimality-gap limit was reached.
@ ModelError
The mathematical model was invalid or unsupported.
@ TimeLimit
The configured time limit was reached.
@ ObjectiveLimit
The configured objective limit was reached.
@ Infeasible
The mathematical model was proven infeasible.
@ Unbounded
The mathematical model was proven unbounded.
@ InternalError
The solver stopped because of an internal error.
@ Feasible
A feasible solution was found, but optimality was not proven.
@ SolutionLimit
The configured solution limit was reached.
@ NodeLimit
The configured node limit was reached.
@ Optimal
An optimal solution was proven.
@ IterationLimit
The configured iteration limit was reached.
@ AbsoluteGapLimit
The configured absolute optimality-gap limit was reached.
@ SolverUnavailable
The requested solver was unavailable on the current computer.
@ NumericalDifficulty
The solver stopped because of numerical difficulties.
@ InfeasibleOrUnbounded
The solver could not distinguish between infeasibility and unboundedness.