ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
Solver Catalog and Factory

Solver Catalog and Factory

v0.26.0 exposed the complete public strategy inventory as runtime metadata. v0.27.0 extends the same catalog with strict constructor-level configuration. The API is intended for reusable subproblem libraries, experiment runners, configuration-driven applications, consoles and graphical interfaces.

Complete inventory

foreach (var strategy in UlsSolverCatalog.All)
{
Console.WriteLine(
$"{strategy.Id}: {strategy.Name} — {strategy.TimeComplexity}");
}
Canonical runtime inventory of every public IUlsSolver strategy.
static IReadOnlyList< UlsSolverDescriptor > All
Gets all public strategies in stable catalog order.

The current inventory is:

View Count
UlsSolverCatalog.All 42
UlsSolverCatalog.Exact 23
UlsSolverCatalog.DirectExact 17
UlsSolverCatalog.Formulations 4
UlsSolverCatalog.CuttingPlanes 2
UlsSolverCatalog.Heuristics 19
UlsSolverCatalog.Configurable 8

Exact includes the 17 direct exact algorithms, four solver-backed formulations and two cutting-plane strategies.

Stable identifiers

Each descriptor has a stable lower-kebab-case Id, for example:

adaptive-exact
wagner-whitin-linear
wagelmans-general
aggregate-inventory-formulation
general-ls-cutting-plane
silver-meal
karni-maximum-part-period-gain

Identifiers are resolved case-insensitively by the runtime API, but the canonical spelling is the lowercase form published by the catalog.

Create a strategy by identifier

IUlsSolver solver =
UlsSolverFactory.Create("wagelmans-general");
var result = solver.Solve(problem);
Creates public ULS strategies from stable catalog identifiers.
static IUlsSolver Create(string id)
Creates a new solver using its stable catalog identifier and default constructor policy.
Defines the common strategy contract implemented by every ULS solver.
Definition IUlsSolver.cs:14
UlsSolveResult Solve(UlsProblem problem, CancellationToken cancellationToken=default)
Solves an uncapacitated lot-sizing problem.

Unknown identifiers throw KeyNotFoundException.

For non-throwing configuration paths:

if (UlsSolverFactory.TryCreate(configuredId, out var solver))
{
var result = solver.Solve(problem);
}
static bool TryCreate(string? id, out IUlsSolver? solver)
Attempts to create a solver using its stable catalog identifier.

Every call returns a fresh solver instance.

Filter by operational category

var localExact =
.Where(strategy => !strategy.RequiresExternalSolver);
var solverBacked =
.Where(strategy => strategy.RequiresExternalSolver);
static IReadOnlyList< UlsSolverDescriptor > Exact
Gets all exact strategies, including direct algorithms, formulations and cutting-plane methods.

RequiresExternalSolver is true only for the four mathematical formulations and the two cutting-plane strategies. Their default constructors use the library's normal automatic engine selection when Solve is eventually called.

Descriptor metadata

Each UlsSolverDescriptor provides:

  • Id
  • Name
  • Kind
  • Category
  • Family
  • TimeComplexity
  • SpaceComplexity
  • Applicability
  • RequiresExternalSolver
  • ScientificReference
  • Doi
  • Implementation
  • SourcePath
  • ImplementationType
  • ConfigurationCapabilities
  • SupportsConfiguration

The metadata is descriptive. Applicability text does not replace the strategy-specific runtime guards already implemented by individual solvers.

Configure construction in v0.27.0

The historical API remains unchanged:

IUlsSolver solver =
UlsSolverFactory.Create("wagelmans-general");

A second overload accepts UlsSolverCreationOptions:

var options =
{
AdaptiveGeneralFallback =
UlsGeneralExactFallback.FedergruenTzurGeneral
};
IUlsSolver solver =
"adaptive-exact",
options);
Composes the existing strategy-specific constructor options used by UlsSolverFactory.

Configuration is strict. A non-empty setting that does not belong to the selected strategy throws instead of being silently ignored.

Adaptive fallback

var solver =
"adaptive-exact",
{
AdaptiveGeneralFallback =
UlsGeneralExactFallback.FedergruenTzurGeneral
});

