LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
CapacityConstraint.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Represents a maximum-capacity constraint defined for each
9/// planning period.
10///
11/// Corresponds to the UML class "Capacite".
12/// Its values correspond to CMax[t] in the source model.
13/// </summary>
14[Serializable]
15[XmlType(TypeName = "capacityConstraint")]
16public sealed class CapacityConstraint :
18{
19 /// <summary>
20 /// Initializes an empty capacity constraint.
21 ///
22 /// This public parameterless constructor is required
23 /// by <see cref="XmlSerializer"/>.
24 /// </summary>
26 {
27 }
28
29 /// <summary>
30 /// Initializes a capacity constraint for the specified
31 /// planning horizon.
32 ///
33 /// Every period is initially assigned a maximum capacity
34 /// of zero.
35 /// </summary>
36 /// <param name="planningHorizon">
37 /// Number of periods in the planning horizon.
38 /// </param>
39 public CapacityConstraint(int planningHorizon)
40 : base(
41 planningHorizon,
42 defaultValue: 0.0) // Initialize all periods with zero capacity
43 {
44 }
45
46 /// <summary>
47 /// Initializes a capacity constraint for the specified
48 /// planning horizon and initial maximum capacity.
49 /// </summary>
50 /// <param name="planningHorizon">
51 /// Number of periods in the planning horizon.
52 /// </param>
53 /// <param name="defaultMaximumCapacity">
54 /// Maximum capacity initially assigned to every period.
55 /// </param>
57 int planningHorizon,
58 double defaultMaximumCapacity)
59 : base(
60 planningHorizon,
61 defaultMaximumCapacity) // Initialize all periods with the specified capacity
62 {
63 }
64
65 /// <summary>
66 /// Gets the complete maximum-capacity time series.
67 ///
68 /// This is a convenience alias for <see cref="LotSizingDataModel.Core.DecisionModel.DoubleTimeSeriesParameter.Values"/>.
69 /// It is not serialized separately.
70 /// </summary>
71 [XmlIgnore]
73 Values;
74
75 /// <summary>
76 /// Gets the maximum capacity available during
77 /// a planning period.
78 /// </summary>
79 /// <param name="period">
80 /// One-based planning-period number.
81 /// </param>
82 public double GetMaximumCapacity(int period)
83 {
84 return GetValue(period);
85 }
86
87 /// <summary>
88 /// Sets the maximum capacity available during
89 /// a planning period.
90 /// </summary>
91 /// <param name="period">
92 /// One-based planning-period number.
93 /// </param>
94 /// <param name="capacity">
95 /// Non-negative finite maximum capacity.
96 /// </param>
97 public void SetMaximumCapacity(
98 int period,
99 double capacity)
100 {
101 SetValue(period, capacity);
102 }
103
104 /// <summary>
105 /// Validates a maximum-capacity 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 capacity is non-negative
115 if (value < 0.0)
116 {
117 throw new ArgumentOutOfRangeException(
118 parameterName,
119 value,
120 "A maximum capacity cannot be negative.");
121 }
122 }
123}
Represents a sequence of finite double values indexed by planning period.
override void ValidateValue(double value, string parameterName)
Validates a maximum-capacity value.
CapacityConstraint(int planningHorizon, double defaultMaximumCapacity)
Initializes a capacity constraint for the specified planning horizon and initial maximum capacity.
DoubleTimeSeries MaximumCapacity
Gets the complete maximum-capacity time series.
void SetMaximumCapacity(int period, double capacity)
Sets the maximum capacity available during a planning period.
CapacityConstraint(int planningHorizon)
Initializes a capacity constraint for the specified planning horizon.
double GetMaximumCapacity(int period)
Gets the maximum capacity available during a planning period.
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.