2using System.Collections.Generic;
4using System.Threading.Tasks;
23 private readonly
object _synchronizationRoot =
62 public async ValueTask<MathematicalModelSolveResult>
SolveAsync(
66 IEnumerable<SolverAvailabilityInfo>
67 availabilityInformation,
69 CancellationToken cancellationToken =
default)
71 ArgumentNullException.ThrowIfNull(
74 ArgumentNullException.ThrowIfNull(
77 ArgumentNullException.ThrowIfNull(
78 availabilityInformation);
80 ArgumentNullException.ThrowIfNull(
85 cancellationToken.ThrowIfCancellationRequested();
88 await _selectionService.SelectAsync(
91 availabilityInformation,
98 var unavailableResult =
116 HasFeasibleSolution =
127 unavailableResult.AddDiagnostic(
132 "No usable mathematical-model solver adapter " +
133 "could be selected.");
135 unavailableResult.EnsureValid();
137 return unavailableResult;
154 result.AddDiagnostic(
158 result.EnsureValid();
181 lock (_synchronizationRoot)
187 if (adapter is not
null)
189 ((global::LotSizingDataModel.Solver.Contracts.IMathematicalModelSolver)adapter)
194 private void SetActiveAdapter(
197 ArgumentNullException.ThrowIfNull(
200 lock (_synchronizationRoot)
202 if (_activeAdapter is not
null)
204 throw new InvalidOperationException(
205 "Another mathematical-model solve is already " +
206 "running through this execution service.");
214 private void ClearActiveAdapter(
217 lock (_synchronizationRoot)
Stores solver adapters that were loaded successfully and provides lookup services by adapter identifi...
Configures how a solver adapter is selected when automatic solver selection is requested.
Describes a request to solve an already built, solver-independent mathematical model.
string FormulationId
Gets or sets the identifier of the formulation that generated the mathematical model.
string RunName
Gets or sets an optional run name.
void EnsureValid()
Validates the mathematical-model solve request.
Stores the solver result for a solver-independent mathematical model.
void AddDiagnostic(string diagnostic)
Adds a non-empty diagnostic message.
Selects a compatible mathematical-model solver adapter and executes an already built solver-independe...
void RequestStop()
Requests interruption of the mathematical-model solve currently executed by the selected solver adapt...
async ValueTask< MathematicalModelSolveResult > SolveAsync(MathematicalModelSolveRequest request, SolverKind requestedSolver, SolverAdapterRegistry registry, IEnumerable< SolverAvailabilityInfo > availabilityInformation, SolverSelectionOptions selectionOptions, CancellationToken cancellationToken=default)
Selects a solver adapter and solves the mathematical model.
Represents the result of selecting a solver adapter that can solve a solver-independent mathematical ...
SolverKind SelectedSolver
Gets or sets the solver selected by the general solver-selection service.
bool IsSuccessful
Gets a value indicating whether a usable mathematical-model solver adapter was selected.
IMathematicalModelSolverAdapter? Adapter
Gets or sets the selected live mathematical-model solver adapter.
string AdapterName
Gets or sets the selected adapter display name.
List< string > Diagnostics
Gets the diagnostics produced during adapter selection.
Selects a solver adapter that supports direct execution of solver-independent mathematical models.
Defines a dynamically discoverable solver adapter capable of solving solver-independent mathematical ...
ValueTask< MathematicalModelSolveResult > SolveAsync(MathematicalModelSolveRequest request, CancellationToken cancellationToken=default)
Solves a solver-independent mathematical model.
Defines a service that selects a compatible solver adapter and executes an already built solver-indep...
SolverTerminationReason
Describes why a solver execution terminated.
SolverKind
Identifies a supported mathematical optimization solver.