LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
SellingPrice.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
5
7
8/// <summary>
9/// Represents the unit selling price of an item supplied
10/// to a distribution center during each planning period.
11///
12/// In the complete model, the selling price depends on:
13/// - the distribution center;
14/// - the supplying warehouse;
15/// - the item;
16/// - the planning period.
17///
18/// Corresponds to the UML class "Prix Vente".
19/// Its values correspond to PV[t] in the knowledge model.
20/// </summary>
21[Serializable]
22[XmlType(TypeName = "sellingPrice")]
23public sealed class SellingPrice :
25{
26 /// <summary>
27 /// Initializes an empty selling-price parameter.
28 ///
29 /// This public parameterless constructor is required
30 /// by <see cref="XmlSerializer"/>.
31 /// </summary>
32 public SellingPrice()
33 {
34 }
35
36 /// <summary>
37 /// Initializes a selling-price parameter for the specified
38 /// planning horizon.
39 ///
40 /// Every planning period is initially assigned
41 /// a selling price of zero.
42 /// </summary>
43 /// <param name="planningHorizon">
44 /// Number of periods in the planning horizon.
45 /// </param>
46 public SellingPrice(int planningHorizon)
47 : base(
48 planningHorizon,
49 defaultValue: 0.0) // Initialize all periods with zero selling price
50 {
51 }
52
53 /// <summary>
54 /// Initializes a selling-price parameter and assigns
55 /// the same unit price to every planning period.
56 /// </summary>
57 /// <param name="planningHorizon">
58 /// Number of periods in the planning horizon.
59 /// </param>
60 /// <param name="defaultUnitSellingPrice">
61 /// Unit selling price initially assigned to every period.
62 /// </param>
64 int planningHorizon,
65 double defaultUnitSellingPrice)
66 : base(
67 planningHorizon,
68 defaultUnitSellingPrice) // Initialize all periods with the specified unit selling price
69 {
70 }
71
72 /// <summary>
73 /// Gets the complete unit-selling-price time series.
74 ///
75 /// This property is an alias for <see cref="LotSizingDataModel.Core.DecisionModel.DoubleTimeSeriesParameter.Values"/>
76 /// and is not serialized separately.
77 /// </summary>
78 [XmlIgnore]
80 Values;
81
82 /// <summary>
83 /// Gets the unit selling price for a planning period.
84 /// </summary>
85 /// <param name="period">
86 /// One-based planning-period number.
87 /// </param>
88 public double GetUnitSellingPrice(int period)
89 {
90 return GetValue(period);
91 }
92
93 /// <summary>
94 /// Sets the unit selling price for a planning period.
95 /// </summary>
96 /// <param name="period">
97 /// One-based planning-period number.
98 /// </param>
99 /// <param name="price">
100 /// Non-negative finite unit selling price.
101 /// </param>
103 int period,
104 double price)
105 {
106 SetValue(period, price);
107 }
108
109 /// <summary>
110 /// Validates a unit selling price.
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 selling price is non-negative
120 if (value < 0.0)
121 {
122 throw new ArgumentOutOfRangeException(
123 parameterName,
124 value,
125 "A unit selling price cannot be negative.");
126 }
127 }
128}
Represents a sequence of finite double values indexed by planning period.
DoubleTimeSeries UnitSellingPriceByPeriod
Gets the complete unit-selling-price time series.
double GetUnitSellingPrice(int period)
Gets the unit selling price for a planning period.
SellingPrice(int planningHorizon)
Initializes a selling-price parameter for the specified planning horizon.
SellingPrice()
Initializes an empty selling-price parameter.
SellingPrice(int planningHorizon, double defaultUnitSellingPrice)
Initializes a selling-price parameter and assigns the same unit price to every planning period.
void SetUnitSellingPrice(int period, double price)
Sets the unit selling price for a planning period.
override void ValidateValue(double value, string parameterName)
Validates a unit selling price.
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.