-
Notifications
You must be signed in to change notification settings - Fork 7
Add impedance weighted graph #441
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
26b6152
Add impedance weighted graph
ckittl 00bd76a
Add tests
ckittl 54c5fd7
Improve JavaDoc
ckittl 5fb6202
Finally fixing JavaDoc
ckittl 44882d4
Mark edge weight setting without quantity as deprecated
ckittl 01b8f26
Fix warnings in readthedocs
ckittl a278d39
Reduce log pollution for tests
ckittl dd2fadc
Addressing reviewers comments
ckittl 2068593
Merge remote-tracking branch 'origin/dev' into ck/#440-impedanceWeigh…
ckittl 1ad7d8e
Fix tests
ckittl 25c28d7
Merge branch 'dev' into ck/#440-impedanceWeightedGraph
ckittl 8493071
Addressing reviewer's comments
ckittl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/edu/ie3/datamodel/graph/ImpedanceWeightedEdge.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * © 2021. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.graph; | ||
|
|
||
| import static tech.units.indriya.unit.Units.OHM; | ||
|
|
||
| import javax.measure.Quantity; | ||
| import javax.measure.Unit; | ||
| import javax.measure.quantity.ElectricResistance; | ||
| import org.jgrapht.graph.DefaultWeightedEdge; | ||
| import tech.units.indriya.quantity.Quantities; | ||
|
|
||
| /** | ||
| * A default implementation for edges in a {@link ImpedanceWeightedGraph}. All access to the weight | ||
| * of an edge must go through the graph interface, which is why this class doesn't expose any public | ||
| * methods. | ||
| * | ||
| * @version 0.1 | ||
| * @since 04.06.20 | ||
| */ | ||
| public class ImpedanceWeightedEdge extends DefaultWeightedEdge { | ||
| private static final long serialVersionUID = -3331046813188425729L; | ||
|
|
||
| protected static final Unit<ElectricResistance> DEFAULT_IMPEDANCE_UNIT = OHM; | ||
|
|
||
| public Quantity<ElectricResistance> getImpedance() { | ||
| return Quantities.getQuantity(getWeight(), DEFAULT_IMPEDANCE_UNIT); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ImpedanceWeightedEdge{" + "impedance=" + getImpedance() + "} " + super.toString(); | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
src/main/java/edu/ie3/datamodel/graph/ImpedanceWeightedGraph.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * © 2021. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.graph; | ||
|
|
||
| import edu.ie3.datamodel.models.input.NodeInput; | ||
| import java.util.function.Supplier; | ||
| import javax.measure.Quantity; | ||
| import javax.measure.quantity.ElectricResistance; | ||
| import org.jgrapht.graph.SimpleWeightedGraph; | ||
| import tech.units.indriya.ComparableQuantity; | ||
|
|
||
| /** An impedance weighted graph that uses {@link ImpedanceWeightedEdge}s as edge type. */ | ||
| public class ImpedanceWeightedGraph extends SimpleWeightedGraph<NodeInput, ImpedanceWeightedEdge> { | ||
|
|
||
| private static final long serialVersionUID = -2797654003980753342L; | ||
|
|
||
| public ImpedanceWeightedGraph() { | ||
| super(ImpedanceWeightedEdge.class); | ||
| } | ||
|
|
||
| public ImpedanceWeightedGraph( | ||
| Supplier<NodeInput> vertexSupplier, Supplier<ImpedanceWeightedEdge> edgeSupplier) { | ||
| super(vertexSupplier, edgeSupplier); | ||
| } | ||
|
|
||
| /** | ||
| * Assigns a {@link Quantity} of type {@link ElectricResistance} to an instance of edge {@link | ||
| * ImpedanceWeightedEdge} | ||
| * | ||
| * @param edge edge whose weight should be altered | ||
| * @param weight the weight of the {@link ImpedanceWeightedEdge} | ||
| */ | ||
| public void setEdgeWeightQuantity( | ||
| ImpedanceWeightedEdge edge, ComparableQuantity<ElectricResistance> weight) { | ||
| double weightDouble = | ||
| weight.to(ImpedanceWeightedEdge.DEFAULT_IMPEDANCE_UNIT).getValue().doubleValue(); | ||
| super.setEdgeWeight(edge, weightDouble); | ||
| } | ||
|
|
||
| /** | ||
| * The only purpose for overriding this method is to provide a better indication of the unit that | ||
| * is expected to be passed in. It is highly advised to use the {@link | ||
| * ImpedanceWeightedGraph#setEdgeWeightQuantity(ImpedanceWeightedEdge, ComparableQuantity)} for | ||
| * safety purposes that the provided edge weight is correct. | ||
| * | ||
| * @param edge the edge whose weight should be altered | ||
| * @param impedanceInOhm the weight of the {@link ImpedanceWeightedEdge} in ohm | ||
| * @deprecated Use {@link ImpedanceWeightedGraph#setEdgeWeightQuantity(ImpedanceWeightedEdge, | ||
| * ComparableQuantity)} instead, as it provides means for proper unit handling | ||
| */ | ||
| @Override | ||
| @Deprecated | ||
t-ober marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public void setEdgeWeight(ImpedanceWeightedEdge edge, double impedanceInOhm) { | ||
| super.setEdgeWeight(edge, impedanceInOhm); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.