New answers tagged network-flow
1
Your problem description is quiet vague. So i picked the simplest solution to his problem i can think off in modeling language JuMP.
If you are more detailed about the reality you are working with a better model can be chosen.
clients = 24
servers = 3
using JuMP
using GLPK
class = Model(with_optimizer(GLPK.Optimizer))
cost = rand(clients, servers) # cost ...
5
Introduce a supersource node $s$, a supersink node $t$, arcs from $s$ to each source, and arcs from each sink to $t$. Arc $(s,i)$ has zero cost and capacity equal to supply[i]. Arc $(i,t)$ has zero cost and capacity equal to -supply[i]. All original nodes have supply zero, $s$ has supply equal to the sum of positive supplies, and $t$ has supply equal to ...
2
One way to model this is to add a dummy arc from the sink to the source and impose flow balance of 0 at every node, including the source and sink.
But if you prefer the conditional constraint, I think the proper syntax is:
m.addConstrs(
(flow.sum('*',j) - flow.sum(j,'*') == 0 for j in vertices if j != 2 and j != 7), "node")
Top 50 recent answers are included
Related Tags
network-flow × 31optimization × 11
linear-programming × 10
graphs × 8
modeling × 5
reference-request × 4
mixed-integer-programming × 3
computational-complexity × 3
simplex × 3
integer-programming × 2
python × 2
cplex × 2
solver × 1
constraint × 1
linearization × 1
gurobi × 1
convex-optimization × 1
algorithms × 1
heuristics × 1
online-resources × 1
terminology × 1
polyhedra × 1
branch-and-cut × 1
books × 1
clustering × 1