LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
LotSizingSolverServiceFactory.cs
Go to the documentation of this file.
1using System;
4
6
7/// <summary>
8/// Provides convenient factory methods for creating the
9/// high-level lot-sizing solver service from a prepared solver
10/// runtime.
11/// </summary>
13{
14 /// <summary>
15 /// Creates the high-level solver service using the supplied
16 /// formulation registry and solver runtime context.
17 /// </summary>
18 /// <param name="formulationRegistry">
19 /// Registry containing the mathematical formulations
20 /// available to the application.
21 /// </param>
22 /// <param name="runtimeContext">
23 /// Prepared runtime containing loaded solver adapters and
24 /// normalized solver availability information.
25 /// </param>
26 /// <returns>
27 /// Configured high-level lot-sizing solver service.
28 /// </returns>
29 /// <exception cref="ArgumentNullException">
30 /// Thrown when <paramref name="formulationRegistry"/> or
31 /// <paramref name="runtimeContext"/> is
32 /// <see langword="null"/>.
33 /// </exception>
35 MathematicalModelFormulationRegistry formulationRegistry,
36 SolverRuntimeContext runtimeContext)
37 {
38 ArgumentNullException.ThrowIfNull(
39 formulationRegistry);
40
41 ArgumentNullException.ThrowIfNull(
42 runtimeContext);
43
44 return new LotSizingSolverService(
45 formulationRegistry,
46 runtimeContext.AdapterRegistry,
47 runtimeContext.AvailabilityInformation);
48 }
49
50 /// <summary>
51 /// Creates the high-level solver service directly from a
52 /// successful solver-runtime build result.
53 /// </summary>
54 /// <param name="formulationRegistry">
55 /// Registry containing the mathematical formulations
56 /// available to the application.
57 /// </param>
58 /// <param name="runtimeBuildResult">
59 /// Solver-runtime build result.
60 /// </param>
61 /// <returns>
62 /// Configured high-level lot-sizing solver service.
63 /// </returns>
64 /// <exception cref="ArgumentNullException">
65 /// Thrown when one of the supplied arguments is
66 /// <see langword="null"/>.
67 /// </exception>
68 /// <exception cref="InvalidOperationException">
69 /// Thrown when the runtime build result does not contain a
70 /// valid runtime context.
71 /// </exception>
73 MathematicalModelFormulationRegistry formulationRegistry,
74 SolverRuntimeBuildResult runtimeBuildResult)
75 {
76 ArgumentNullException.ThrowIfNull(
77 formulationRegistry);
78
79 ArgumentNullException.ThrowIfNull(
80 runtimeBuildResult);
81
82 if (runtimeBuildResult.RuntimeContext is null)
83 {
84 throw new InvalidOperationException(
85 "The solver runtime build result does not contain " +
86 "a valid runtime context.");
87 }
88
89 return Create(
90 formulationRegistry,
91 runtimeBuildResult.RuntimeContext);
92 }
93}
Represents the result of building the solver runtime from discovery information and dynamically loade...
SolverRuntimeContext? RuntimeContext
Gets or sets the runtime context created from the discovered and loaded solver infrastructure.
Represents the solver runtime infrastructure available to the application after adapter discovery and...
SolverAdapterRegistry AdapterRegistry
Gets the registry containing all solver adapters loaded successfully for the current runtime.
IReadOnlyList< SolverAvailabilityInfo > AvailabilityInformation
Gets the normalized availability information for the detected native solvers.
Provides convenient factory methods for creating the high-level lot-sizing solver service from a prep...
static LotSizingSolverService Create(MathematicalModelFormulationRegistry formulationRegistry, SolverRuntimeContext runtimeContext)
Creates the high-level solver service using the supplied formulation registry and solver runtime cont...
static LotSizingSolverService Create(MathematicalModelFormulationRegistry formulationRegistry, SolverRuntimeBuildResult runtimeBuildResult)
Creates the high-level solver service directly from a successful solver-runtime build result.
Orchestrates the complete solution of a lot-sizing instance, from formulation selection to normalized...