-
Notifications
You must be signed in to change notification settings - Fork 5
/
SystemParticipants.java
382 lines (346 loc) · 12.3 KB
/
SystemParticipants.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.container;
import edu.ie3.datamodel.models.input.system.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* Represents the accumulation of system participant elements (BM plants, CHP plants, EVCS, fixed
* feed ins, heat pumps, loads, PV plants, storages, WECs)
*/
public class SystemParticipants implements InputContainer<SystemParticipantInput> {
private final Set<BmInput> bmPlants;
private final Set<ChpInput> chpPlants;
private final Set<EvcsInput> evCS;
private final Set<EvInput> evs;
private final Set<FixedFeedInInput> fixedFeedIns;
private final Set<HpInput> heatPumps;
private final Set<LoadInput> loads;
private final Set<PvInput> pvPlants;
private final Set<StorageInput> storages;
private final Set<WecInput> wecPlants;
private final Set<EmInput> emSystems;
public SystemParticipants(
Set<BmInput> bmPlants,
Set<ChpInput> chpPlants,
Set<EvcsInput> evCS,
Set<EvInput> evs,
Set<FixedFeedInInput> fixedFeedIns,
Set<HpInput> heatPumps,
Set<LoadInput> loads,
Set<PvInput> pvPlants,
Set<StorageInput> storages,
Set<WecInput> wecPlants,
Set<EmInput> emSystems) {
this.bmPlants = bmPlants;
this.chpPlants = chpPlants;
this.evCS = evCS;
this.evs = evs;
this.fixedFeedIns = fixedFeedIns;
this.heatPumps = heatPumps;
this.loads = loads;
this.pvPlants = pvPlants;
this.storages = storages;
this.wecPlants = wecPlants;
this.emSystems = emSystems;
}
/**
* Combine different already existing containers
*
* @param systemParticipants already existing containers
*/
public SystemParticipants(Collection<SystemParticipants> systemParticipants) {
this.bmPlants =
systemParticipants.stream()
.flatMap(participants -> participants.bmPlants.stream())
.collect(Collectors.toSet());
this.chpPlants =
systemParticipants.stream()
.flatMap(participants -> participants.chpPlants.stream())
.collect(Collectors.toSet());
this.evCS =
systemParticipants.stream()
.flatMap(participants -> participants.evCS.stream())
.collect(Collectors.toSet());
this.evs =
systemParticipants.stream()
.flatMap(participants -> participants.evs.stream())
.collect(Collectors.toSet());
this.fixedFeedIns =
systemParticipants.stream()
.flatMap(participants -> participants.fixedFeedIns.stream())
.collect(Collectors.toSet());
this.heatPumps =
systemParticipants.stream()
.flatMap(participants -> participants.heatPumps.stream())
.collect(Collectors.toSet());
this.loads =
systemParticipants.stream()
.flatMap(participants -> participants.loads.stream())
.collect(Collectors.toSet());
this.pvPlants =
systemParticipants.stream()
.flatMap(participants -> participants.pvPlants.stream())
.collect(Collectors.toSet());
this.storages =
systemParticipants.stream()
.flatMap(participants -> participants.storages.stream())
.collect(Collectors.toSet());
this.wecPlants =
systemParticipants.stream()
.flatMap(participants -> participants.wecPlants.stream())
.collect(Collectors.toSet());
this.emSystems =
systemParticipants.stream()
.flatMap(participants -> participants.emSystems.stream())
.collect(Collectors.toSet());
}
/**
* Create an instance based on a list of {@link SystemParticipantInput} entities
*
* @param systemParticipants list of system participants this container instance should be created
* from
*/
public SystemParticipants(List<SystemParticipantInput> systemParticipants) {
/* init sets */
this.bmPlants =
systemParticipants.parallelStream()
.filter(BmInput.class::isInstance)
.map(BmInput.class::cast)
.collect(Collectors.toSet());
this.chpPlants =
systemParticipants.parallelStream()
.filter(ChpInput.class::isInstance)
.map(ChpInput.class::cast)
.collect(Collectors.toSet());
this.evCS =
systemParticipants.parallelStream()
.filter(EvcsInput.class::isInstance)
.map(EvcsInput.class::cast)
.collect(Collectors.toSet());
this.evs =
systemParticipants.parallelStream()
.filter(EvInput.class::isInstance)
.map(EvInput.class::cast)
.collect(Collectors.toSet());
this.fixedFeedIns =
systemParticipants.parallelStream()
.filter(FixedFeedInInput.class::isInstance)
.map(FixedFeedInInput.class::cast)
.collect(Collectors.toSet());
this.heatPumps =
systemParticipants.parallelStream()
.filter(HpInput.class::isInstance)
.map(HpInput.class::cast)
.collect(Collectors.toSet());
this.loads =
systemParticipants.parallelStream()
.filter(LoadInput.class::isInstance)
.map(LoadInput.class::cast)
.collect(Collectors.toSet());
this.pvPlants =
systemParticipants.parallelStream()
.filter(PvInput.class::isInstance)
.map(PvInput.class::cast)
.collect(Collectors.toSet());
this.storages =
systemParticipants.parallelStream()
.filter(StorageInput.class::isInstance)
.map(StorageInput.class::cast)
.collect(Collectors.toSet());
this.wecPlants =
systemParticipants.parallelStream()
.filter(WecInput.class::isInstance)
.map(WecInput.class::cast)
.collect(Collectors.toSet());
this.emSystems =
systemParticipants.parallelStream()
.filter(EmInput.class::isInstance)
.map(EmInput.class::cast)
.collect(Collectors.toSet());
}
@Override
public final List<SystemParticipantInput> allEntitiesAsList() {
List<SystemParticipantInput> allEntities = new ArrayList<>();
allEntities.addAll(bmPlants);
allEntities.addAll(chpPlants);
allEntities.addAll(evCS);
allEntities.addAll(evs);
allEntities.addAll(fixedFeedIns);
allEntities.addAll(heatPumps);
allEntities.addAll(loads);
allEntities.addAll(pvPlants);
allEntities.addAll(storages);
allEntities.addAll(wecPlants);
allEntities.addAll(emSystems);
return Collections.unmodifiableList(allEntities);
}
public SystemParticipantsCopyBuilder copy() {
return new SystemParticipantsCopyBuilder(this);
}
/** @return unmodifiable Set of all biomass plants in this grid */
public Set<BmInput> getBmPlants() {
return Collections.unmodifiableSet(bmPlants);
}
/** @return unmodifiable Set of all CHP plants in this grid */
public Set<ChpInput> getChpPlants() {
return Collections.unmodifiableSet(chpPlants);
}
/** @return unmodifiable Set of all ev charging stations in this grid */
public Set<EvcsInput> getEvCS() {
return Collections.unmodifiableSet(evCS);
}
/** @return unmodifiable Set of all electric vehicles in this grid */
public Set<EvInput> getEvs() {
return evs;
}
/** @return unmodifiable Set of all fixed feed in this grid */
public Set<FixedFeedInInput> getFixedFeedIns() {
return Collections.unmodifiableSet(fixedFeedIns);
}
/** @return unmodifiable Set of all heat pumps in this grid */
public Set<HpInput> getHeatPumps() {
return Collections.unmodifiableSet(heatPumps);
}
/** @return unmodifiable Set of all loads in this grid */
public Set<LoadInput> getLoads() {
return Collections.unmodifiableSet(loads);
}
/** @return unmodifiable Set of all PV plants in this grid */
public Set<PvInput> getPvPlants() {
return Collections.unmodifiableSet(pvPlants);
}
/** @return unmodifiable Set of all storages in this grid */
public Set<StorageInput> getStorages() {
return Collections.unmodifiableSet(storages);
}
/** @return unmodifiable Set of all WECs in this grid */
public Set<WecInput> getWecPlants() {
return Collections.unmodifiableSet(wecPlants);
}
public Set<EmInput> getEmSystems() {
return Collections.unmodifiableSet(emSystems);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SystemParticipants that)) return false;
return Objects.equals(bmPlants, that.bmPlants)
&& Objects.equals(chpPlants, that.chpPlants)
&& Objects.equals(evCS, that.evCS)
&& Objects.equals(evs, that.evs)
&& Objects.equals(fixedFeedIns, that.fixedFeedIns)
&& Objects.equals(heatPumps, that.heatPumps)
&& Objects.equals(loads, that.loads)
&& Objects.equals(pvPlants, that.pvPlants)
&& Objects.equals(storages, that.storages)
&& Objects.equals(wecPlants, that.wecPlants);
}
@Override
public int hashCode() {
return Objects.hash(
bmPlants,
chpPlants,
evCS,
evs,
fixedFeedIns,
heatPumps,
loads,
pvPlants,
storages,
wecPlants);
}
public static class SystemParticipantsCopyBuilder
extends InputContainerCopyBuilder<SystemParticipantInput, SystemParticipants> {
private Set<BmInput> bmPlants;
private Set<ChpInput> chpPlants;
private Set<EvcsInput> evCS;
private Set<EvInput> evs;
private Set<FixedFeedInInput> fixedFeedIns;
private Set<HpInput> heatPumps;
private Set<LoadInput> loads;
private Set<PvInput> pvPlants;
private Set<StorageInput> storages;
private Set<WecInput> wecPlants;
private Set<EmInput> emSystems;
protected SystemParticipantsCopyBuilder(SystemParticipants container) {
super(container);
this.bmPlants = container.bmPlants;
this.chpPlants = container.chpPlants;
this.evCS = container.evCS;
this.evs = container.evs;
this.fixedFeedIns = container.fixedFeedIns;
this.heatPumps = container.heatPumps;
this.loads = container.loads;
this.pvPlants = container.pvPlants;
this.storages = container.storages;
this.wecPlants = container.wecPlants;
this.emSystems = container.emSystems;
}
public SystemParticipantsCopyBuilder bmPlants(Set<BmInput> bmPlants) {
this.bmPlants = bmPlants;
return childInstance();
}
public SystemParticipantsCopyBuilder chpPlants(Set<ChpInput> chpPlants) {
this.chpPlants = chpPlants;
return childInstance();
}
public SystemParticipantsCopyBuilder evCS(Set<EvcsInput> evCS) {
this.evCS = evCS;
return childInstance();
}
public SystemParticipantsCopyBuilder evs(Set<EvInput> evs) {
this.evs = evs;
return childInstance();
}
public SystemParticipantsCopyBuilder fixedFeedIn(Set<FixedFeedInInput> fixedFeedIns) {
this.fixedFeedIns = fixedFeedIns;
return childInstance();
}
public SystemParticipantsCopyBuilder heatPumps(Set<HpInput> heatPumps) {
this.heatPumps = heatPumps;
return childInstance();
}
public SystemParticipantsCopyBuilder loads(Set<LoadInput> loads) {
this.loads = loads;
return childInstance();
}
public SystemParticipantsCopyBuilder pvPlants(Set<PvInput> pvPlants) {
this.pvPlants = pvPlants;
return childInstance();
}
public SystemParticipantsCopyBuilder storages(Set<StorageInput> storages) {
this.storages = storages;
return childInstance();
}
public SystemParticipantsCopyBuilder wecPlants(Set<WecInput> wecPlants) {
this.wecPlants = wecPlants;
return childInstance();
}
public SystemParticipantsCopyBuilder emSystems(Set<EmInput> emSystems) {
this.emSystems = emSystems;
return childInstance();
}
public SystemParticipants build() {
return new SystemParticipants(
bmPlants,
chpPlants,
evCS,
evs,
fixedFeedIns,
heatPumps,
loads,
pvPlants,
storages,
wecPlants,
emSystems);
}
@Override
protected SystemParticipantsCopyBuilder childInstance() {
return this;
}
}
}