ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
LinearModelExecutorRegistry.cs
Go to the documentation of this file.
2
3/// <summary>
4/// Stores concrete portable-model execution backends by solver kind.
5/// </summary>
6public sealed class LinearModelExecutorRegistry
7{
8 private readonly Dictionary<SolverKind, ILinearModelSolverExecutor>
9 _executors = [];
10
11 /// <summary>Gets the number of registered execution backends.</summary>
12 public int Count => _executors.Count;
13
14 /// <summary>Registers one concrete execution backend.</summary>
15 public void Register(
17 {
18 ArgumentNullException.ThrowIfNull(executor);
19
20 if (executor.SolverKind is
21 SolverKind.Unknown or
22 SolverKind.Automatic)
23 {
24 throw new InvalidOperationException(
25 "An executor must target one concrete solver.");
26 }
27
28 if (!_executors.TryAdd(
29 executor.SolverKind,
30 executor))
31 {
32 throw new InvalidOperationException(
33 $"An executor for '{executor.SolverKind}' is already registered.");
34 }
35 }
36
37 /// <summary>Gets one registered execution backend.</summary>
39 SolverKind solverKind)
40 {
41 return _executors.TryGetValue(
42 solverKind,
43 out ILinearModelSolverExecutor? executor)
44 ? executor
45 : throw new InvalidOperationException(
46 $"No linear-model executor is registered for '{solverKind}'.");
47 }
48}
Stores concrete portable-model execution backends by solver kind.
ILinearModelSolverExecutor GetRequired(SolverKind solverKind)
Gets one registered execution backend.
void Register(ILinearModelSolverExecutor executor)
Registers one concrete execution backend.
int Count
Gets the number of registered execution backends.
Executes the portable LinearModel with one concrete solver.
SolverKind SolverKind
Gets the concrete solver implemented by this executor.
SolverKind
Identifies a mathematical optimization solver that can be used by solver-backed ULS algorithms.
Definition SolverKind.cs:15