Linear Programming: Simplex Method. Solution
Linear Programming: Simplex Method. Solution
maximize 5x + 3y
5x − 2y ≥ 0
x+y ≤ 7
x ≤ 5
x ≥ 0
y ≥ 0
(1, 3), (2, 5), (3, 7), (5, 11), (7, 14), (8, 15), (10, 19).
Suppose you want to determine a line ax + by = c that approximately passes through these
points (it might not contain all the points). Write a linear program to find a line that mini-
mizes the maximum absolute error, being
maximize −z
−z + xi a + yi b − c ≤ 0 ∀0<i≤7
z + xi a + yi b − c ≤ 0 ∀0<i≤7
a, b, c, z ≥ 0.
4. The following figure shows a graph with four nodes on the left representing boys and four
nodes on the right representing girls. There is an edge between a boy and girl if they like
each other (for instance, Al likes all the girls).
This kind of graph, in which the nodes can be partitioned into two groups such that all
edges are between the groups, is called bipartite. Is it possible to choose couples so that
everyone has exactly one partner? In graph-theoretic jargon, is there a perfect matching?
Write a linear program that solves the matching problem.
Solution We turn the graph into a directed graph, choosing to direct the edges towards
the girls. Furthermore, we add nodes s and t to the graph with for every boy an edge from s
to that boy and for every girl an edge from that girl to t. For all nodes i and j, we have
a constant cij that is 0 if there is no edge and 1 if there is an edge from i to j. Finally, we
introduce variables fij for all nodes i and j. The problem has turned into a maximum flow
problem (after solving it as such, we simply check if the size of the flow equals the number
of boys), where s is the source node, t the sink node, c the capacities and f the flow. Thus,
the problem can be modelled by a linear program as explained during the lecture.
5. In the last lecture, we saw the single-source-single-target shortest path problem being for-
mulated as a linear maximization problem. Alternatively, one can derive the following dual
minimization variant: X
minimize xuv w(u, v)
(u,v)∈E
Here, xuv = 1 if the edge (u, v) is part of the shortest path, and xuv = 0, otherwise. Write
down the corresponding constraints.
Solution The constraints are
X X X X
xsv − xvs = xvt − xtv = 1
v v v v
and, for all w ∈
/ {s, t}, X X
xvw − xwv = 0.
v v
Here s is the source node and t is the target node. To make this a linear problem, we need
to replace the assertion xuv ∈ {0, 1} for all u and v by xuv ≥ 0. Note that there may now
be solutions with non-integer values for some xuv . This means that the “flow” is divided
over multiple paths between certain nodes, but because of the minimization it can only be
divided if these paths have the same length. Thus, any path along which all xuv are nonzero
will be a shortest path.
6. Convert the following linear program into standard form:
minimize 2x1 + 7x2 + x3
x1 − x3 = 7
3x1 + x2 ≥ 24
x2 ≥ 0
x3 ≤ 0
Now we introduce slack variables x4 , x5 , and x6 and display the program in slack form.
z = 2x1 − 6x3
x4 = 7 − x1 − x2 + x3
x5 = −8 + 3x1 − x2
x6 = −x1 + 2x2 + 2x3
Those are the basic variables. The nonbasic variables are x1 , x2 , and x3 .
8. Solve the following linear program using SIMPLEX
z = 18x1 + 12.5x2
x3 = 20 − x1 − x2
x4 = 12 − x1
x5 = 16 − x2
The variable x1 has a positive coefficient in the objective function. With respect to x1 , the
second constraint is the most restrictive. Thus, we substitute x1 using x1 = 12 − x4 .
The variable x2 has a positive coefficient in the new objective function, and now the first
constraint is the most restrictive. We replace it by x2 = 8 − x3 + x4 and substitute x2
everywhere else.
Now all coefficients are negative, so the basic solution, with x1 = 12 and x2 = 8, is optimal.
9. For the following network, with edge capacities as shown, find the maximum flow from S
to T , along with a matching cut.
4 5
A D G
6 1
2 2 12
10
1
S B E T
20
2 6
10 4
5
C F
A cut partitions the vertices of a graph into two disjoint subsets, say L and R. The capacity
of a cut is the total capacity of the edges from L to R. A cut is said to match a flow if the size
of the flow is equal to the capacity of the cut.
Solution Sending a flow of 4 over the path (S, A, D, G, T ), the residual graph is as
follows.
1
4
A D G
2 4
1
2 2 4 8
4
10
S B E T
1 20
2 6
10 4
5
C F
A possible choice of the rest of the paths is shown below, along with the additional flow
each path admits and the final residual graph that results from all this.
1
4
A D 4 G
6 1
2 2 9 3
Path Flow 5
(S, A, B, E, G, T ) 2 1 5
(S, B, E, G, T ) 1 S B 15 E T
(S, C, F, T ) 4 5
(S, C, B, E, G, T ) 2 4
2 6
4
6 1
C F
4
Together, the size of the flow is 13. A matching cut can be found by taking for L the nodes
that in the final residual graph can be reached from S, i.e., L = {S, C, F }.