2using System.ComponentModel;
4using System.Xml.Serialization;
5using LotSizingDataModel.Core.Common;
20[XmlType(TypeName =
"productionDecision")]
25 private int _routingId;
27 private DoubleTimeSeries _quantities =
30 private IntegerTimeSeries _setups =
33 private IntegerTimeSeries _lotMultipleCounts =
45 SubscribeToSeries(_quantities);
46 SubscribeToSeries(_setups);
47 SubscribeToSeries(_lotMultipleCounts);
67 throw new ArgumentOutOfRangeException(
70 "The routing identifier must be strictly positive.");
73 if (planningHorizon <= 0)
75 throw new ArgumentOutOfRangeException(
76 nameof(planningHorizon),
78 "The planning horizon must be strictly positive.");
90 [XmlAttribute(
"routingId")]
103 throw new ArgumentOutOfRangeException(
106 "The routing identifier cannot be negative.");
121 [XmlElement(
"quantities")]
127 ArgumentNullException.ThrowIfNull(value);
136 UnsubscribeFromSeries(_quantities);
142 SubscribeToSeries(_quantities);
144 NotifyDerivedProperties();
154 [XmlElement(
"setups")]
160 ArgumentNullException.ThrowIfNull(value);
169 UnsubscribeFromSeries(_setups);
175 SubscribeToSeries(_setups);
177 NotifyDerivedProperties();
191 [XmlElement(
"lotMultipleCounts")]
194 get => _lotMultipleCounts;
197 ArgumentNullException.ThrowIfNull(value);
206 UnsubscribeFromSeries(
210 ref _lotMultipleCounts,
216 NotifyDerivedProperties();
234 Setups.PeriodCount ==
236 LotMultipleCounts.PeriodCount ==
247 double.IsFinite(quantity) &&
267 count => count >= 0);
313 if (!
double.IsFinite(quantity) ||
316 throw new ArgumentOutOfRangeException(
319 "The production quantity must be finite " +
320 "and non-negative.");
338 return Setups[period] == 1;
389 throw new ArgumentOutOfRangeException(
392 "The lot-multiple count cannot be negative.");
413 throw new ArgumentOutOfRangeException(
416 "The period count cannot be negative.");
431 NotifyDerivedProperties();
443 NotifyDerivedProperties();
449 double totalQuantity =
452 int activatedPeriodCount =
454 setup => setup == 1);
457 $
"Routing {RoutingId}: " +
458 $
"total quantity {totalQuantity}; " +
459 $
"activated periods {activatedPeriodCount}";
462 private void SubscribeToSeries(
465 series.PropertyChanged +=
466 OnSeriesPropertyChanged;
469 private void UnsubscribeFromSeries(
472 series.PropertyChanged -=
473 OnSeriesPropertyChanged;
476 private void OnSeriesPropertyChanged(
478 PropertyChangedEventArgs eventArgs)
480 NotifyDerivedProperties();
483 private void NotifyDerivedProperties()
int GetLotMultipleCount(int period)
Gets the number of lot-size multiples used during a planning period.
IntegerTimeSeries LotMultipleCounts
Gets or sets the number of lot-size multiples used during each planning period.
ProductionDecision(int routingId, int planningHorizon)
Initializes a production decision for a routing and a planning horizon.
bool HasValidQuantities
Gets a value indicating whether every production quantity is finite and non-negative.
int PlanningHorizon
Gets the number of planning periods represented by the production-quantity series.
void SetSetupActivated(int period, bool isActivated)
Sets the production-activation decision for a period.
bool HasValidLotMultipleCounts
Gets a value indicating whether every lot-multiple count is non-negative.
double GetQuantity(int period)
Gets the production quantity for a planning period.
IntegerTimeSeries Setups
Gets or sets the binary routing-activation decisions.
bool IsSetupActivated(int period)
Determines whether production is activated during a planning period.
void Clear()
Resets every production decision value to zero.
ProductionDecision()
Initializes an empty production decision.
bool HasValidSetupValues
Gets a value indicating whether every setup value is equal to zero or one.
void SetLotMultipleCount(int period, int count)
Sets the number of lot-size multiples used during a planning period.
int RoutingId
Gets or sets the identifier of the production routing associated with the decision.
override string ToString()
void SetQuantity(int period, double quantity)
Sets the production quantity for a planning period.
bool IsInternallyValid
Gets a value indicating whether the production decision is internally consistent.
DoubleTimeSeries Quantities
Gets or sets the quantities produced through the routing.
void ResizeTimeSeries(int periodCount)
Resizes every decision series to the specified planning horizon.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all decision series use the same planning horizon.