2using System.ComponentModel;
4using System.Xml.Serialization;
20[XmlType(TypeName =
"doubleTimeSeriesParameter")]
36 SubscribeToValues(_values);
51 double defaultValue = 0.0)
70 [XmlElement(
"values")]
84 if (ReferenceEquals(_values, newValue))
90 UnsubscribeFromValues(_values);
95 SubscribeToValues(_values);
123 public double this[
int period]
149 this[period] = value;
173 throw new ArgumentOutOfRangeException(
176 "The planning horizon cannot be negative.");
208 string parameterName)
211 if (
double.IsNaN(value) ||
212 double.IsInfinity(value))
214 throw new ArgumentOutOfRangeException(
217 "A period-dependent value must be finite.");
228 ArgumentNullException.ThrowIfNull(values);
231 foreach (
double value
in values)
240 private void SubscribeToValues(
244 values.PropertyChanged +=
245 OnValuesPropertyChanged;
251 private void UnsubscribeFromValues(
255 values.PropertyChanged -=
256 OnValuesPropertyChanged;
263 private void OnValuesPropertyChanged(
265 PropertyChangedEventArgs e)
271 if (e.PropertyName ==
Represents a sequence of finite double values indexed by planning period.
double[] Values
Gets or replaces all values of the time series.
int PeriodCount
Gets the number of periods currently represented.
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.
void ResizeTimeSeries(int periodCount)
Resizes the time series when the planning horizon changes.
void Fill(double value)
Assigns the same value to every planning period.
DoubleTimeSeriesParameter()
Initializes an empty period-dependent parameter.
double GetValue(int period)
Gets the parameter value for a planning period.
DoubleTimeSeries Values
Gets or sets the values of the parameter for all planning periods.
void SetValue(int period, double value)
Sets the parameter value for a planning period.
int PlanningHorizon
Gets the number of planning periods currently represented by this parameter.
virtual void ValidateValue(double value, string parameterName)
Validates one value before it is assigned to the parameter.
void ValidateSeries(DoubleTimeSeries values)
Validates all values contained in a time series.
virtual double DefaultValueForNewPeriods
Gets the value assigned to periods created when the planning horizon grows.
DoubleTimeSeriesParameter(int planningHorizon, double defaultValue=0.0)
Initializes a period-dependent parameter with the specified planning horizon.
Defines a model object containing data indexed by planning period.