LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
FixedUsageCost.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 used
10/// during a planning period.
11///
12/// This cost does not depend on the quantity processed by the
13/// resource. It is incurred once when the resource is activated
14/// during the corresponding period.
15///
16/// Corresponds to the UML class "Cout fixe d'utilisation".
17/// Its values correspond to CFU[t] in the source model.
18/// </summary>
19[Serializable]
20[XmlType(TypeName = "fixedUsageCost")]
21public sealed class FixedUsageCost :
23{
24 /// <summary>
25 /// Initializes an empty fixed-usage-cost parameter.
26 ///
27 /// This public parameterless constructor is required
28 /// by <see cref="XmlSerializer"/>.
29 /// </summary>
31 {
32 }
33
34 /// <summary>
35 /// Initializes a fixed-usage-cost parameter for the
36 /// specified planning horizon.
37 ///
38 /// Every planning period is initially assigned a cost
39 /// of zero.
40 /// </summary>
41 /// <param name="planningHorizon">
42 /// Number of periods in the planning horizon.
43 /// </param>
44 public FixedUsageCost(int planningHorizon)
45 : base(
46 planningHorizon,
47 defaultValue: 0.0) // Initialize all periods with zero fixed usage cost
48 {
49 }
50
51 /// <summary>
52 /// Initializes a fixed-usage-cost parameter and assigns
53 /// the same cost to every planning period.
54 /// </summary>
55 /// <param name="planningHorizon">
56 /// Number of periods in the planning horizon.
57 /// </param>
58 /// <param name="defaultFixedUsageCost">
59 /// Fixed usage cost initially assigned to every period.
60 /// </param>
62 int planningHorizon,
63 double defaultFixedUsageCost)
64 : base(
65 planningHorizon,
66 defaultFixedUsageCost) // Initialize all periods with the specified fixed usage cost
67 {
68 }
69
70 /// <summary>
71 /// Gets the complete fixed-usage-cost 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 fixed usage cost for a planning period.
82 /// </summary>
83 /// <param name="period">
84 /// One-based planning-period number.
85 /// </param>
86 public double GetFixedUsageCost(int period)
87 {
88 return GetValue(period);
89 }
90
91 /// <summary>
92 /// Sets the fixed usage cost for a planning period.
93 /// </summary>
94 /// <param name="period">
95 /// One-based planning-period number.
96 /// </param>
97 /// <param name="cost">
98 /// Non-negative finite fixed usage cost.
99 /// </param>
100 public void SetFixedUsageCost(
101 int period,
102 double cost)
103 {
104 SetValue(period, cost);
105 }
106
107 /// <summary>
108 /// Validates a fixed usage cost.
109 /// </summary>
110 protected override void ValidateValue(
111 double value,
112 string parameterName)
113 {
114 // First validate that the value is finite (base class validation)
115 base.ValidateValue(value, parameterName);
116
117 // Then validate that the fixed usage cost is non-negative
118 if (value < 0.0)
119 {
120 throw new ArgumentOutOfRangeException(
121 parameterName,
122 value,
123 "A fixed usage cost cannot be negative.");
124 }
125 }
126}
Represents a sequence of finite double values indexed by planning period.
DoubleTimeSeries FixedCostByPeriod
Gets the complete fixed-usage-cost time series.
FixedUsageCost(int planningHorizon, double defaultFixedUsageCost)
Initializes a fixed-usage-cost parameter and assigns the same cost to every planning period.
void SetFixedUsageCost(int period, double cost)
Sets the fixed usage cost for a planning period.
FixedUsageCost()
Initializes an empty fixed-usage-cost parameter.
override void ValidateValue(double value, string parameterName)
Validates a fixed usage cost.
double GetFixedUsageCost(int period)
Gets the fixed usage cost for a planning period.
FixedUsageCost(int planningHorizon)
Initializes a fixed-usage-cost parameter for the specified planning horizon.
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.