2using System.ComponentModel;
4using System.Xml.Serialization;
5using LotSizingDataModel.Core.Common;
6using LotSizingDataModel.Core.PhysicalModel;
25[XmlType(TypeName =
"workCenterCapacityDecision")]
30 private WorkCenterReference _workCenter =
33 private IntegerTimeSeries _activations =
36 private DoubleTimeSeries _additionalCapacityUsed =
48 SubscribeToObject(_workCenter);
49 SubscribeToObject(_activations);
50 SubscribeToObject(_additionalCapacityUsed);
64 WorkCenterReference workCenter,
68 ArgumentNullException.ThrowIfNull(workCenter);
70 if (workCenter.PlantId <= 0)
72 throw new ArgumentException(
73 "The plant identifier must be strictly positive.",
77 if (workCenter.WorkCenterId <= 0)
79 throw new ArgumentException(
80 "The work-center identifier must be " +
85 if (planningHorizon <= 0)
87 throw new ArgumentOutOfRangeException(
88 nameof(planningHorizon),
90 "The planning horizon must be strictly positive.");
102 [XmlElement(
"workCenter")]
108 ArgumentNullException.ThrowIfNull(value);
117 UnsubscribeFromObject(_workCenter);
123 SubscribeToObject(_workCenter);
125 NotifyDerivedProperties();
142 [XmlElement(
"activations")]
148 ArgumentNullException.ThrowIfNull(value);
157 UnsubscribeFromObject(_activations);
163 SubscribeToObject(_activations);
165 NotifyDerivedProperties();
180 [XmlElement(
"additionalCapacityUsed")]
183 get => _additionalCapacityUsed;
186 ArgumentNullException.ThrowIfNull(value);
189 _additionalCapacityUsed,
195 UnsubscribeFromObject(
196 _additionalCapacityUsed);
199 ref _additionalCapacityUsed,
203 _additionalCapacityUsed);
205 NotifyDerivedProperties();
223 AdditionalCapacityUsed.PeriodCount ==
232 WorkCenter.PlantId > 0 &&
233 WorkCenter.WorkCenterId > 0;
243 activation is 0 or 1);
253 double.IsFinite(capacity) &&
339 if (!
double.IsFinite(capacity) ||
342 throw new ArgumentOutOfRangeException(
345 "The additional capacity must be finite " +
346 "and non-negative.");
365 WorkCenterReference workCenter)
367 ArgumentNullException.ThrowIfNull(workCenter);
369 return WorkCenter.PlantId ==
370 workCenter.PlantId &&
371 WorkCenter.WorkCenterId ==
372 workCenter.WorkCenterId;
390 throw new ArgumentOutOfRangeException(
393 "The period count cannot be negative.");
404 NotifyDerivedProperties();
416 NotifyDerivedProperties();
422 int activatedPeriodCount =
427 double totalAdditionalCapacity =
431 $
"Work center {WorkCenter}: " +
432 $
"activated periods {activatedPeriodCount}; " +
433 $
"additional capacity " +
434 $
"{totalAdditionalCapacity}";
437 private void SubscribeToObject(
438 ModelObject modelObject)
440 modelObject.PropertyChanged +=
441 OnNestedPropertyChanged;
444 private void UnsubscribeFromObject(
445 ModelObject modelObject)
447 modelObject.PropertyChanged -=
448 OnNestedPropertyChanged;
451 private void OnNestedPropertyChanged(
453 PropertyChangedEventArgs eventArgs)
455 NotifyDerivedProperties();
458 private void NotifyDerivedProperties()
bool Matches(WorkCenterReference workCenter)
Determines whether this decision refers to the specified work center.
WorkCenterCapacityDecision(WorkCenterReference workCenter, int planningHorizon)
Initializes a capacity decision for a work center and a planning horizon.
void Clear()
Resets every work-center capacity decision value to zero.
int PlanningHorizon
Gets the number of planning periods represented by the activation series.
void ResizeTimeSeries(int periodCount)
Resizes every decision series to the specified planning horizon.
bool HasConsistentPlanningHorizon
Gets a value indicating whether every decision series uses the same planning horizon.
WorkCenterReference WorkCenter
Gets or sets the reference to the work center associated with the capacity decision.
override string ToString()
void SetAdditionalCapacityUsed(int period, double capacity)
Sets the global additional capacity used during a planning period.
bool HasValidAdditionalCapacityValues
Gets a value indicating whether every additional-capacity value is finite and non-negative.
bool HasValidActivationValues
Gets a value indicating whether every activation value is equal to zero or one.
double GetAdditionalCapacityUsed(int period)
Gets the global additional capacity used during a planning period.
bool IsInternallyValid
Gets a value indicating whether the work-center capacity decision is internally consistent.
bool HasValidWorkCenterReference
Gets a value indicating whether the work-center reference is initialized.
bool IsActivated(int period)
Determines whether the work center is activated during a planning period.
void SetActivated(int period, bool isActivated)
Sets the global work-center activation decision for a planning period.
IntegerTimeSeries Activations
Gets or sets the binary global work-center activation decisions.
WorkCenterCapacityDecision()
Initializes an empty work-center capacity decision.
DoubleTimeSeries AdditionalCapacityUsed
Gets or sets the global additional capacity used by the work center during each planning period.