41 throw new ArgumentNullException(nameof(adapterRegistry));
45 throw new ArgumentNullException(nameof(executorRegistry));
49 throw new ArgumentNullException(nameof(selectionService));
55 public async ValueTask<LinearModelSolveResult>
SolveAsync(
58 CancellationToken cancellationToken =
default)
60 ArgumentNullException.ThrowIfNull(model);
65 options.EnsureValid();
66 cancellationToken.ThrowIfCancellationRequested();
68 var selectionOptions =
71 RequireExactSolverKind =
73 !options.AllowFallbackWhenExplicit
82 await _selectionService.SelectAsync(
96 solveDuration: TimeSpan.Zero,
97 nativeStatus:
string.Empty,
102 _executorRegistry.GetRequired(
Creates the built-in concrete solver-adapter registry.
Creates the built-in CPLEX, Gurobi, Xpress and CBC model executors.
Stores concrete portable-model execution backends by solver kind.
Configures one solver-backed execution of a portable linear model.
Result of executing a solver-independent linear or mixed-integer model.
LinearModelSolver()
Initializes the service with the built-in discovery and execution backends.
LinearModelSolver(SolverAdapterRegistry adapterRegistry, LinearModelExecutorRegistry executorRegistry, SolverSelectionService selectionService)
Initializes the service with explicit registries. This constructor is useful for deterministic tests ...
async ValueTask< LinearModelSolveResult > SolveAsync(LinearModel model, LinearModelSolveOptions? options=null, CancellationToken cancellationToken=default)
Selects a usable solver and executes the portable model.
Immutable solver-independent linear or mixed-integer linear model.
bool IsMixedInteger
Gets whether the model contains integer or binary variables.
string Name
Gets the model name.
Stores optimization-solver adapters and provides deterministic lookup by adapter identifier and solve...
Configures automatic or explicit optimization-solver selection.
List< SolverCapability > RequiredCapabilities
Gets capabilities that the selected adapter must support.
Describes the outcome of optimization-solver selection.
IReadOnlyList< string > Diagnostics
Gets deterministic selection diagnostics.
bool IsSelected
Gets whether a usable adapter was selected.
SolverKind SelectedSolver
Gets the selected solver kind, or Unknown when none was selected.
Selects a usable optimization solver by capability, machine availability, and deterministic priority.
Executes the portable LinearModel with one concrete solver.
ValueTask< LinearModelSolveResult > SolveAsync(LinearModel model, SolverSelectionResult selection, LinearModelSolveOptions options, CancellationToken cancellationToken=default)
Executes one portable model using an already selected solver.
LinearModelSolveStatus
Describes the termination state of a solver-backed portable linear model.
SolverCapability
Identifies an optional capability exposed by an optimization-solver adapter.
@ Automatic
Select the first usable solver according to the configured priority.