I am trying to solve a assignment problem using linear programming. I am using the simplex algorithm mentioned in CLRS.
Consider the below example:
--(1/1)--->|a|---(10/1)------>|d|----------->
| | ^ |
| |_(7/1)__ | |
|s| ________|_(12/1)__| |t|
| | |_______ |
| | | |
| | v |
--(1/1)--->|b|---(10/1)---->|c|--(1/1)----->
Vertex a and b are the persons.
Vertex c and d are the jobs.
I have modeled it as a min cost max flow problem.
Source S and Sink t has been added.
All the edge weights have been set to 1.
Edge cost from source to vertex a and b is set to 1.
Edge cost from d,c to sink is set to 1.
The (a/b) values in the edge represent (Cost/Flow Capacity) for that edge.
I use W to represent edge cost and C for capacity.
The linear program is:
Minimize,
Summation(W(uv).f(uv)) over all uv.
Such that,
f(uv) >= 0 , for all (u,v) in E
f(uv) <= C(u,v) , C(u,v)=1 in this case, for all (u,v) in E
Flow conservation for each vertex except the source and the sink.
So Sum(f(uv)) = Sum(f(vu)), for all u,v
Flow demand of atleast 2, since we need to match 2 persons.
f(sa) + f(sb) = 2
The Standard Form is:
Maximize,
-(Summation(W(uv).f(uv)) over all uv)
Such that,
f(uv) >= 0 , for all (u,v) in E
f(uv) <= C(u,v) , C(u,v)=1 in this case, for all (u,v) in E
Flow conservation for each vertex except the source and the sink.
So Sum(f(uv)) = Sum(f(vu)), for all u,v
Demand:
f(sa) + f(sb) = 2
Which reduces to
maximize (- { W(sa).f(sa) + W(sb).f(sb) + W(ad).f(ad) + W(ac).f(ac) + W(bd).f(bd) + W(bc).f(bc) + W(dt).f(dt) + W(ct).f(ct) } )
Substituting x1 for sa, x2 for sb, x3 for ad, x4 for ac, x5 for bd, x6 for bc, x7 for dt, x8 for ct.
Finally, we get something like this:
Maximize
-x1-x2-10(x3)-7(x4)-12(x5)-7(x6)-x7-x8 (objective function)
Given that (constraints)
Capacity constraints:
x{1-8} <= 1
Flow conversations:
x1 = x3+x4 --> ( x1-x3-x4 <=0 & -x1+x3+x4 <= 0)
x2 = x6+x5 --> ( x2-x6-x5 <=0 & -x2+x6+x5 <= 0)
x7 = x3+x5 --> ( x7-x3-x5 <=0 & -x7+x3+x5 <= 0)
x8 = x4+x6 --> ( x8-x4-x6 <=0 & -x8+x4+x6 <= 0)
Demand:
x1 + x2 =2 --> ( x1+x2 <=2 && -x1-x2 <=2)
According to CLRS, The first part of simplex is to obtain a initial slack form with a feasible solution using the INITIALISE-SIMPLEX method.
This method checks if there are any negative values on the right hand side of the inequalities in the constraints. If not it returns the current setting as the initial slack form for the main algorithm to process.
In the main algorithm the first step is to choose a Non-basic variable whose coefficient is non-negative in the objective function.
But in this case, all the variables in the objective function have a negative coefficient(since we multiplied the initial obj function to convert minimization to maximization form).
So simplex will terminate with 0 as flow values for all the edges ?
I fed the above problem to "linear_solver in google OR-Tools library". And it returns the correct result as 21 and x3 =1 & x4 =0 & x5 =0 & x6 =1
So i think my equations are right.
CLRS doesn't handle this case, or am i missing something ?