12 string.IsNullOrWhiteSpace(
18 Directory.CreateDirectory(parent);
24 solverKind.ToString(),
25 Guid.NewGuid().ToString(
"N"));
27 Directory.CreateDirectory(directory);
32 string generatedModelPath,
35 if (
string.IsNullOrWhiteSpace(
46 Path.GetDirectoryName(destination);
48 if (!
string.IsNullOrWhiteSpace(directory))
50 Directory.CreateDirectory(directory);
59 internal static IReadOnlyDictionary<int, double>
62 IReadOnlyDictionary<int, double> returnedValues)
65 new Dictionary<int, double>(
70 completed[variable.
Id] =
71 returnedValues.TryGetValue(
75 : variable.LowerBound == variable.UpperBound
88 IReadOnlyDictionary<int, double> returnedValues,
89 bool hasCandidateSolution,
92 IEnumerable<string> diagnostics,
93 string artifactDirectory)
98 IReadOnlyDictionary<int, double> completed =
103 :
new Dictionary<int, double>();
105 IReadOnlyDictionary<int, double> normalized =
119 if (hasCandidateSolution)
128 foreach (
string diagnostic
in validation.
Diagnostics)
131 "Independent checker: " +
144 "The native solver returned a candidate solution, but " +
145 "the independent portable-model checker rejected it.");
149 string retainedDirectory =
150 options.KeepTemporaryFiles
165 SolverReportedStatus =
173 IReadOnlyDictionary<int, double> values,
183 new Dictionary<int, double>(
188 if (!values.TryGetValue(
190 out
double rawValue))
192 throw new InvalidOperationException(
193 $
"No returned value exists for variable '{variable.Name}'.");
196 normalized[variable.
Id] =
197 normalizer.Normalize(
216 if (Directory.Exists(directory))
235 StringSplitOptions.RemoveEmptyEntries |
236 StringSplitOptions.TrimEntries)
Independent solver-agnostic validation of a returned variable assignment.
bool IsFeasible
Gets whether all checked requirements passed.
IReadOnlyList< string > Diagnostics
Gets validation diagnostics.
Independently checks solver-returned values against the portable model.
static LinearModelSolutionValidation Validate(LinearModel model, IReadOnlyDictionary< int, double > values, double feasibilityTolerance, double integralityTolerance)
Validates bounds, integrality, constraints and objective reconstruction.
Configures one solver-backed execution of a portable linear model.
string TemporaryRootPath
Gets or sets an optional parent directory for temporary solver artifacts.
double NearIntegerTolerance
Gets or sets the tolerance used to clean continuous values that are numerically indistinguishable fro...
double ZeroTolerance
Gets or sets the tolerance used to identify numerical zero before validation and objective reconstruc...
double IntegralityTolerance
Gets or sets the integrality tolerance used both for normalization and the independent solution check...
bool KeepTemporaryFiles
Gets or sets whether temporary model/solution/log artifacts are retained.
string ExportModelPath
Gets or sets an optional path receiving the exact LP model submitted to the selected solver.
double FeasibilityTolerance
Gets or sets the feasibility tolerance used by the independent solution checker.
Result of executing a solver-independent linear or mixed-integer model.
Normalizes raw mathematical-variable values returned by optimization solvers before independent valid...
static LinearModelSolveResult BuildSolutionResult(LinearModel model, SolverSelectionResult selection, LinearModelSolveOptions options, LinearModelSolveStatus proposedStatus, IReadOnlyDictionary< int, double > returnedValues, bool hasCandidateSolution, TimeSpan duration, string nativeStatus, IEnumerable< string > diagnostics, string artifactDirectory)
static string CreateArtifactDirectory(SolverKind solverKind, LinearModelSolveOptions options)
static string LastMeaningfulLine(string text)
static IReadOnlyDictionary< int, double > NormalizeValues(LinearModel model, IReadOnlyDictionary< int, double > values, LinearModelSolveOptions options)
static void DeleteArtifactsUnlessRetained(string directory, LinearModelSolveOptions options)
static void ExportModelIfRequested(string generatedModelPath, LinearModelSolveOptions options)
static IReadOnlyDictionary< int, double > CompleteValues(LinearModel model, IReadOnlyDictionary< int, double > returnedValues)
Immutable solver-independent linear or mixed-integer linear model.
string Name
Gets the model name.
int VariableCount
Gets the number of variables.
Describes one variable in a portable linear mathematical model.
int Id
Gets the stable zero-based variable identifier.
Serializable-style immutable snapshot of the solver selected for one solver-backed ULS execution.
Describes the outcome of optimization-solver selection.
LinearModelSolveStatus
Describes the termination state of a solver-backed portable linear model.
SolverKind
Identifies a mathematical optimization solver that can be used by solver-backed ULS algorithms.