LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
BacklogConstraint.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
5
7
8/// <summary>
9/// Represents the maximum backlog level allowed for each
10/// planning period.
11///
12/// Backlog corresponds to demand that is not satisfied during
13/// its original period but remains to be fulfilled later.
14///
15/// Corresponds to the UML class "Backlog".
16/// Its values correspond to Blmax[t] in the source model.
17/// </summary>
18[Serializable]
19[XmlType(TypeName = "backlogConstraint")]
20public sealed class BacklogConstraint :
22{
23 /// <summary>
24 /// Initializes an empty backlog constraint.
25 ///
26 /// This public parameterless constructor is required
27 /// by <see cref="XmlSerializer"/>.
28 /// </summary>
30 {
31 }
32
33 /// <summary>
34 /// Initializes a backlog constraint for the specified
35 /// planning horizon.
36 ///
37 /// Every period is initially assigned a maximum backlog
38 /// level of zero.
39 /// </summary>
40 /// <param name="planningHorizon">
41 /// Number of periods in the planning horizon.
42 /// </param>
43 public BacklogConstraint(int planningHorizon)
44 : base(
45 planningHorizon,
46 defaultValue: 0.0) // Initialize all periods with zero maximum backlog
47 {
48 }
49
50 /// <summary>
51 /// Initializes a backlog constraint and assigns the same
52 /// maximum backlog level to every planning period.
53 /// </summary>
54 /// <param name="planningHorizon">
55 /// Number of periods in the planning horizon.
56 /// </param>
57 /// <param name="defaultMaximumBacklog">
58 /// Maximum backlog initially allowed in every period.
59 /// </param>
61 int planningHorizon,
62 double defaultMaximumBacklog)
63 : base(
64 planningHorizon,
65 defaultMaximumBacklog) // Initialize all periods with the specified maximum backlog
66 {
67 }
68
69 /// <summary>
70 /// Gets the complete maximum-backlog 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 maximum backlog allowed during a planning period.
81 /// </summary>
82 /// <param name="period">
83 /// One-based planning-period number.
84 /// </param>
85 public double GetMaximumBacklog(int period)
86 {
87 return GetValue(period);
88 }
89
90 /// <summary>
91 /// Sets the maximum backlog allowed during a planning period.
92 /// </summary>
93 /// <param name="period">
94 /// One-based planning-period number.
95 /// </param>
96 /// <param name="maximumBacklog">
97 /// Non-negative finite maximum backlog level.
98 /// </param>
99 public void SetMaximumBacklog(
100 int period,
101 double maximumBacklog)
102 {
103 SetValue(period, maximumBacklog);
104 }
105
106 /// <summary>
107 /// Validates a maximum-backlog value.
108 /// </summary>
109 protected override void ValidateValue(
110 double value,
111 string parameterName)
112 {
113 // First validate that the value is finite (base class validation)
114 base.ValidateValue(value, parameterName);
115
116 // Then validate that the maximum backlog level is non-negative
117 if (value < 0.0)
118 {
119 throw new ArgumentOutOfRangeException(
120 parameterName,
121 value,
122 "A maximum backlog level cannot be negative.");
123 }
124 }
125}
Represents a sequence of finite double values indexed by planning period.
BacklogConstraint(int planningHorizon, double defaultMaximumBacklog)
Initializes a backlog constraint and assigns the same maximum backlog level to every planning period.
BacklogConstraint(int planningHorizon)
Initializes a backlog constraint for the specified planning horizon.
DoubleTimeSeries MaximumBacklogByPeriod
Gets the complete maximum-backlog time series.
override void ValidateValue(double value, string parameterName)
Validates a maximum-backlog value.
double GetMaximumBacklog(int period)
Gets the maximum backlog allowed during a planning period.
void SetMaximumBacklog(int period, double maximumBacklog)
Sets the maximum backlog allowed during 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.