-
Notifications
You must be signed in to change notification settings - Fork 4
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
Two network comparison #12
base: main
Are you sure you want to change the base?
Conversation
bug fixes
plt.savefig("network_graph.png", dpi=300) | ||
|
||
|
||
def available_item_properties( |
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.
it would be better to split this method into two:
- one method that compares the edges
- one method that compares the nodes
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.
I think you are referring to the compare_graph_properties on line 124 which is where I have implemented the method to compare both nodes and edges.
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.
this was a general comment about having separate methods for nodes and vertices so that you don't have to do:
if item not in ["network_nodes", "network_edges"]: # Validate item type
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.
Oh, thanks for the clarity.
"Invalid item type. Must be 'network_nodes' or 'network_edges'." | ||
) | ||
|
||
missing_item = [] # Initialize a list to store missing items |
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.
unfortunately this won't do what we want it to - here you want to compare the graphs without caring about the details of the buses making up the graph. Looking at the function graph.add_nodes_from(buses_i) at Line 64 of pypsa/graph.py, the function you've got here for comparing nodes would actually compare the lists of buses in each network. What we want to do instead is to compare e.g. the number of nodes in each graph
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.
Actually, the pypsa-network is translated into a graph by using the buses as nodes and the links/links as edges. Treating the network as a graph means that no attention is paid to the size of the bus or the length of the links/lines.
Feel free to disagree :)
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.
Also, the graph method in pypsa was built ontop of networkx
which is used to develop graphs in Python https://github.com/PyPSA/PyPSA/blob/master/pypsa/graph.py#L22
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.
At line 64 of the pypsa classs for graphs the graph is created from the set of buses:
graph.add_nodes_from(buses_i)
At line 53 of the same file, we set
buses_i = network.buses.index
As such, the nodes in the graph each correspond to the string index of the associated bus. This means that two nodes in the graph are defined to be equal if they have the same bus name. This means that when in your method you compare the nodes, you are only comparing the respective bus names in each network. This is not the information we want. Instead, we should look at general properties of the graph e.g. number of nodes, average degree.
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.
I could remove the nodes and edges properties from the code. But there can't be multiple buses with the same name in network.buses.index
. I only added in case we need to do some more complex comparison which can also be useful for our matching algorithm which also relies on the index of buses.
let me know what you think?
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.
the problem is that it isn't the names of the buses that we are interested in - it is their other properties
the new functions you've added r.e. number of edges and nodes look great - can you move them into the single graph function and then compare the returned values for each graph in the two-graph function? |
This PR includes functions to compare graph properties of two networks.