2using System.ComponentModel;
3using System.Xml.Serialization;
19[XmlType(TypeName =
"integerTimeSeriesParameter")]
35 SubscribeToValues(_values);
53 if (planningHorizon < 0)
55 throw new ArgumentOutOfRangeException(
56 nameof(planningHorizon),
58 "The planning horizon cannot be negative.");
73 [XmlElement(
"values")]
87 if (ReferenceEquals(_values, newValue))
93 UnsubscribeFromValues(_values);
98 SubscribeToValues(_values);
120 public int this[
int period]
146 this[period] = value;
170 throw new ArgumentOutOfRangeException(
173 "The planning horizon cannot be negative.");
197 string parameterName)
211 ArgumentNullException.ThrowIfNull(values);
214 foreach (
int value
in values)
223 private void SubscribeToValues(
227 values.PropertyChanged +=
228 OnValuesPropertyChanged;
234 private void UnsubscribeFromValues(
238 values.PropertyChanged -=
239 OnValuesPropertyChanged;
246 private void OnValuesPropertyChanged(
248 PropertyChangedEventArgs e)
254 if (e.PropertyName ==
Represents a sequence of integer values indexed by planning period.
int PeriodCount
Gets the number of planning periods represented by this time series.
int[] Values
Gets or replaces all values of the time series.
Base class for model objects that notify listeners when one of their properties changes.
virtual void OnPropertyChanged([CallerMemberName] string? propertyName=null)
Raises the PropertyChanged event.
int GetValue(int period)
Gets the parameter value for a planning period.
int PlanningHorizon
Gets the number of planning periods represented by this parameter.
void Fill(int value)
Assigns the same value to every planning period.
void ValidateSeries(IntegerTimeSeries values)
Validates every value contained in a time series.
void ResizeTimeSeries(int periodCount)
Resizes the time series when the planning horizon changes.
IntegerTimeSeriesParameter()
Initializes an empty period-dependent integer parameter.
IntegerTimeSeriesParameter(int planningHorizon, int defaultValue=0)
Initializes a period-dependent integer parameter.
void SetValue(int period, int value)
Sets the parameter value for a planning period.
IntegerTimeSeries Values
Gets or sets the parameter values for all planning periods.
virtual void ValidateValue(int value, string parameterName)
Validates one integer value.
virtual int DefaultValueForNewPeriods
Gets the value assigned to newly created periods when the planning horizon grows.
Defines a model object containing data indexed by planning period.