10 private readonly Func<IUlsSolver> _factory;
11 private readonly Func<UlsSolverCreationOptions, IUlsSolver>? _configuredFactory;
18 string timeComplexity,
19 string spaceComplexity,
21 string scientificReference,
23 string implementation,
25 Type implementationType,
26 Func<IUlsSolver> factory,
29 Func<UlsSolverCreationOptions, IUlsSolver>? configuredFactory =
null)
31 ArgumentException.ThrowIfNullOrWhiteSpace(
id);
32 ArgumentException.ThrowIfNullOrWhiteSpace(name);
33 ArgumentException.ThrowIfNullOrWhiteSpace(family);
34 ArgumentException.ThrowIfNullOrWhiteSpace(timeComplexity);
35 ArgumentException.ThrowIfNullOrWhiteSpace(spaceComplexity);
36 ArgumentException.ThrowIfNullOrWhiteSpace(applicability);
37 ArgumentException.ThrowIfNullOrWhiteSpace(scientificReference);
38 ArgumentException.ThrowIfNullOrWhiteSpace(implementation);
39 ArgumentException.ThrowIfNullOrWhiteSpace(sourcePath);
40 ArgumentNullException.ThrowIfNull(implementationType);
41 ArgumentNullException.ThrowIfNull(factory);
44 ValidateConfigurationFactory(
45 configurationCapabilities,
48 if (!typeof(
IUlsSolver).IsAssignableFrom(implementationType))
50 throw new ArgumentException(
51 $
"Type '{implementationType.FullName}' does not implement IUlsSolver.",
52 nameof(implementationType));
66 Doi = doi ??
string.Empty;
75 _configuredFactory = configuredFactory;
82 public string Id {
get; }
85 public string Name {
get; }
114 public string Doi {
get; }
145 ValidateCreatedSolver(
160 ArgumentNullException.ThrowIfNull(options);
169 if (_configuredFactory is
null)
171 throw new InvalidOperationException(
172 $
"Solver '{Id}' does not expose configurable construction.");
175 return ValidateCreatedSolver(
176 _configuredFactory(options));
181 ArgumentNullException.ThrowIfNull(solver);
185 throw new InvalidOperationException(
186 $
"Catalog factory for '{Id}' returned '{solver.GetType().FullName}' " +
187 $
"instead of '{ImplementationType.FullName}'.");
192 throw new InvalidOperationException(
193 $
"Catalog kind mismatch for '{Id}'. Expected {Kind}, got {solver.Kind}.");
199 private static void ValidateConfigurationFactory(
201 Func<UlsSolverCreationOptions, IUlsSolver>? configuredFactory)
204 configuredFactory is not
null)
206 throw new ArgumentException(
207 "A configured factory requires at least one configuration capability.",
208 nameof(configuredFactory));
212 configuredFactory is
null)
214 throw new ArgumentException(
215 "Configuration capabilities require a configured factory.",
216 nameof(configuredFactory));
220 private static void ValidateStableId(
string id)
222 if (
id[0] ==
'-' ||
id[^1] ==
'-')
224 throw new ArgumentException(
225 "A solver identifier cannot start or end with '-'.",
229 var previousHyphen =
false;
231 foreach (var character
in id)
234 character is >=
'a' and <=
'z' ||
235 character is >=
'0' and <=
'9' ||
238 if (!valid || (character ==
'-' && previousHyphen))
240 throw new ArgumentException(
241 "Solver identifiers must use normalized lower-kebab-case ASCII.",
245 previousHyphen = character ==
'-';
Composes the existing strategy-specific constructor options used by UlsSolverFactory.
void EnsureValidFor(UlsSolverDescriptor descriptor)
string Doi
Gets the primary DOI when one is recorded, otherwise an empty string.
UlsSolverKind Kind
Gets the exact/heuristic strategy kind.
UlsSolverConfigurationCapabilities ConfigurationCapabilities
Gets the constructor-level settings supported by the configurable factory for this strategy.
string Applicability
Gets the documented applicability conditions.
Type ImplementationType
Gets the concrete public strategy type.
string TimeComplexity
Gets the documented asymptotic time complexity.
string Family
Gets the literature/implementation family.
bool RequiresExternalSolver
Gets whether solving requires an external mathematical-programming engine.
string SourcePath
Gets the repository-relative implementation source path.
string SpaceComplexity
Gets the documented auxiliary/model memory complexity.
string Name
Gets the human-readable strategy name.
string ScientificReference
Gets the primary scientific or historical reference.
IUlsSolver Create()
Creates a new solver instance using the strategy's default constructor policy.
UlsSolverDescriptor(string id, string name, UlsSolverCategory category, string family, string timeComplexity, string spaceComplexity, string applicability, string scientificReference, string doi, string implementation, string sourcePath, Type implementationType, Func< IUlsSolver > factory, UlsSolverConfigurationCapabilities configurationCapabilities=UlsSolverConfigurationCapabilities.None, Func< UlsSolverCreationOptions, IUlsSolver >? configuredFactory=null)
bool SupportsConfiguration
Gets whether this strategy exposes at least one configurable factory setting.
string Implementation
Gets the implementation note exposed by the public catalog.
IUlsSolver Create(UlsSolverCreationOptions options)
Creates a new solver instance using explicit constructor-level configuration.
UlsSolverCategory Category
Gets the operational strategy category.
string Id
Gets the stable lower-kebab-case identifier used by UlsSolverFactory.
Defines the common strategy contract implemented by every ULS solver.
UlsSolverKind Kind
Gets the broad family of the solver.
UlsSolverKind
Identifies the broad family of a ULS solution strategy.
@ Heuristic
A heuristic algorithm that seeks a feasible solution without an optimality proof.
UlsSolverConfigurationCapabilities
Identifies the constructor-level settings that can be supplied through the configurable solver factor...
UlsSolverCategory
Identifies the operational category of a public ULS strategy.
@ OptimizationFormulation
Exact mathematical formulation solved through the portable external optimization layer.
@ Heuristic
Constructive or improvement heuristic without an optimality proof.