You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This enforces implicitly that the resulting graph is acyclic and that way the Network object
immediately represents a complete graph and the optimization model can be generated its
constructor as there is no information missing.
The method connect_nodes() would also add the nodes to the network if they are not there yet (is
this a good method name then if it also adds it to the network?).
One more option which might make sense: similar to PyPsa, one could allow referencing to the nodes
in connect_nodes() as strings if the are already part of the network object:
This might be way more readable and many things are easier to be implemented if the network can be
passed around functions as a container object and the information for the network can be connected
piece by piece in any order.
Especially also for unit testing it might be helpful as one could create a base network and than
add stuff to it for testing specific features.
Hints for implementation
In the network class one needs to take care of:
generate graph on the fly, i.e. not in the constructor but only when it's needed
lazy generate the linopy.Model() object: set self.model to None and call _generate_optimization_model()inoptimize(), add_constraints()andadd_variables()ifself.modelis stillNone`
lazy generate the networkx object self.graph for plotting in Network.draw() or simply
remove self.graph and call _create_graph() in draw() every time?
raise error if the network is changed somehow after the linopy.Model has been generated and self.model is not None, i.e. in add_node(), connect_nodes(), add_constraints(), add_variables() - basically the Network object should be modified only through methods
update or lazy generate the nodes_dict attribute, outputs of nodes and other things done in Network.__init__()
check that the graph is acyclic at some point (before optimize() is called?)
check that all nodes are connected (before optimize() is called?) - see _check_all_nodes_connected()
The text was updated successfully, but these errors were encountered:
This might be a neat change for the future. It should be possible to implement it in a backward compatible way.
Current interface
In the current interface, one needs to pass input nodes to the constructor of the output node to
create connections in the network:
This enforces implicitly that the resulting graph is acyclic and that way the Network object
immediately represents a complete graph and the optimization model can be generated its
constructor as there is no information missing.
Suggestion
The method
connect_nodes()
would also add the nodes to the network if they are not there yet (isthis a good method name then if it also adds it to the network?).
Alternatively we could use a method
add_node()
:One more option which might make sense: similar to PyPsa, one could allow referencing to the nodes
in
connect_nodes()
as strings if the are already part of the network object:Motivation
This might be way more readable and many things are easier to be implemented if the network can be
passed around functions as a container object and the information for the network can be connected
piece by piece in any order.
Especially also for unit testing it might be helpful as one could create a base network and than
add stuff to it for testing specific features.
Hints for implementation
In the network class one needs to take care of:
self.model to None and call
_generate_optimization_model()in
optimize(),
add_constraints()and
add_variables()if
self.modelis still
None`networkx
objectself.graph
for plotting inNetwork.draw()
or simplyremove
self.graph
and call_create_graph()
indraw()
every time?linopy.Model
has been generated andself.model
is notNone
, i.e. inadd_node()
,connect_nodes()
,add_constraints()
,add_variables()
- basically the Network object should be modified only through methodsnodes_dict
attribute, outputs of nodes and other things done inNetwork.__init__()
optimize()
is called?)optimize()
is called?) - see_check_all_nodes_connected()
The text was updated successfully, but these errors were encountered: