LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
SafetyStockViolationCost.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
5
7
8/// <summary>
9/// Represents the unit cost incurred when the inventory level
10/// falls below the required safety-stock level.
11///
12/// The cost is applied to each unit missing from the safety stock
13/// during the corresponding planning period.
14///
15/// Corresponds to the UML class "Cout stock securite".
16/// Its values correspond to CSecu[t] in the source model.
17/// </summary>
18[Serializable]
19[XmlType(TypeName = "safetyStockViolationCost")]
20public sealed class SafetyStockViolationCost :
22{
23 /// <summary>
24 /// Initializes an empty safety-stock-violation-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 safety-stock-violation-cost parameter
35 /// for the specified planning horizon.
36 ///
37 /// Every planning period is initially assigned a unit cost
38 /// of zero.
39 /// </summary>
40 /// <param name="planningHorizon">
41 /// Number of periods in the planning horizon.
42 /// </param>
43 public SafetyStockViolationCost(int planningHorizon)
44 : base(
45 planningHorizon,
46 defaultValue: 0.0) // Initialize all periods with zero violation cost
47 {
48 }
49
50 /// <summary>
51 /// Initializes a safety-stock-violation-cost parameter and
52 /// assigns the same unit cost to every planning period.
53 /// </summary>
54 /// <param name="planningHorizon">
55 /// Number of periods in the planning horizon.
56 /// </param>
57 /// <param name="defaultUnitViolationCost">
58 /// Unit cost initially assigned to every planning period.
59 /// </param>
61 int planningHorizon,
62 double defaultUnitViolationCost)
63 : base(
64 planningHorizon,
65 defaultUnitViolationCost) // Initialize all periods with the specified unit violation cost
66 {
67 }
68
69 /// <summary>
70 /// Gets the complete safety-stock-violation-cost time series.
71 ///
72 /// This property is an alias for <see cref="LotSizingDataModel.Core.DecisionModel.DoubleTimeSeriesParameter.Values"/>
73 /// and is not serialized separately.
74 /// </summary>
75 [XmlIgnore]
77 Values;
78
79 /// <summary>
80 /// Gets the cost incurred for one unit missing
81 /// from the safety stock during a planning period.
82 /// </summary>
83 /// <param name="period">
84 /// One-based planning-period number.
85 /// </param>
86 public double GetUnitViolationCost(int period)
87 {
88 return GetValue(period);
89 }
90
91 /// <summary>
92 /// Sets the cost incurred for one unit missing
93 /// from the safety stock during a planning period.
94 /// </summary>
95 /// <param name="period">
96 /// One-based planning-period number.
97 /// </param>
98 /// <param name="cost">
99 /// Non-negative finite cost per missing unit.
100 /// </param>
102 int period,
103 double cost)
104 {
105 SetValue(period, cost);
106 }
107
108 /// <summary>
109 /// Validates a safety-stock-violation unit cost.
110 /// </summary>
111 protected override void ValidateValue(
112 double value,
113 string parameterName)
114 {
115 // First validate that the value is finite (base class validation)
116 base.ValidateValue(value, parameterName);
117
118 // Then validate that the safety-stock-violation cost is non-negative
119 if (value < 0.0)
120 {
121 throw new ArgumentOutOfRangeException(
122 parameterName,
123 value,
124 "A safety-stock-violation cost cannot be negative.");
125 }
126 }
127}
Represents a sequence of finite double values indexed by planning period.
double GetUnitViolationCost(int period)
Gets the cost incurred for one unit missing from the safety stock during a planning period.
DoubleTimeSeries UnitViolationCostByPeriod
Gets the complete safety-stock-violation-cost time series.
void SetUnitViolationCost(int period, double cost)
Sets the cost incurred for one unit missing from the safety stock during a planning period.
SafetyStockViolationCost(int planningHorizon, double defaultUnitViolationCost)
Initializes a safety-stock-violation-cost parameter and assigns the same unit cost to every planning ...
override void ValidateValue(double value, string parameterName)
Validates a safety-stock-violation unit cost.
SafetyStockViolationCost()
Initializes an empty safety-stock-violation-cost parameter.
SafetyStockViolationCost(int planningHorizon)
Initializes a safety-stock-violation-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.