LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
BacklogCost.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
5
7
8/// <summary>
9/// Represents the unit cost incurred for each item unit
10/// remaining in backlog during a planning period.
11///
12/// Backlog corresponds to demand postponed to a later period.
13/// The cost may therefore be incurred during every period in
14/// which the corresponding demand remains unfulfilled.
15///
16/// Corresponds to the UML class "Cout Backlog".
17/// Its values correspond to CBack[t] in the source model.
18/// </summary>
19[Serializable]
20[XmlType(TypeName = "backlogCost")]
21public sealed class BacklogCost :
23{
24 /// <summary>
25 /// Initializes an empty backlog-cost parameter.
26 ///
27 /// This public parameterless constructor is required
28 /// by <see cref="XmlSerializer"/>.
29 /// </summary>
30 public BacklogCost()
31 {
32 }
33
34 /// <summary>
35 /// Initializes a backlog-cost parameter for the specified
36 /// planning horizon.
37 ///
38 /// Every planning period is initially assigned a unit
39 /// backlog cost of zero.
40 /// </summary>
41 /// <param name="planningHorizon">
42 /// Number of periods in the planning horizon.
43 /// </param>
44 public BacklogCost(int planningHorizon)
45 : base(
46 planningHorizon,
47 defaultValue: 0.0) // Initialize all periods with zero unit backlog cost
48 {
49 }
50
51 /// <summary>
52 /// Initializes a backlog-cost parameter and assigns
53 /// the same unit cost to every planning period.
54 /// </summary>
55 /// <param name="planningHorizon">
56 /// Number of periods in the planning horizon.
57 /// </param>
58 /// <param name="defaultUnitBacklogCost">
59 /// Unit backlog cost initially assigned to every period.
60 /// </param>
62 int planningHorizon,
63 double defaultUnitBacklogCost)
64 : base(
65 planningHorizon,
66 defaultUnitBacklogCost) // Initialize all periods with the specified unit backlog cost
67 {
68 }
69
70 /// <summary>
71 /// Gets the complete unit-backlog-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 cost of keeping one item unit in backlog
82 /// during a planning period.
83 /// </summary>
84 /// <param name="period">
85 /// One-based planning-period number.
86 /// </param>
87 public double GetUnitBacklogCost(int period)
88 {
89 return GetValue(period);
90 }
91
92 /// <summary>
93 /// Sets the cost of keeping one item unit in backlog
94 /// during a planning period.
95 /// </summary>
96 /// <param name="period">
97 /// One-based planning-period number.
98 /// </param>
99 /// <param name="cost">
100 /// Non-negative finite cost per backlog unit.
101 /// </param>
103 int period,
104 double cost)
105 {
106 SetValue(period, cost);
107 }
108
109 /// <summary>
110 /// Validates a unit backlog cost.
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 backlog cost is non-negative
120 if (value < 0.0)
121 {
122 throw new ArgumentOutOfRangeException(
123 parameterName,
124 value,
125 "A unit backlog cost cannot be negative.");
126 }
127 }
128}
Represents a sequence of finite double values indexed by planning period.
DoubleTimeSeries UnitBacklogCostByPeriod
Gets the complete unit-backlog-cost time series.
void SetUnitBacklogCost(int period, double cost)
Sets the cost of keeping one item unit in backlog during a planning period.
double GetUnitBacklogCost(int period)
Gets the cost of keeping one item unit in backlog during a planning period.
BacklogCost(int planningHorizon, double defaultUnitBacklogCost)
Initializes a backlog-cost parameter and assigns the same unit cost to every planning period.
override void ValidateValue(double value, string parameterName)
Validates a unit backlog cost.
BacklogCost(int planningHorizon)
Initializes a backlog-cost parameter for the specified planning horizon.
BacklogCost()
Initializes an empty backlog-cost parameter.
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.