LotSizingDataModel.Solution 2.0.1
Solution objects for production, setup, inventory and related decisions.
Loading...
Searching...
No Matches
LotSizingSolution.Financial.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using System.Xml.Serialization;
5
7
8/// <summary>
9/// Adds normalized financial execution traces to a solution.
10/// </summary>
11public sealed partial class LotSizingSolution
12{
13 [XmlArray("cashBalances")]
14 [XmlArrayItem("cashBalance")]
15 public List<CashBalancePoint> CashBalances
16 {
17 get;
18 } = new();
19
20 public void SetCashBalance(
21 int period,
22 double balance)
23 {
24 CashBalancePoint? existing =
25 CashBalances.SingleOrDefault(
26 point =>
27 point.Period == period);
28
29 if (existing is null)
30 {
31 CashBalances.Add(
33 {
34 Period = period,
35 Balance = balance
36 });
37
38 return;
39 }
40
41 existing.Balance = balance;
42 }
43
44 public bool TryGetCashBalance(
45 int period,
46 out double balance)
47 {
48 CashBalancePoint? existing =
49 CashBalances.SingleOrDefault(
50 point =>
51 point.Period == period);
52
53 if (existing is null)
54 {
55 balance = 0.0;
56 return false;
57 }
58
59 balance = existing.Balance;
60 return true;
61 }
62}
Represents one candidate solution for a lot-sizing supply-chain instance.
bool TryGetCashBalance(int period, out double balance)