LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
ZeroOrFullCapacityProductionAnalyzer.cs
Go to the documentation of this file.
3
5
6/// <summary>
7/// Detects the zero-or-full-capacity production regime from already modeled
8/// minimum-lot-size and production-capacity series.
9/// </summary>
10/// <remarks>
11/// If positive production must be at least the period minimum lot and at most
12/// the same period capacity, equality of those two parameters forces positive
13/// production to full capacity.
14/// </remarks>
16{
18 IEnumerable<double> minimumLotSizes,
19 IEnumerable<double> productionCapacities,
20 TemporalPatternTolerance? tolerance = null)
21 {
22 ArgumentNullException.ThrowIfNull(minimumLotSizes);
23 ArgumentNullException.ThrowIfNull(productionCapacities);
24
25 double[] lowerBounds =
26 minimumLotSizes.ToArray();
27
28 double[] capacities =
29 productionCapacities.ToArray();
30
31 if (
32 lowerBounds.Length == 0 ||
33 lowerBounds.Length != capacities.Length)
34 {
35 throw new ArgumentException(
36 "Minimum-lot-size and capacity series must be non-empty " +
37 "and have the same length.");
38 }
39
40 ValidateNonNegativeFinite(
41 lowerBounds,
42 nameof(minimumLotSizes));
43
44 ValidateNonNegativeFinite(
45 capacities,
46 nameof(productionCapacities));
47
49 tolerance ??
51
52 double scale =
53 lowerBounds
54 .Concat(capacities)
55 .Select(Math.Abs)
56 .DefaultIfEmpty(0.0)
57 .Max();
58
59 double effectiveTolerance =
60 policy.GetEffectiveTolerance(scale);
61
62 double[] gaps =
63 new double[lowerBounds.Length];
64
65 bool satisfied = true;
66
67 for (int index = 0; index < lowerBounds.Length; index++)
68 {
69 gaps[index] =
70 lowerBounds[index] -
71 capacities[index];
72
73 if (
74 capacities[index] <= effectiveTolerance ||
75 Math.Abs(gaps[index]) > effectiveTolerance)
76 {
77 satisfied = false;
78 }
79 }
80
82 satisfied
83 ? UniversalConditionState.Satisfied
84 : UniversalConditionState.NotSatisfied,
85 gaps,
86 effectiveTolerance);
87 }
88
89 private static void ValidateNonNegativeFinite(
90 IEnumerable<double> values,
91 string parameterName)
92 {
93 if (
94 values.Any(
95 value =>
96 !double.IsFinite(value) ||
97 value < 0.0))
98 {
99 throw new ArgumentException(
100 "Production-mode inputs must be finite and non-negative.",
101 parameterName);
102 }
103 }
104}
Result of testing whether positive production is forced to equal the period production capacity.
Detects the zero-or-full-capacity production regime from already modeled minimum-lot-size and product...
ZeroOrFullCapacityProductionAnalysis Analyze(IEnumerable< double > minimumLotSizes, IEnumerable< double > productionCapacities, TemporalPatternTolerance? tolerance=null)
Defines the numerical tolerance policy used for temporal-pattern analysis.
double GetEffectiveTolerance(double scale)
Computes the effective absolute tolerance for a given value scale.
static TemporalPatternTolerance Default
Gets the default conservative numerical tolerance.
UniversalConditionState
Three-valued state of a derived semantic condition.