2using System.ComponentModel;
4using System.Xml.Serialization;
5using LotSizingDataModel.Core.Common;
6using LotSizingDataModel.Core.PhysicalModel;
21[XmlType(TypeName =
"warehouseCapacityDecision")]
26 private WarehouseReference _warehouse =
29 private IntegerTimeSeries _activations =
32 private DoubleTimeSeries _additionalCapacityUsed =
44 SubscribeToObject(_warehouse);
45 SubscribeToObject(_activations);
46 SubscribeToObject(_additionalCapacityUsed);
60 WarehouseReference warehouse,
64 ArgumentNullException.ThrowIfNull(warehouse);
66 if (warehouse.ReferenceId <= 0)
68 throw new ArgumentException(
69 "The warehouse reference identifier must be " +
74 if (planningHorizon <= 0)
76 throw new ArgumentOutOfRangeException(
77 nameof(planningHorizon),
79 "The planning horizon must be strictly positive.");
91 [XmlElement(
"warehouse")]
97 ArgumentNullException.ThrowIfNull(value);
106 UnsubscribeFromObject(_warehouse);
112 SubscribeToObject(_warehouse);
114 NotifyDerivedProperties();
129 [XmlElement(
"activations")]
135 ArgumentNullException.ThrowIfNull(value);
144 UnsubscribeFromObject(_activations);
150 SubscribeToObject(_activations);
152 NotifyDerivedProperties();
167 [XmlElement(
"additionalCapacityUsed")]
170 get => _additionalCapacityUsed;
173 ArgumentNullException.ThrowIfNull(value);
176 _additionalCapacityUsed,
182 UnsubscribeFromObject(
183 _additionalCapacityUsed);
186 ref _additionalCapacityUsed,
190 _additionalCapacityUsed);
192 NotifyDerivedProperties();
210 AdditionalCapacityUsed.PeriodCount ==
219 Warehouse.ReferenceId > 0;
229 activation is 0 or 1);
239 double.IsFinite(capacity) &&
324 if (!
double.IsFinite(capacity) ||
327 throw new ArgumentOutOfRangeException(
330 "The additional capacity must be finite " +
331 "and non-negative.");
350 WarehouseReference warehouse)
352 ArgumentNullException.ThrowIfNull(warehouse);
354 return SameWarehouse(
374 throw new ArgumentOutOfRangeException(
377 "The period count cannot be negative.");
388 NotifyDerivedProperties();
400 NotifyDerivedProperties();
406 int activatedPeriodCount =
411 double totalAdditionalCapacity =
415 $
"Warehouse {Warehouse.Kind}:" +
416 $
"{Warehouse.ReferenceId}: " +
417 $
"activated periods {activatedPeriodCount}; " +
418 $
"additional capacity " +
419 $
"{totalAdditionalCapacity}";
422 private void SubscribeToObject(
423 ModelObject modelObject)
425 modelObject.PropertyChanged +=
426 OnNestedPropertyChanged;
429 private void UnsubscribeFromObject(
430 ModelObject modelObject)
432 modelObject.PropertyChanged -=
433 OnNestedPropertyChanged;
436 private void OnNestedPropertyChanged(
438 PropertyChangedEventArgs eventArgs)
440 NotifyDerivedProperties();
443 private void NotifyDerivedProperties()
464 private static bool SameWarehouse(
465 WarehouseReference first,
466 WarehouseReference second)
WarehouseCapacityDecision()
Initializes an empty warehouse-capacity decision.
IntegerTimeSeries Activations
Gets or sets the binary global warehouse activation decisions.
void Clear()
Resets every warehouse-capacity decision value to zero.
WarehouseCapacityDecision(WarehouseReference warehouse, int planningHorizon)
Initializes a capacity decision for a warehouse and a planning horizon.
WarehouseReference Warehouse
Gets or sets the warehouse associated with the capacity decision.
bool IsInternallyValid
Gets a value indicating whether the warehouse-capacity decision is internally consistent.
bool HasConsistentPlanningHorizon
Gets a value indicating whether every decision series uses the same planning horizon.
bool IsActivated(int period)
Determines whether the warehouse is activated during a planning period.
bool HasValidActivationValues
Gets a value indicating whether every activation value is equal to zero or one.
bool HasValidWarehouseReference
Gets a value indicating whether the warehouse reference is initialized.
override string ToString()
bool HasValidAdditionalCapacityValues
Gets a value indicating whether every additional-capacity value is finite and non-negative.
DoubleTimeSeries AdditionalCapacityUsed
Gets or sets the global additional capacity used by the warehouse during each planning period.
int PlanningHorizon
Gets the number of planning periods represented by the activation series.
double GetAdditionalCapacityUsed(int period)
Gets the global additional warehouse capacity used during a planning period.
bool Matches(WarehouseReference warehouse)
Determines whether this decision refers to the specified warehouse.
void SetActivated(int period, bool isActivated)
Sets the global warehouse activation decision for a planning period.
void ResizeTimeSeries(int periodCount)
Resizes every decision series to the specified planning horizon.
void SetAdditionalCapacityUsed(int period, double capacity)
Sets the global additional warehouse capacity used during a planning period.