The default remains Wagelmans general. This option exists for reproducible research and explicit policy control; v0.25.0 benchmark evidence still supports Wagelmans as the default general fallback.

Lyu-Lee parallel execution

var solver =
"lyu-lee-parallel",
{
MaxDegreeOfParallelism = 4,
ParallelThreshold = 256
});

Unspecified fields preserve the existing LyuLeeParallelSolver defaults.

Choose an external optimization engine

The factory reuses LinearModelSolveOptions; it does not introduce a second solver-configuration model.

var solver =
"aggregate-inventory-formulation",
{
OptimizationExecution =
{
Solver = SolverKind.CoinOrCbc,
AllowFallbackWhenExplicit = false
}
});
Configures one solver-backed execution of a portable linear model.
SolverKind
Identifies a mathematical optimization solver that can be used by solver-backed ULS algorithms.
Definition SolverKind.cs:15

SolverKind.Automatic retains the normal CPLEX → Gurobi → Xpress → CBC priority. Explicit Cplex, Gurobi, Xpress and CoinOrCbc values are also available.

The full LinearModelSolveOptions object remains available, including feasibility/integrality tolerances, model export, temporary-file retention and temporary-root settings.

Configure cutting planes

Cutting-plane strategies accept both solver execution options and the existing LsCuttingPlaneOptions:

var solver =
"general-ls-cutting-plane",
{
OptimizationExecution =
{
},
CuttingPlane =
new LsCuttingPlaneOptions
{
MaximumIterations = 20,
MaximumCutsPerIteration = 10
}
});
@ Automatic
Select the first usable solver according to the configured priority.
Definition SolverKind.cs:20

The existing cutting-plane object continues to control violation tolerance, minimum efficacy and cut-selection policy as well.

Discover configuration capabilities

foreach (var strategy in UlsSolverCatalog.Configurable)
{
Console.WriteLine(
$"{strategy.Id}: {strategy.ConfigurationCapabilities}");
}
static IReadOnlyList< UlsSolverDescriptor > Configurable
Gets strategies exposing at least one constructor-level configurable factory setting.

The current capability flags are:

  • AdaptiveGeneralFallback
  • Parallelism
  • OptimizationExecution
  • CuttingPlane

This metadata is also projected into docs/algorithm-catalog.json, allowing configuration-driven UIs to expose only relevant controls.

Recommended automatic exact entry point

var recommended =
IUlsSolver solver =
recommended.Create();
static UlsSolverDescriptor RecommendedExact
Gets the recommended automatic exact entry point.

RecommendedExact resolves to adaptive-exact, i.e. AdaptiveExactUlsSolver.

One source of truth for code and documentation

UlsSolverCatalog is the canonical metadata inventory.

docs/algorithm-catalog.json is a generated projection consumed by the documentation portal. CI verifies that it is byte-for-byte synchronized with the runtime catalog.

After adding or changing catalog metadata, regenerate the projection with:

dotnet run -c Release `
--project .\tools\ULSAlgorithms.CatalogExporter\ULSAlgorithms.CatalogExporter.csproj `
-- --write .\docs\algorithm-catalog.json

Validation can be run explicitly with:

.\tools\Test-SolverCatalog.ps1

The normal Build/Test preflight and the documentation workflow both run the same synchronization check.

Persist a configured strategy

v0.28.0 adds UlsSolverConfiguration, a versioned JSON envelope around the stable strategy ID and UlsSolverCreationOptions:

var configuration =
{
SolverId = "lyu-lee-parallel",
Options =
{
MaxDegreeOfParallelism = 4,
ParallelThreshold = 256
}
};
configuration.SaveJson("solver-config.json");
var solver =
UlsSolverConfiguration.LoadJson("solver-config.json"));
Versioned, serializable definition of one ULS strategy and its constructor-level options.
static UlsSolverConfiguration LoadJson(string path)
Loads and validates one UTF-8 JSON configuration file.
void SaveJson(string path)
Writes this configuration as UTF-8 without a byte-order mark.

See Serializable Solver Configuration for schema, validation and reproducibility guidance.