-
Notifications
You must be signed in to change notification settings - Fork 7
Added abstraction for power value sources. #1439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
cdb4e23
f2419e8
7122abb
bd4e443
651fa76
f731029
e359480
2abbd59
1155374
48a4ec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* © 2025. TU Dortmund University, | ||
* Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
* Research group Distribution grid planning and operation | ||
*/ | ||
package edu.ie3.datamodel.io.source; | ||
|
||
import edu.ie3.datamodel.models.profile.LoadProfile; | ||
import edu.ie3.datamodel.models.profile.PowerProfile; | ||
import edu.ie3.datamodel.models.value.PValue; | ||
import java.time.ZonedDateTime; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
import javax.measure.quantity.Energy; | ||
import javax.measure.quantity.Power; | ||
import tech.units.indriya.ComparableQuantity; | ||
|
||
/** Interface defining base functionality for power value sources. */ | ||
public sealed interface PowerValueSource< | ||
P extends PowerProfile, ID extends PowerValueSource.InputData> | ||
Check notice on line 20 in src/main/java/edu/ie3/datamodel/io/source/PowerValueSource.java
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check out the sonarqube issue |
||
permits PowerValueSource.MarkovBased, PowerValueSource.TimeSeriesBased { | ||
|
||
/** Returns the profile of this source. */ | ||
P getProfile(); | ||
|
||
/** | ||
* Method to get the next power value based on the provided input data. | ||
* | ||
* @param data input data that is used to calculate the next power value. | ||
* @return an option for the power value. | ||
*/ | ||
Optional<PValue> getValue(ID data); | ||
Comment on lines
+26
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this method now becomes obsolete with the addition of |
||
|
||
/** | ||
* Method to get a supplier for the next power value based on the provided input data. Depending | ||
* on the implementation the supplier will either always return the same value or each time a | ||
* random value. To return one constant value please use {@link #getValue(InputData)}. | ||
* | ||
* @param data input data that is used to calculate the next power value. | ||
* @return A supplier for an option on the value at the given time step. | ||
*/ | ||
Supplier<Optional<PValue>> getValueSupplier(ID data); | ||
|
||
/** | ||
* Method to determine the next timestamp for which data is present. | ||
* | ||
* @param time current time | ||
* @return an option for the next timestamp or {@link Optional#empty()} if no timestamp was found. | ||
*/ | ||
Optional<ZonedDateTime> getNextTimeKey(ZonedDateTime time); | ||
|
||
/** Returns the maximal power that can be returned by this source. */ | ||
Optional<ComparableQuantity<Power>> getMaxPower(); | ||
|
||
/** Returns the energy scaling of this power source. */ | ||
Optional<ComparableQuantity<Energy>> getProfileEnergyScaling(); | ||
|
||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | ||
// non-sealed implementations | ||
|
||
/** Interface for time-series-based power value sources. */ | ||
non-sealed interface TimeSeriesBased | ||
extends PowerValueSource<LoadProfile, TimeSeriesInputValue> {} | ||
|
||
/** Interface for markov-chain-based power value sources. */ | ||
non-sealed interface MarkovBased extends PowerValueSource<PowerProfile, InputData> {} | ||
|
||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | ||
// input data | ||
|
||
/** | ||
* Interface for the input data of {@link #getValue(InputData)}. The data is used to determine the | ||
* next power. | ||
*/ | ||
sealed interface InputData permits PowerValueSource.TimeSeriesInputValue { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can think about a different name for the interface here. |
||
/** Returns the timestamp for which a power value is needed. */ | ||
ZonedDateTime getTime(); | ||
} | ||
|
||
/** | ||
* Input data for time-series-based power value sources. | ||
* | ||
* @param time | ||
*/ | ||
record TimeSeriesInputValue(ZonedDateTime time) implements InputData { | ||
@Override | ||
public ZonedDateTime getTime() { | ||
return time; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't do this, especially because the equals method still relies on the super class