75 double integralityTolerance,
76 double nearIntegerTolerance)
80 nameof(zeroTolerance));
84 nameof(integralityTolerance));
88 nameof(nearIntegerTolerance));
116 ArgumentNullException.ThrowIfNull(
119 if (!
double.IsFinite(rawValue))
121 throw new ArgumentOutOfRangeException(
124 "A solver variable value must be finite.");
127 if (Math.Abs(rawValue) <=
133 return variable.Type
switch
153 private double NormalizeBinary(
160 if (Math.Abs(rawValue) <=
173 throw new InvalidOperationException(
174 $
"Binary solver value '{rawValue:G17}' is not within " +
175 $
"the configured integrality tolerance " +
176 $
"'{IntegralityTolerance:G17}' of 0 or 1.");
178 private double NormalizeInteger(
181 double nearestInteger =
184 MidpointRounding.AwayFromZero);
194 private double NormalizeContinuous(
197 double nearestInteger =
200 MidpointRounding.AwayFromZero);
210 private static void ValidateTolerance(
212 string parameterName)
214 if (!
double.IsFinite(tolerance) ||
217 throw new ArgumentOutOfRangeException(
220 "A numerical tolerance must be finite and non-negative.");
LinearVariableValueNormalizer()
Initializes the normalizer with repository defaults.
double NearIntegerTolerance
Gets the near-integer tolerance for continuous values.
const double DefaultIntegralityTolerance
Historical public default absolute tolerance used for integer-domain variables.
const double DefaultNearIntegerTolerance
Default absolute tolerance used to clean continuous values that are numerically indistinguishable fro...
LinearVariableValueNormalizer(double zeroTolerance, double integralityTolerance, double nearIntegerTolerance)
Initializes the normalizer with explicit tolerances.
const double DefaultZeroTolerance
Default absolute tolerance used to identify numerical zero.
double IntegralityTolerance
Gets the integrality tolerance.
double ZeroTolerance
Gets the zero tolerance.
const double SolverIntegralityTolerance
Default integrality tolerance used when normalizing values returned by external mathematical-programm...
double Normalize(LinearVariable variable, double rawValue)
Normalizes one raw solver value according to the variable domain.
Describes one variable in a portable linear mathematical model.
@ Continuous
A continuous real-valued variable.
@ Binary
A binary variable restricted to zero or one.
@ Integer
An integer-valued variable.