How do I formulate the inputs for linprog from a Minimum Cost Flow with Lower and Upper Bounds on Links’ Capacities?

3 views (last 30 days)
I am trying to learn to use Matlab to solve a a problem and haven't been able to get the input arguments right. I have lower and upper bounds, cost per link, and weight per node. I am trying to minimize the sum(cij xij) where c is the cost and x is the flow. I and j represent the node at the beginning and end of each link. My constraints are that the sum of the incoming links to each node minus the sum of the outgoing node have to equal the weight of each node. Here is what I have, but it gives me the wrong answer. I am pretty sure the problem is in A.
options = optimoptions('linprog','Algorithm','simplex');
f = [1; 4; 2; -1; 6]; % link cost
A = [5 0 0 0 0 0 5 0 3 0 0 5 0 0 3 0 5 0 3 0]; %Should this be per link??
b = [5; 0; 3; -8]; %weight of nodes
lb = [0 0 0 1 1]; %lower bounds
ub = [6 3 4 8 5]; %upper bounds
[x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!