Modeling network flow problem in Python #4384
-
Hello, I'm implementing a network flow problem using My question is about expressing this in the Now we start definining the constraints. First, constraint from equations 4, 5, and 6 to ensure the selected route is contiguous:
Equation (4) above requires that exactly one more route must flow out of the starting point than into it. Equation (5) requires that exactly one more selected route must flow into the end point than flow out of it. Finally, equation (6) indicates the outward and inward flow between two nodes must be balanced for all nodes other than the start and the finish. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think this should work similarly to the way I implemented the objective functions: c4 = solver.Constraint(1)
for f in range(modesz):
for j in range(nodesz):
c4.SetCoefficient(get_x(s, j, f), 1)
for f in range(modesz):
for j in range(nodesz):
c4.SetCoefficient(get_x(j, s, f), -1) This should capture the intent of equation (4) above. |
Beta Was this translation helpful? Give feedback.
I think this should work similarly to the way I implemented the objective functions:
This should capture the intent of equation (4) above.