I am using Networkx to define a graph G and later use it in my abstract model of pyomo.
The graph contains few nodes. I want to create pyomo abstract constraints equal to the number of nodes in graph. The graph G is:
def mygraph():
G = nx.Graph()
#Some nodes are defined here
Later, I am using my graph in my Pyomo Abstract Model as:
def mymodel(): #Abstract Model CreationI want to create constraints for each node of the graph and pprint() it to verify. Like, suppose my graph has 6 nodes then there must be 6 constraints. I am trying to do so as:
model.nodes_range = RangeSet(1, len(g)) # this creates a parameter with same size of the graphHowever, I am not getting constraints with this for each node. Can you guide me with this?
Kind Regards
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/2a3ae572-1244-41aa-863d-c479db03f120n%40googlegroups.com.
ISBN: 3030689301
ISBN13: 9783030689308
To quickly answer your question:
Constraint(model.nodes_range, rule=const1)
tells Pyomo to call the function const1 once for each member of model.nodes_range and pass that in as an argument (for the first function argument is always the model). This is explained much better in the book.
Dave
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/c3e74c59-3048-465d-9305-bccf9eaf48f2n%40googlegroups.com.