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