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