20 CancellationToken cancellationToken =
default)
22 ArgumentNullException.ThrowIfNull(
31 UlsSolverDescriptor descriptor =
36 UlsSolverFactory.Create(
42 throw new InvalidOperationException(
43 $
"ULSAlgorithms factory returned a non-exact solver for '{solverId}'.");
53 cancellationToken.ThrowIfCancellationRequested();
58 UlsSolveResult solveResult =
65 if (!solveResult.HasSolution ||
66 solveResult.Solution is
null)
68 throw new InvalidOperationException(
69 $
"Exact ULSAlgorithms solver '{solverId}' returned no solution. Status={solveResult.Status}. Message={solveResult.Message}");
72 UlsSolution solution =
75 UlsSolutionValidationResult validation =
76 UlsSolutionValidator.Validate(
80 if (!validation.IsFeasible)
82 throw new InvalidOperationException(
83 $
"ULSAlgorithms validator rejected the exact solution from '{solverId}'.");
86 if (solution.Horizon !=
89 throw new InvalidOperationException(
90 $
"ULSAlgorithms solver '{solverId}' returned horizon {solution.Horizon}, expected {problemData.Horizon}.");
93 double objectiveValue =
94 solveResult.ObjectiveValue ??
97 double costDifference =
100 validation.RecomputedTotalCost);
105 Math.Abs(objectiveValue));
110 throw new InvalidOperationException(
111 $
"ULSAlgorithms exact objective mismatch for '{solverId}'.");
114 string solverVersion =
115 ULSAlgorithmsInfo.InformationalVersion;
117 if (
string.IsNullOrWhiteSpace(
121 ULSAlgorithmsInfo.Version.ToString();
127 solveResult.SolverName,
130 solution.ProductionQuantities.ToArray(),
131 solution.EndingInventories.ToArray(),
132 solution.SetupDecisions.ToArray(),