-
Notifications
You must be signed in to change notification settings - Fork 5
/
LoadProfileInput.java
82 lines (70 loc) · 2.49 KB
/
LoadProfileInput.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
/*
* © 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.timeseries.repetitive;
import static java.time.temporal.ChronoUnit.HOURS;
import edu.ie3.datamodel.models.profile.StandardLoadProfile;
import edu.ie3.datamodel.models.value.PValue;
import java.time.DayOfWeek;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.stream.Collectors;
// TODO This is a sample implementation, please implement a real scenario
public class LoadProfileInput extends RepetitiveTimeSeries<LoadProfileEntry, PValue> {
private final StandardLoadProfile type;
private final Map<DayOfWeek, Map<Integer, PValue>> dayOfWeekToHourlyValues;
public LoadProfileInput(UUID uuid, StandardLoadProfile type, Set<LoadProfileEntry> values) {
super(uuid, values);
this.type = type;
this.dayOfWeekToHourlyValues =
getEntries().stream()
.collect(
Collectors.groupingBy(
LoadProfileEntry::getDayOfWeek,
Collectors.toMap(
LoadProfileEntry::getQuarterHourOfDay, LoadProfileEntry::getValue)));
}
public LoadProfileInput(StandardLoadProfile type, Set<LoadProfileEntry> values) {
this(UUID.randomUUID(), type, values);
}
@Override
public PValue calc(ZonedDateTime time) {
return dayOfWeekToHourlyValues.get(time.getDayOfWeek()).get(time.getHour());
}
@Override
protected Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time) {
return Optional.of(time.minus(1, HOURS));
}
@Override
protected Optional<ZonedDateTime> getNextDateTime(ZonedDateTime time) {
return Optional.of(time.plus(1, HOURS));
}
public StandardLoadProfile getType() {
return type;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
LoadProfileInput that = (LoadProfileInput) o;
return type.equals(that.type) && dayOfWeekToHourlyValues.equals(that.dayOfWeekToHourlyValues);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), type, dayOfWeekToHourlyValues);
}
@Override
public String toString() {
return "LoadProfileInput{"
+ "uuid="
+ getUuid()
+ ", type="
+ type
+ ", dayOfWeekToHourlyValues="
+ dayOfWeekToHourlyValues
+ '}';
}
}