LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
UlsAlgorithmsHeuristicLotSizingAdapter.cs
Go to the documentation of this file.
1using LotSizingDataModel.Instance;
4
6
7/// <summary>
8/// Executes one explicitly selected ULSAlgorithms heuristic on
9/// the strict canonical SI-ULS shape introduced by alpha.34.
10/// </summary>
12{
14 _mappingService;
15
17 _extractor =
18 new();
19
20 private readonly UlsAlgorithmsHeuristicBridge
21 _bridge =
22 new();
23
25 _projector =
26 new();
27
30 {
31 _mappingService =
32 mappingService ??
33 throw new ArgumentNullException(
34 nameof(mappingService));
35 }
36
37 public async ValueTask<UlsAlgorithmsHeuristicAdapterResult>
39 LotSizingInstance instance,
40 MathematicalModel canonicalModel,
41 string heuristicSolverId,
42 CancellationToken cancellationToken = default)
43 {
44 ArgumentNullException.ThrowIfNull(
45 instance);
46
47 ArgumentNullException.ThrowIfNull(
48 canonicalModel);
49
51 _extractor.Extract(
52 instance,
53 canonicalModel);
54
56 _bridge.Solve(
57 problem,
58 heuristicSolverId,
59 cancellationToken);
60
61 var mathematicalResult =
62 _projector.Project(
63 canonicalModel,
64 problem,
65 externalResult);
66
68 await _mappingService.MapAsync(
69 instance,
70 canonicalModel,
71 mathematicalResult,
73 {
74 IncludeZeroValues = true,
75 RequireKnownCategories = true,
76 RequireCompleteVariableValues = true
77 },
78 cancellationToken);
79
80 if (!mapping.IsSuccessful ||
81 mapping.Solution is null)
82 {
83 throw new InvalidOperationException(
84 "The normalized LotSizingDataModel mapping of the heuristic ULS result failed: " +
85 mapping.FailureMessage);
86 }
87
89 externalResult,
90 mathematicalResult,
91 mapping.Solution);
92 }
93}
Extracts the narrow canonical SI-ULS contract accepted by the alpha.34 exact adapters.
Normalized deterministic uncapacitated single-item problem passed to ULSAlgorithms.
Executes exactly one pinned public ULSAlgorithms heuristic.
Validated feasible result returned by one pinned ULSAlgorithms heuristic.
async ValueTask< UlsAlgorithmsHeuristicAdapterResult > SolveAndMapAsync(LotSizingInstance instance, MathematicalModel canonicalModel, string heuristicSolverId, CancellationToken cancellationToken=default)
Projects a validated feasible ULSAlgorithms heuristic result onto a canonical LotSizingDataModel math...
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.