ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
UlsSolverCreationOptions.cs
Go to the documentation of this file.
4
6
7/// <summary>
8/// Composes the existing strategy-specific constructor options used by
9/// <see cref="UlsSolverFactory"/>.
10/// </summary>
11/// <remarks>
12/// <para>
13/// Every property is optional. An empty instance is equivalent to the
14/// historical parameterless factory path.
15/// </para>
16/// <para>
17/// Configuration is strict: supplying a setting that is not supported by the
18/// selected strategy throws <see cref="ArgumentException"/> rather than being
19/// silently ignored.
20/// </para>
21/// <para>
22/// Existing option objects are reused directly. Solver-backed strategies clone
23/// their execution/cutting-plane options during construction, preserving their
24/// existing ownership semantics.
25/// </para>
26/// </remarks>
27public sealed class UlsSolverCreationOptions
28{
29 /// <summary>
30 /// Gets or sets the general exact fallback used by
31 /// <c>adaptive-exact</c>. Null preserves the default Wagelmans fallback.
32 /// </summary>
34
35 /// <summary>
36 /// Gets or sets the maximum worker count for a strategy exposing the
37 /// parallelism capability. Null preserves that strategy's default.
38 /// </summary>
39 public int? MaxDegreeOfParallelism { get; set; }
40
41 /// <summary>
42 /// Gets or sets the minimum candidate count before parallel evaluation is
43 /// attempted. Null preserves the strategy default.
44 /// </summary>
45 public int? ParallelThreshold { get; set; }
46
47 /// <summary>
48 /// Gets or sets solver-backed execution options, including the requested
49 /// optimization engine and numerical/file-management settings.
50 /// </summary>
52
53 /// <summary>
54 /// Gets or sets root (l,S) cutting-plane engineering options.
55 /// </summary>
56 public LsCuttingPlaneOptions? CuttingPlane { get; set; }
57
58 internal bool IsEmpty =>
60 MaxDegreeOfParallelism is null &&
61 ParallelThreshold is null &&
62 OptimizationExecution is null &&
63 CuttingPlane is null;
64
65 internal void EnsureValidFor(UlsSolverDescriptor descriptor)
66 {
67 ArgumentNullException.ThrowIfNull(descriptor);
68
69 var capabilities = descriptor.ConfigurationCapabilities;
70
71 if (AdaptiveGeneralFallback.HasValue)
72 {
73 RequireCapability(
74 descriptor,
75 capabilities,
76 UlsSolverConfigurationCapabilities.AdaptiveGeneralFallback,
78
79 if (!Enum.IsDefined(
82 {
83 throw new ArgumentOutOfRangeException(
86 "Unknown adaptive general exact fallback.");
87 }
88 }
89
90 if (MaxDegreeOfParallelism.HasValue ||
91 ParallelThreshold.HasValue)
92 {
93 RequireCapability(
94 descriptor,
95 capabilities,
97 "parallelism");
98
99 if (MaxDegreeOfParallelism.HasValue &&
100 (MaxDegreeOfParallelism.Value == 0 ||
101 MaxDegreeOfParallelism.Value < -1))
102 {
103 throw new ArgumentOutOfRangeException(
106 "MaxDegreeOfParallelism must be -1 or strictly positive.");
107 }
108
109 if (ParallelThreshold.HasValue &&
110 ParallelThreshold.Value < 1)
111 {
112 throw new ArgumentOutOfRangeException(
113 nameof(ParallelThreshold),
114 ParallelThreshold.Value,
115 "ParallelThreshold must be strictly positive.");
116 }
117 }
118
119 if (OptimizationExecution is not null)
120 {
121 RequireCapability(
122 descriptor,
123 capabilities,
124 UlsSolverConfigurationCapabilities.OptimizationExecution,
125 nameof(OptimizationExecution));
126
127 OptimizationExecution.EnsureValid();
128 }
129
130 if (CuttingPlane is not null)
131 {
132 RequireCapability(
133 descriptor,
134 capabilities,
136 nameof(CuttingPlane));
137
138 CuttingPlane.EnsureValid();
139 }
140 }
141
142 private static void RequireCapability(
143 UlsSolverDescriptor descriptor,
146 string optionName)
147 {
148 if ((actual & required) == required)
149 {
150 return;
151 }
152
153 throw new ArgumentException(
154 $"Configuration option '{optionName}' is not supported by " +
155 $"solver '{descriptor.Id}'.",
156 optionName);
157 }
158}
Composes the existing strategy-specific constructor options used by UlsSolverFactory.
UlsGeneralExactFallback? AdaptiveGeneralFallback
Gets or sets the general exact fallback used by adaptive-exact. Null preserves the default Wagelmans ...
LinearModelSolveOptions? OptimizationExecution
Gets or sets solver-backed execution options, including the requested optimization engine and numeric...
void EnsureValidFor(UlsSolverDescriptor descriptor)
int? MaxDegreeOfParallelism
Gets or sets the maximum worker count for a strategy exposing the parallelism capability....
int? ParallelThreshold
Gets or sets the minimum candidate count before parallel evaluation is attempted. Null preserves the ...
LsCuttingPlaneOptions? CuttingPlane
Gets or sets root (l,S) cutting-plane engineering options.
Immutable metadata and construction entry for one public ULS strategy.
UlsSolverConfigurationCapabilities ConfigurationCapabilities
Gets the constructor-level settings supported by the configurable factory for this strategy.
Configures root LP (l,S) separation before the final exact MILP solve.
Configures one solver-backed execution of a portable linear model.
UlsSolverConfigurationCapabilities
Identifies the constructor-level settings that can be supplied through the configurable solver factor...
UlsGeneralExactFallback
Selects the general exact algorithm used when the linear-time Wagner-Whitin specialization is not app...