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