LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
UniversalNotationRenderer.cs
Go to the documentation of this file.
2
4
5/// <summary>
6/// Renders the canonical text form of notation scheme version 1.
7/// </summary>
8public static class UniversalNotationRenderer
9{
10 public static string Render(
12 {
13 ArgumentNullException.ThrowIfNull(notation);
14
15 return
16 $"{RenderAlpha(notation.Alpha)} | " +
17 $"{RenderBeta(notation.Beta)} | " +
18 $"{RenderGamma(notation.Gamma)}";
19 }
20
21 private static string RenderAlpha(
23 {
24 string cardinality =
25 alpha.ItemCardinality switch
26 {
29 _ => "?"
30 };
31
32 string productStructure =
33 alpha.ProblemLevel switch
34 {
35 UniversalProblemLevel.SingleLevel => "SL",
36 UniversalProblemLevel.MultiLevel =>
37 "ML:" +
38 UniversalNotationTokenCatalog
39 .GetProductStructureCode(
41 _ => "Level:?"
42 };
43
44 return string.Join(
45 ",",
46 new[]
47 {
48 cardinality,
49 productStructure,
50 RenderNetwork(alpha.Network)
51 });
52 }
53
54 private static string RenderNetwork(
55 UniversalNetworkNotation network)
56 {
57 string core =
58 network.Coupling switch
59 {
60 NetworkCouplingType.ForwardOnly =>
61 "Net:" +
62 UniversalNotationTokenCatalog
63 .GetNetworkTopologyCode(
64 network.ForwardTopology),
65
66 NetworkCouplingType.ReverseOnly =>
67 "Net:R:" +
68 UniversalNotationTokenCatalog
69 .GetNetworkTopologyCode(
70 network.ReverseTopology ??
72
73 NetworkCouplingType.ClosedLoop =>
74 "Net:CL(F:" +
75 UniversalNotationTokenCatalog
76 .GetNetworkTopologyCode(
77 network.ForwardTopology) +
78 ";R:" +
79 UniversalNotationTokenCatalog
80 .GetNetworkTopologyCode(
81 network.ReverseTopology ??
83 ")",
84
85 _ => throw new ArgumentOutOfRangeException(
86 nameof(network),
87 network.Coupling,
88 "Unknown network coupling type.")
89 };
90
91 var modifiers = new List<string>();
92
93 if (network.EchelonCount.HasValue)
94 {
95 modifiers.Add($"E{network.EchelonCount.Value}");
96 }
97
98 if (network.HasCycles)
99 {
100 modifiers.Add("CY");
101 }
102
103 if (network.HasMultiSourcing)
104 {
105 modifiers.Add("MS");
106 }
107
108 if (network.HasTransshipment)
109 {
110 modifiers.Add("TS");
111 }
112
113 return modifiers.Count == 0
114 ? core
115 : core + ":" + string.Join(":", modifiers);
116 }
117
118 private static string RenderBeta(
119 UniversalNotationBeta beta)
120 {
121 var tokens =
122 new List<string>();
123
124 tokens.AddRange(
125 beta.Features
126 .OrderBy(feature => (int)feature)
127 .Select(
128 UniversalNotationTokenCatalog.GetFeatureToken));
129
130 tokens.AddRange(
131 beta.SemanticConditions
132 .OrderBy(condition => (int)condition)
133 .Select(
134 UniversalNotationTokenCatalog
135 .GetSemanticConditionToken));
136
137 tokens.AddRange(
138 beta.TemporalQualifiers
139 .OrderBy(
140 qualifier =>
141 (int)qualifier.Parameter)
142 .Select(
143 UniversalNotationTokenCatalog
144 .GetTemporalQualifierToken));
145
146 return tokens.Count == 0
147 ? "None"
148 : string.Join(",", tokens);
149 }
150
151 private static string RenderGamma(
152 UniversalNotationGamma gamma)
153 {
154 return gamma.Objective switch
155 {
156 UniversalObjectiveKind.Economic => "Obj:Econ",
157 UniversalObjectiveKind.MultipleObjectives => "Obj:Multi",
158 UniversalObjectiveKind.Financial => "Obj:Fin",
159 UniversalObjectiveKind.Sustainability => "Obj:Sust",
160 UniversalObjectiveKind.ServiceLevel => "Obj:Service",
161 _ => "Obj:?"
162 };
163 }
164}
Typed abstract syntax tree for the versioned alpha | beta | gamma scheme.
Alpha field: structural/environment characteristics.
Renders the canonical text form of notation scheme version 1.
static string Render(UniversalLotSizingNotation notation)
SupplyNetworkTopologyType
Classifies the directed physical topology of a supply-flow network.