LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
MetaheuristicsPlatformLotSizingAdapter.cs
Go to the documentation of this file.
1using LotSizingDataModel.Instance;
2using LotSizingDataModel.Solution;
5
7
9{
11 _mappingService;
12
15 {
16 _mappingService =
17 mappingService ??
18 throw new ArgumentNullException(
19 nameof(mappingService));
20 }
21
22 public async ValueTask<LotSizingSolution>
24 LotSizingInstance instance,
26 DebConstraintGaBridgeOptions? options = null,
27 CancellationToken cancellationToken = default)
28 {
29 ArgumentNullException.ThrowIfNull(
30 instance);
31
32 ArgumentNullException.ThrowIfNull(
33 model);
34
35 var optimizer =
37
38 DebConstraintGaBridgeResult bridgeResult =
39 optimizer.Optimize(
40 model,
41 options,
42 cancellationToken);
43
44 if (!bridgeResult.IsFeasible)
45 {
46 throw new InvalidOperationException(
47 "The metaheuristic run did not produce a feasible incumbent.");
48 }
49
50 var projector =
52
53 var mathematicalResult =
54 projector.Project(
55 model,
56 bridgeResult);
57
59 await _mappingService.MapAsync(
60 instance,
61 model,
62 mathematicalResult,
64 {
65 IncludeZeroValues = true,
66 RequireKnownCategories = true,
67 RequireCompleteVariableValues = true
68 },
69 cancellationToken);
70
71 if (!mapping.IsSuccessful ||
72 mapping.Solution is null)
73 {
74 throw new InvalidOperationException(
75 "Normalized mapping of the MetaheuristicsPlatform incumbent failed: " +
76 mapping.FailureMessage);
77 }
78
79 return mapping.Solution;
80 }
81}
async ValueTask< LotSizingSolution > SolveAndMapAsync(LotSizingInstance instance, MathematicalModel model, DebConstraintGaBridgeOptions? options=null, CancellationToken cancellationToken=default)
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.