21 IReadOnlyDictionary<int, double> values)
23 ArgumentNullException.ThrowIfNull(result);
24 ArgumentNullException.ThrowIfNull(model);
25 ArgumentNullException.ThrowIfNull(values);
29 if (!values.TryGetValue(variable.
Id, out
double value))
34 result.AddVariableValue(
54 IReadOnlyDictionary<int, double> values,
55 out
double objectiveValue)
57 ArgumentNullException.ThrowIfNull(model);
58 ArgumentNullException.ThrowIfNull(values);
63 foreach (
LinearTerm term
in model.Objective.Expression.Terms)
65 if (!values.TryGetValue(term.
VariableId, out
double variableValue))
67 objectiveValue =
default;
72 term.Coefficient * variableValue;
75 objectiveValue = value;
76 return double.IsFinite(value);
87 ArgumentNullException.ThrowIfNull(result);
101 result.AbsoluteGap.Value /
114 ArgumentException.ThrowIfNullOrWhiteSpace(solverToken);
119 "LotSizingDataModel",
121 Guid.NewGuid().ToString(
"N"));
123 Directory.CreateDirectory(directory);
134 if (
string.IsNullOrWhiteSpace(directory))
141 if (Directory.Exists(directory))
160 string generatedLpPath,
161 string configuredExportPath)
163 ArgumentException.ThrowIfNullOrWhiteSpace(generatedLpPath);
166 string.IsNullOrWhiteSpace(configuredExportPath)
167 ? Path.GetFullPath(
"LotSizingModel.lp")
168 : Path.GetFullPath(configuredExportPath);
171 Path.GetDirectoryName(path);
173 if (!
string.IsNullOrWhiteSpace(directory))
175 Directory.CreateDirectory(directory);
Stores the solver result for a solver-independent mathematical model.
double? ObjectiveValue
Gets or sets the objective value.
double? BestBound
Gets or sets the best objective bound.
Stores the value returned by a solver for one mathematical decision variable.
Shared helpers used by optional native-solver adapters.
static void TryDeleteDirectory(string directory)
Removes a temporary directory without masking a solver result or error.
static void PopulateVariableValues(MathematicalModelSolveResult result, MathematicalModel model, IReadOnlyDictionary< int, double > values)
Populates generic mathematical variable values from a dictionary keyed by mathematical variable ident...
static bool TryEvaluateObjective(MathematicalModel model, IReadOnlyDictionary< int, double > values, out double objectiveValue)
Evaluates the mathematical objective from a complete or partial value map.
static void PopulateGapStatistics(MathematicalModelSolveResult result)
Computes absolute and relative objective gaps when an incumbent and bound are available.
static string CreateTemporaryDirectory(string solverToken)
Creates an isolated temporary directory for one solver invocation.
static void ExportPortableModel(string generatedLpPath, string configuredExportPath)
Copies the generated portable LP model to the user-requested export path.
double Constant
Gets or sets the constant value of the expression.
Represents one coefficient-variable term in a linear expression.
int VariableId
Gets or sets the identifier of the referenced mathematical variable.
Represents a solver-independent mathematical optimization model.
MathematicalObjective Objective
Gets or sets the mathematical objective.
LinearExpression Expression
Gets or sets the linear objective expression.
Represents one decision variable in a mathematical optimization model.
string DomainKey
Gets or sets an optional domain key used to map the mathematical variable back to a lot-sizing decisi...
int Id
Gets or sets the unique variable identifier within the mathematical model.
string Name
Gets or sets the variable name.