LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
MinimumLotSize.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
5
7
8/// <summary>
9/// Represents the minimum production-lot size for each
10/// planning period.
11///
12/// Corresponds to the UML class "Lot Minimum".
13/// Its values correspond to Qmin[t] in the source model.
14/// </summary>
15[Serializable]
16[XmlType(TypeName = "minimumLotSize")]
17public sealed class MinimumLotSize :
19{
20 /// <summary>
21 /// Initializes an empty minimum-lot-size constraint.
22 ///
23 /// This public parameterless constructor is required
24 /// by <see cref="XmlSerializer"/>.
25 /// </summary>
27 {
28 }
29
30 /// <summary>
31 /// Initializes a minimum-lot-size constraint for the
32 /// specified planning horizon.
33 ///
34 /// Every period is initially assigned a minimum lot size
35 /// of zero.
36 /// </summary>
37 /// <param name="planningHorizon">
38 /// Number of periods in the planning horizon.
39 /// </param>
40 public MinimumLotSize(int planningHorizon)
41 : base(
42 planningHorizon,
43 defaultValue: 0.0) // Initialize all periods with zero minimum lot size
44 {
45 }
46
47 /// <summary>
48 /// Initializes a minimum-lot-size constraint for the
49 /// specified planning horizon and assigns the same value
50 /// to every period.
51 /// </summary>
52 /// <param name="planningHorizon">
53 /// Number of periods in the planning horizon.
54 /// </param>
55 /// <param name="defaultMinimumLotSize">
56 /// Minimum lot size initially assigned to every period.
57 /// </param>
59 int planningHorizon,
60 double defaultMinimumLotSize)
61 : base(
62 planningHorizon,
63 defaultMinimumLotSize) // Initialize all periods with the specified minimum lot size
64 {
65 }
66
67 /// <summary>
68 /// Gets the complete minimum-lot-size time series.
69 ///
70 /// This property is an alias for <see cref="LotSizingDataModel.Core.DecisionModel.DoubleTimeSeriesParameter.Values"/>
71 /// and is not serialized separately.
72 /// </summary>
73 [XmlIgnore]
75 Values;
76
77 /// <summary>
78 /// Gets the minimum lot size for a planning period.
79 /// </summary>
80 /// <param name="period">
81 /// One-based planning-period number.
82 /// </param>
83 public double GetMinimumLotSize(int period)
84 {
85 return GetValue(period);
86 }
87
88 /// <summary>
89 /// Sets the minimum lot size for a planning period.
90 /// </summary>
91 /// <param name="period">
92 /// One-based planning-period number.
93 /// </param>
94 /// <param name="minimumLotSize">
95 /// Non-negative finite minimum lot size.
96 /// </param>
97 public void SetMinimumLotSize(
98 int period,
99 double minimumLotSize)
100 {
101 SetValue(period, minimumLotSize);
102 }
103
104 /// <summary>
105 /// Validates a minimum-lot-size value.
106 /// </summary>
107 protected override void ValidateValue(
108 double value,
109 string parameterName)
110 {
111 // First validate that the value is finite (base class validation)
112 base.ValidateValue(value, parameterName);
113
114 // Then validate that the minimum lot size is non-negative
115 if (value < 0.0)
116 {
117 throw new ArgumentOutOfRangeException(
118 parameterName,
119 value,
120 "A minimum lot size cannot be negative.");
121 }
122 }
123}
Represents a sequence of finite double values indexed by planning period.
double GetMinimumLotSize(int period)
Gets the minimum lot size for a planning period.
MinimumLotSize(int planningHorizon, double defaultMinimumLotSize)
Initializes a minimum-lot-size constraint for the specified planning horizon and assigns the same val...
MinimumLotSize(int planningHorizon)
Initializes a minimum-lot-size constraint for the specified planning horizon.
DoubleTimeSeries MinimumLotSizeByPeriod
Gets the complete minimum-lot-size time series.
void SetMinimumLotSize(int period, double minimumLotSize)
Sets the minimum lot size for a planning period.
override void ValidateValue(double value, string parameterName)
Validates a minimum-lot-size value.
MinimumLotSize()
Initializes an empty minimum-lot-size constraint.
DoubleTimeSeriesParameter()
Initializes an empty period-dependent parameter.
double GetValue(int period)
Gets the parameter value for a planning period.
DoubleTimeSeries Values
Gets or sets the values of the parameter for all planning periods.
void SetValue(int period, double value)
Sets the parameter value for a planning period.