LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
UlsAlgorithmsExactProblemData.cs
Go to the documentation of this file.
2
3/// <summary>
4/// Normalized deterministic uncapacitated single-item problem
5/// passed to ULSAlgorithms.
6/// </summary>
8{
10 IReadOnlyList<double> demands,
11 IReadOnlyList<double> setupCosts,
12 IReadOnlyList<double> unitProductionCosts,
13 IReadOnlyList<double> holdingCosts)
14 {
15 ArgumentNullException.ThrowIfNull(demands);
16 ArgumentNullException.ThrowIfNull(setupCosts);
17 ArgumentNullException.ThrowIfNull(unitProductionCosts);
18 ArgumentNullException.ThrowIfNull(holdingCosts);
19
20 Demands = demands.ToArray();
21 SetupCosts = setupCosts.ToArray();
22 UnitProductionCosts = unitProductionCosts.ToArray();
23 HoldingCosts = holdingCosts.ToArray();
24
26 }
27
28 public double[] Demands
29 {
30 get;
31 }
32
33 public double[] SetupCosts
34 {
35 get;
36 }
37
38 public double[] UnitProductionCosts
39 {
40 get;
41 }
42
43 public double[] HoldingCosts
44 {
45 get;
46 }
47
48 public int Horizon =>
49 Demands.Length;
50
51 public void EnsureValid()
52 {
53 if (Horizon <= 0)
54 {
55 throw new InvalidOperationException(
56 "A ULSAlgorithms exact problem requires a positive planning horizon.");
57 }
58
59 if (SetupCosts.Length != Horizon ||
60 UnitProductionCosts.Length != Horizon ||
61 HoldingCosts.Length != Horizon)
62 {
63 throw new InvalidOperationException(
64 "Demand, setup-cost, production-cost and holding-cost vectors must have identical horizons.");
65 }
66
67 ValidateVector(
68 Demands,
69 nameof(Demands));
70
71 ValidateVector(
73 nameof(SetupCosts));
74
75 ValidateVector(
77 nameof(UnitProductionCosts));
78
79 ValidateVector(
81 nameof(HoldingCosts));
82 }
83
84 private static void ValidateVector(
85 IReadOnlyList<double> values,
86 string name)
87 {
88 for (int index = 0;
89 index < values.Count;
90 index++)
91 {
92 double value =
93 values[index];
94
95 if (double.IsNaN(value) ||
96 double.IsInfinity(value) ||
97 value < 0.0)
98 {
99 throw new InvalidOperationException(
100 $"{name}[{index}] must be finite and non-negative.");
101 }
102 }
103 }
104}
UlsAlgorithmsExactProblemData(IReadOnlyList< double > demands, IReadOnlyList< double > setupCosts, IReadOnlyList< double > unitProductionCosts, IReadOnlyList< double > holdingCosts)