LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
UlsAlgorithmsExactLotSizingAdapter.cs
Go to the documentation of this file.
1using LotSizingDataModel.Instance;
4
6
7/// <summary>
8/// Solves a canonical SI-ULS instance with one explicitly
9/// requested exact ULSAlgorithms method and maps the result
10/// through the existing normalized solution-mapping service.
11/// </summary>
13{
15 _mappingService;
16
18 _extractor;
19
20 private readonly UlsAlgorithmsExactBridge
21 _bridge;
22
24 _projector;
25
28 {
29 _mappingService =
30 mappingService ??
31 throw new ArgumentNullException(
32 nameof(mappingService));
33
34 _extractor =
36
37 _bridge =
39
40 _projector =
42 }
43
44 public async ValueTask<UlsAlgorithmsExactAdapterResult>
46 LotSizingInstance instance,
47 MathematicalModel canonicalModel,
49 CancellationToken cancellationToken = default)
50 {
51 ArgumentNullException.ThrowIfNull(
52 instance);
53
54 ArgumentNullException.ThrowIfNull(
55 canonicalModel);
56
58 _extractor.Extract(
59 instance,
60 canonicalModel);
61
62 UlsAlgorithmsExactBridgeResult externalResult =
63 _bridge.Solve(
64 problem,
65 method,
66 cancellationToken);
67
68 var mathematicalResult =
69 _projector.Project(
70 canonicalModel,
71 problem,
72 externalResult);
73
75 await _mappingService.MapAsync(
76 instance,
77 canonicalModel,
78 mathematicalResult,
80 {
81 IncludeZeroValues = true,
82 RequireKnownCategories = true,
83 RequireCompleteVariableValues = true
84 },
85 cancellationToken);
86
87 if (!mapping.IsSuccessful ||
88 mapping.Solution is null)
89 {
90 throw new InvalidOperationException(
91 "The normalized LotSizingDataModel mapping of the external exact ULS result failed: " +
92 mapping.FailureMessage);
93 }
94
96 externalResult,
97 mathematicalResult,
98 mapping.Solution);
99 }
100}
End-to-end LotSizingDataModel result of an external exact ULSAlgorithms adapter execution.
Executes one explicitly selected exact ULSAlgorithms method. No method fallback is permitted.
Immutable external exact-solve evidence retained before projection back into LotSizingDataModel.
async ValueTask< UlsAlgorithmsExactAdapterResult > SolveAndMapAsync(LotSizingInstance instance, MathematicalModel canonicalModel, UlsAlgorithmsExactMethod method, CancellationToken cancellationToken=default)
Projects a validated ULSAlgorithms exact result onto the already-built canonical LotSizingDataModel m...
Extracts the narrow canonical SI-ULS contract accepted by the alpha.34 exact adapters.
Normalized deterministic uncapacitated single-item problem passed to ULSAlgorithms.
Defines the options used when mapping a mathematical solver result back to a normalized lot-sizing so...
Describes the result of mapping a mathematical solver result back to a normalized lot-sizing solution...
bool IsSuccessful
Gets or sets a value indicating whether mapping succeeded.
LotSizingSolution? Solution
Gets or sets the normalized lot-sizing solution produced by the mapping process.
Represents a solver-independent mathematical optimization model.
Defines a service that maps a generic mathematical solver result to a normalized lot-sizing solution.
UlsAlgorithmsExactMethod
Exact ULSAlgorithms methods deliberately exposed by the LotSizingDataModel alpha.34 bridge.