LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
CashFlowPolicy.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Defines cash-flow timing and solvency semantics independently of OPEX budget.
9/// </summary>
10/// <remarks>
11/// Economic objective coefficients remain the source of decision-dependent
12/// receipts/disbursements. Positive economic coefficients are disbursements;
13/// negative coefficients are receipts. Fixed net cash flows are represented
14/// separately and may be positive or negative.
15/// </remarks>
16[Serializable]
17[XmlType(TypeName = "cashFlowPolicy")]
18public sealed class CashFlowPolicy :
21{
22 private double _initialCashBalance;
23 private int _receiptDelayPeriods;
24 private int _disbursementDelayPeriods;
25 private bool _enforceMinimumCashBalance = true;
26
27 private DoubleTimeSeries _fixedNetCashFlow = new();
28 private DoubleTimeSeries _minimumCashBalance = new();
29
30 [XmlAttribute("initialCashBalance")]
31 public double InitialCashBalance
32 {
33 get => _initialCashBalance;
34 set
35 {
36 EnsureFinite(value, nameof(value));
37 SetProperty(ref _initialCashBalance, value);
38 }
39 }
40
41 [XmlAttribute("receiptDelayPeriods")]
43 {
44 get => _receiptDelayPeriods;
45 set
46 {
47 if (value < 0)
48 {
49 throw new ArgumentOutOfRangeException(nameof(value));
50 }
51
52 SetProperty(ref _receiptDelayPeriods, value);
53 }
54 }
55
56 [XmlAttribute("disbursementDelayPeriods")]
58 {
59 get => _disbursementDelayPeriods;
60 set
61 {
62 if (value < 0)
63 {
64 throw new ArgumentOutOfRangeException(nameof(value));
65 }
66
67 SetProperty(ref _disbursementDelayPeriods, value);
68 }
69 }
70
71 [XmlAttribute("enforceMinimumCashBalance")]
73 {
74 get => _enforceMinimumCashBalance;
75 set => SetProperty(ref _enforceMinimumCashBalance, value);
76 }
77
78 [XmlElement("fixedNetCashFlow")]
80 {
81 get => _fixedNetCashFlow;
82 set
83 {
84 ArgumentNullException.ThrowIfNull(value);
85 SetProperty(ref _fixedNetCashFlow, value);
86 }
87 }
88
89 [XmlElement("minimumCashBalance")]
91 {
92 get => _minimumCashBalance;
93 set
94 {
95 ArgumentNullException.ThrowIfNull(value);
96 SetProperty(ref _minimumCashBalance, value);
97 }
98 }
99
100 [XmlIgnore]
101 public int PlanningHorizon =>
102 Math.Max(
103 FixedNetCashFlow.PeriodCount,
104 MinimumCashBalance.PeriodCount);
105
106 [XmlIgnore]
108 FixedNetCashFlow.PeriodCount ==
109 MinimumCashBalance.PeriodCount;
110
111 public void ResizeTimeSeries(int periodCount)
112 {
113 if (periodCount < 0)
114 {
115 throw new ArgumentOutOfRangeException(nameof(periodCount));
116 }
117
118 FixedNetCashFlow.Resize(periodCount, 0.0);
119 MinimumCashBalance.Resize(periodCount, 0.0);
120
123 }
124
125 private static void EnsureFinite(
126 double value,
127 string parameterName)
128 {
129 if (!double.IsFinite(value))
130 {
131 throw new ArgumentOutOfRangeException(
132 parameterName,
133 value,
134 "Cash values must be finite.");
135 }
136 }
137}
Represents a sequence of finite double values indexed by planning period.
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.
Defines cash-flow timing and solvency semantics independently of OPEX budget.
int PlanningHorizon
Gets the number of planning periods currently represented by the object's time-dependent data.
void ResizeTimeSeries(int periodCount)
Resizes every time-dependent series contained in the object.
Defines a model object containing data indexed by planning period.