2using System.ComponentModel;
4using System.Xml.Serialization;
5using LotSizingDataModel.Core.Common;
21[XmlType(TypeName =
"transportResourceCapacityDecision")]
26 private int _transportResourceId;
28 private IntegerTimeSeries _activations =
31 private DoubleTimeSeries _additionalCapacityUsed =
43 SubscribeToObject(_activations);
44 SubscribeToObject(_additionalCapacityUsed);
58 int transportResourceId,
62 if (transportResourceId <= 0)
64 throw new ArgumentOutOfRangeException(
65 nameof(transportResourceId),
67 "The transport-resource identifier must be " +
68 "strictly positive.");
71 if (planningHorizon <= 0)
73 throw new ArgumentOutOfRangeException(
74 nameof(planningHorizon),
76 "The planning horizon must be strictly positive.");
89 [XmlAttribute(
"transportResourceId")]
92 get => _transportResourceId;
102 throw new ArgumentOutOfRangeException(
105 "The transport-resource identifier " +
106 "cannot be negative.");
110 ref _transportResourceId,
126 [XmlElement(
"activations")]
132 ArgumentNullException.ThrowIfNull(value);
141 UnsubscribeFromObject(_activations);
147 SubscribeToObject(_activations);
149 NotifyDerivedProperties();
164 [XmlElement(
"additionalCapacityUsed")]
167 get => _additionalCapacityUsed;
170 ArgumentNullException.ThrowIfNull(value);
173 _additionalCapacityUsed,
179 UnsubscribeFromObject(
180 _additionalCapacityUsed);
183 ref _additionalCapacityUsed,
187 _additionalCapacityUsed);
189 NotifyDerivedProperties();
207 AdditionalCapacityUsed.PeriodCount ==
218 activation is 0 or 1);
228 double.IsFinite(capacity) &&
313 if (!
double.IsFinite(capacity) ||
316 throw new ArgumentOutOfRangeException(
319 "The additional capacity must be finite " +
320 "and non-negative.");
338 int transportResourceId)
359 throw new ArgumentOutOfRangeException(
362 "The period count cannot be negative.");
373 NotifyDerivedProperties();
385 NotifyDerivedProperties();
391 int activatedPeriodCount =
396 double totalAdditionalCapacity =
400 $
"Transport resource {TransportResourceId}: " +
401 $
"activated periods {activatedPeriodCount}; " +
402 $
"additional capacity " +
403 $
"{totalAdditionalCapacity}";
406 private void SubscribeToObject(
407 ModelObject modelObject)
409 modelObject.PropertyChanged +=
410 OnNestedPropertyChanged;
413 private void UnsubscribeFromObject(
414 ModelObject modelObject)
416 modelObject.PropertyChanged -=
417 OnNestedPropertyChanged;
420 private void OnNestedPropertyChanged(
422 PropertyChangedEventArgs eventArgs)
424 NotifyDerivedProperties();
427 private void NotifyDerivedProperties()
bool HasValidActivationValues
Gets a value indicating whether every activation value is equal to zero or one.
IntegerTimeSeries Activations
Gets or sets the binary global transport-resource activation decisions.
TransportResourceCapacityDecision(int transportResourceId, int planningHorizon)
Initializes a capacity decision for a transport resource and a planning horizon.
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.
void SetActivated(int period, bool isActivated)
Sets the global transport-resource activation decision for a planning period.
int PlanningHorizon
Gets the number of planning periods represented by the activation series.
double GetAdditionalCapacityUsed(int period)
Gets the global additional transport capacity used during a planning period.
bool IsInternallyValid
Gets a value indicating whether the transport-resource capacity decision is internally consistent.
DoubleTimeSeries AdditionalCapacityUsed
Gets or sets the global additional capacity used by the transport resource during each planning perio...
int TransportResourceId
Gets or sets the identifier of the transport resource associated with the capacity decision.
void Clear()
Resets every transport-resource capacity decision value to zero.
override string ToString()
TransportResourceCapacityDecision()
Initializes an empty transport-resource capacity decision.
void SetAdditionalCapacityUsed(int period, double capacity)
Sets the global additional transport capacity used during a planning period.
bool HasValidAdditionalCapacityValues
Gets a value indicating whether every additional-capacity value is finite and non-negative.
bool IsActivated(int period)
Determines whether the transport resource is activated during a planning period.
bool Matches(int transportResourceId)
Determines whether this decision refers to the specified transport resource.