0% found this document useful (0 votes)
4 views17 pages

122387

This document discusses iterative improvement techniques for optimization problems, focusing on the Simplex method and graphical methods for linear programming. It explains how to find optimal solutions through feasible regions, and outlines special cases such as multiple optimal solutions, infeasible problems, and unbounded solutions. Additionally, it highlights the limitations of linear programming and provides a step-by-step guide for applying the Simplex method to solve linear programming problems.

Uploaded by

Neithal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views17 pages

122387

This document discusses iterative improvement techniques for optimization problems, focusing on the Simplex method and graphical methods for linear programming. It explains how to find optimal solutions through feasible regions, and outlines special cases such as multiple optimal solutions, infeasible problems, and unbounded solutions. Additionally, it highlights the limitations of linear programming and provides a step-by-step guide for applying the Simplex method to solve linear programming problems.

Uploaded by

Neithal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

CS1410 – Design and Analysis of Algorithms

UNIT IV ITERATIVE IMPROVEMENT

Graphical Method-The Simplex Method-The Maximum-Flow Problem –Maximum Matching in


Bipartite Graphs-The Stable marriage Problem

4.1 ITERATIVE IMPROVEMENT


The iterative-improvement technique involves finding a solution to an optimization
problem by generating a sequence of feasible solutions with improving values of the
problem’s objective function. Each subsequent solution in such a sequence typically involves
a small, localized change in the previous feasible solution. When no such change improves
the value of the objective function, the algorithm returns the last feasible solution as optimal
and stops.
Important problems that can be solved exactly by iterative-improvement algorithms
include
 Linear programming,
 Maximizing the flow in a network, and
 Matching the maximum possible number of vertices in a graph.

4.2 THE GRAPHICAL METHOD


Linear programming, the general problem of optimizing a linear function of several
variables subject to a set of linear constraints:

Graphical Method - Geometric Interpretation of Linear Programming

Example 1 Consider the following linear programming problem in two variables:


Maximize 3x + 5y
Subject to x + y ≤ 4
x + 3y ≤ 6
x ≥ 0, y ≥ 0.

 A feasible solution to this problem is any point (x, y) that satisfies all the constraints
of the problem;
 The problem’s feasible region is the set of all its feasible points.
Any equation ax + by = c, where coefficients a and b are not both equal to zero, defines a
straight line. Such a line divides the plane into two half-planes: for all the points in one of
them, ax + by < c, while for all the points in the other, ax + by > c. In particular, the set of
points defined by inequality x + y ≤ 4 comprises the points on and below the line x + y = 4,
and the set of points defined by inequality x + 3y ≤ 6 comprises the points on and below the
line x + 3y = 6. Since the points of the feasible region must satisfy all the constraints of the
problem, the feasible region is obtained by the intersection of these two half-planes and the
first quadrant of the Cartesian plane defined by the nonnegativity constraints x ≥ 0, y ≥ 0
(see Figure ).
Thus, the feasible region for problem is the convex polygon with the vertices (0, 0), (4,
0), (0, 2), and (3, 1). (The last point, which is the point of intersection of the lines x + y = 4
and x + 3y = 6, is obtained by solving the system of these two linear equations.)
Our task is to find an optimal solution, a point in the feasible region with the largest
value of the objective function z = 3x + 5y. The optimal solution to the linear programming
problem in question is x = 3, y = 1, with the maximal value of the objective function equal to
14.

St. Joseph’s College of Engineering Page 1 of 17


CS1410 – Design and Analysis of Algorithms

Special Cases in Graphical Method: Linear Programming

The linear programming problems (LPP) discussed in the previous section possessed
unique solutions. This was because the optimal value occurred at one of the extreme points
(corner points). But situations may arise, when the optimal solution obtained is not unique.

Case 1: Multiple Optimal Solutions:


Maximize z = x1 + 2x2
subject to
x1 ≤ 80
x2 ≤ 60
5x1 + 6x2 ≤ 600
x1 + 2x2 ≤ 160
x1, x2 ≥ 0.

In the above figure, there is no unique outer most corner cut by the objective function
line. All points from P to Q lying on line PQ represent optimal solutions and all these will give
the same optimal value (maximum profit) of Rs. 160. This is indicated by the fact that both
the points P with co-ordinates (40, 60) and Q with co-ordinates (60, 50) are on the line x 1 +
2x2 = 160. Thus, every point on the line PQ maximizes the value of the objective function and
the problem has multiple solutions.

St. Joseph’s College of Engineering Page 2 of 17


CS1410 – Design and Analysis of Algorithms
Case 2: Infeasible Problem:
Linear programming problems with the empty feasible region are called infeasible.
Obviously, infeasible problems do not have optimal solutions. For example, if the constraints
include two contradictory requirements, such as x + y ≤ 1and x + y ≥ 2, there can be no
points in the problem’s feasible region.
In some cases, there is no feasible solution area, i.e., there are no points that satisfy all
constraints of the problem. An infeasible LP problem with two decision variables can be
identified through its graph. For example, let us consider the following linear
programming problem (LPP).

Minimize z = 200x1 + 300x2


subject to
2x1 + 3x2 ≥ 1200
x1 + x2 ≤ 400
2x1 + 1.5x2 ≥ 900
x1, x2 ≥ 0

The region located on the right of PQR includes all solutions, which satisfy the first and the
third constraints. The region located on the left of ST includes all solutions, which satisfy the
second constraint. Thus, the problem is infeasible because there is no set of points that
satisfy all the three constraints.

Case:3 Unbounded Solution:


It is a solution whose objective function is infinite. If the feasible region is unbounded
then one or more decision variables will increase indefinitely without violating feasibility, and
the value of the objective function can be made arbitrarily large. Consider the following
model:
Minimize z = 40x1 + 60x2
subject to
2x1 + x2 ≥ 70
x1 + x2 ≥ 40
x1 + 3x2 ≥ 90
x1, x2 ≥ 0

St. Joseph’s College of Engineering Page 3 of 17


CS1410 – Design and Analysis of Algorithms
The point (x1, x2) must be somewhere in the solution space as shown in the figure by shaded
portion.

The three extreme points (corner points) in the finite plane are:
P = (90, 0); Q = (24, 22) and R = (0, 70)
The values of the objective function at these extreme points are:
Z(P) = 3600, Z(Q) = 2280 and Z(R) = 4200

Limitations of Linear Programming


 Linearity of relations: A primary requirement of linear programming is that the
objective function and every constraint must be linear. However, in real life situations,
several business and industrial problems are nonlinear in nature.
 Single objective: Linear programming takes into account a single objective only, i.e.,
profit maximization or cost minimization. However, in today's dynamic business
environment, there is no single universal objective for all organizations.
 Certainty: Linear Programming assumes that the values of co-efficient of decision
variables are known with certainty.
 Due to this restrictive assumption, linear programming cannot be applied to a wide
variety of problems where values of the coefficients are probabilistic.
 Constant parameters: Parameters appearing in LP are assumed to be constant, but
in practical situations it is not so.
 Divisibility: In linear programming, the decision variables are allowed to take non-
negative integer as well as fractional values. However, we quite often face situations
where the planning models contain integer valued variables. For instance, trucks in a
fleet, generators in a powerhouse, pieces of equipment, investment alternatives and
there are a myriad of other examples. Rounding off the solution to the nearest integer
will not yield an optimal solution. In such cases, linear programming techniques cannot
be used.

4.3 THE SIMPLEX METHOD

Solve using the Simplex method the following problem:


Maximiz Z = f(x,y) = 3x
e + 2y
subject
2x + y ≤ 18
to:
2x + 3y ≤ 42
3x + y ≤ 24
x≥0,y≥0
Consider the following steps:
1. Make a change of variables and normalize the sign of the independent terms.
A change is made to the variable naming, establishing the following correspondences:
o x becomes X1
o y becomes X2
As the independent terms of all restrictions are positive no further action is required.
Otherwise there would be multiplied by "-1" on both sides of the inequality (noting that this
operation also affects the type of restriction).

2. Normalize restrictions.
The inequalities become equations by adding slack, surplus and artificial variables as
the following table:
Inequality Variable that
type appears
- surplus +

artificial
= + artificial

St. Joseph’s College of Engineering Page 4 of 17


CS1410 – Design and Analysis of Algorithms

≤ + slack
In this case, a slack variable (X3, X4 and X5) is introduced in each of the restrictions of
≤ type, to convert them into equalities, resulting the system of linear equations:
2X1 + X2 + X3 =
18
2X1 + 3·X2 +
X4 = 42
3X1 + X2 + X5 =
24

3. Match the objective function to zero.


Z - 3·X1 - 2·X2 - 0·X3 - 0·X4 - 0·X5 = 0

4. Write the initial tableau of Simplex method.


The initial tableau of Simplex method consists of all the coefficients of the decision
variables of the original problem and the slack, surplus and artificial variables added in
second step (in columns, with P0 as the constant term and Pi as the coefficients of the rest of
Xi variables), and constraints (in rows). The Cb column contains the coefficients of the
variables that are in the base.
The first row consists of the objective function coefficients, while the last row contains
the objective function value and reduced costs Zj - Cj.
The last row is calculated as follows: Zj = Σ(Cbi·Pj) for i = 1..m, where if j = 0, P0 =
bi and C0 = 0, else Pj = aij. Although this is the first tableau of the Simplex method and all
Cb are null, so the calculation can simplified, and by this time Zj = -Cj.
Tableau I . 1st iteration
3 2 0 0 0
Base Cb P0 P1 P2 P3 P4 P5
P3 0 18 2 1 1 0 0
P4 0 42 2 3 0 1 0
P5 0 24 3 1 0 0 1
Z 0 -3 -2 0 0 0

5. Stopping condition.
If the objective is to maximize, when in the last row (indicator row) there is no negative
value between discounted costs (P1 columns below) the stop condition is reached.
In that case, the algorithm reaches the end as there is no improvement possibility. The
Z value (P0 column) is the optimal solution of the problem.
Another possible scenario is all values are negative or zero in the input variable column
of the base. This indicates that the problem is not limited and the solution will always be
improved. Otherwise, the following steps are executed iteratively.

6. Choice of the input and output base variables.


First, input base variable is determined. For this, column whose value in Z row is the
lesser of all the negatives is chosen. In this example it would be the variable X1 (P1) with -3
as coefficient.
If there are two or more equal coefficients satisfying the above condition (case of tie),
then choice the basic variable.
The column of the input base variable is called pivot column (in green color).
Once obtained the input base variable, the output base variable is determined. The decision is
based on a simple calculation: divide each independent term (P0 column) between the
corresponding value in the pivot column, if both values are strictly positive (greater than
zero). The row whose result is minimum score is chosen.

St. Joseph’s College of Engineering Page 5 of 17


CS1410 – Design and Analysis of Algorithms
If there is any value less than or equal to zero, this quotient will not be performed. If all
values of the pivot column satisfy this condition, the stop condition will be reached and the
problem has an unbounded solution
In this example: 18/2 [=9] , 42/2 [=21] and 24/3 [=8]
The term of the pivot column which led to the lesser positive quotient in the previous
division indicates the row of the slack variable leaving the base. In this example, it is X5 (P5),
with 3 as coefficient. This row is called pivot row (in green).
If two or more quotients meet the choosing condition (case of tie), other than that basic
variable is chosen (wherever possible).The intersection of pivot column and pivot row marks
the pivot value, in this example, 3.

7. Update tableau.

The new coefficients of the tableau are calculated as follows:


In the pivot row each new value is calculated as:
New value = Previous value / Pivot
In the other rows each new value is calculated as:
New value = Previous value - (Previous value in pivot column * New value in pivot
row)
So the pivot is normalized (its value becomes 1), while the other values of the pivot column
are canceled (analogous to the Gauss-Jordan method).
Calculations for P4 row are shown below:
Previous P4 row 42 2 3 0 1 0
- - - - - -
Previous value in pivot column 2 2 2 2 2 2
x x x x x x
New value in pivot row 8 1 1/3 0 0 1/3
= = = = = =
New P4 row 26 0 7/3 0 1 -2/3

The tableau corresponding to this second iteration is:

Tableau II . 2nd iteration


3 2 0 0 0
Base Cb P0 P1 P2 P3 P4 P5
P3 0 2 0 1/3 1 0 -2/3
P4 0 26 0 7/3 0 1 -2/3
P1 3 8 1 1/3 0 0 1/3
Z 24 0 -1 0 0 1
8. When checking the stop condition is observed which is not fulfilled since there is one
negative value in the last row, -1. So, continue iteration steps 6 and 7 again.
6.1. The input base variable is X2 (P2), since it is the variable that corresponds to the
column where the coefficient is -1.
6.2. To calculate the output base variable, the constant terms P0 column) are divided
by the terms of the new pivot column: 2 / 1/3 [=6] , 26 / 7/3 [=78/7] and 8 / 1/3 [=24]. As the
lesser positive quotient is 6, the output base variable is X3 (P3).
6.3. The new pivot is 1/3.
7. Updating the values of tableau again is obtained:
Tableau III . 3rd iteration
3 2 0 0 0
Base Cb P0 P1 P2 P3 P4 P5
P2 2 6 0 1 3 0 -2

St. Joseph’s College of Engineering Page 6 of 17


CS1410 – Design and Analysis of Algorithms

Tableau III . 3rd iteration


P4 0 12 0 0 -7 1 4
P1 3 6 1 0 -1 0 1
Z 30 0 0 3 0 -1

9. Checking again the stop condition reveals that the pivot row has one negative value, -1. It
means that optimal solution is not reached yet and we must continue iterating (steps 6 and
7):
6.1. The input base variable is X5 (P5), since it is the variable that corresponds to the
column where the coefficient is -1.
6.2. To calculate the output base variable, the constant terms (P0) are divided by the
terms of the new pivot column: 6/(-2) [=-3] , 12/4 [=3] , and 6/1 [=6]. In this iteration, the
output base variable is X4 (P4).
6.3. The new pivot is 4.
7. Updating the values of tableau again is obtained:

Tableau IV . 4th iteration


3 2 0 0 0
Base Cb P0 P1 P2 P3 P4 P5
P2 2 12 0 1 -1/2 1/2 0
P5 0 3 0 0 -7/4 1/4 1
P1 3 3 1 0 3/4 -1/4 0
Z 33 0 0 5/4 1/4 0

10. End of algorithm.


It is noted that in the last row, all the coefficients are positive, so the stop condition is
fulfilled.
The optimal solution is given by the val-ue of Z in the constant terms column
(P0 column), in the example: 33. In the same column, the point where it reaches is shown,
watching the corresponding rows of input decision variables: X1 = 3 and X2 = 12.
Undoing the name change gives x = 3 and y = 12.

Summary of the simplex method


 Step 0 Initialization Present a given linear programming problem in standard form and
set up an initial tableau with nonnegative entries in the rightmost column and m other
columns composing the m × m identity matrix. These m columns define the basic
variables of the initial basic feasible solution, used as the labels of the tableau’s rows.
 Step 1 Optimality test If all the entries in the objective row (except, possibly, the one
in the rightmost column, which represents the value of the objective function) are
nonnegative—stop: the tableau represents an optimal solution whose basic variables’
values are in the rightmost column and the remaining, nonbasic variables’ values are
zeros.
 Step 2 Finding the entering variable Select a negative entry from among the first n
elements of the objective row. (A commonly used rule is to select the negative entry
with the largest absolute value, with ties broken arbitrarily.) Mark its column to indicate
the entering variable and the pivot column.
 Step 3 Finding the departing variable For each positive entry in the pivot column,
calculate the θ-ratio by dividing that row’s entry in the rightmost column by its entry in
the pivot column. (If all the entries in the pivot column are negative or zero, the
problem is unbounded—stop.) Find the row with the smallest θ-ratio (ties may be
broken arbitrarily), and mark this row to indicate the departing variable and the pivot
row.

St. Joseph’s College of Engineering Page 7 of 17


CS1410 – Design and Analysis of Algorithms
 Step 4 Forming the next tableau Divide all the entries in the pivot row by its entry in
the pivot column. Subtract from each of the other rows, including the objective row, the
new pivot row multiplied by the entry in the pivot column of the row in question. (This
will make all the entries in the pivot column 0’s except for 1 in the pivot row.) Replace
the label of the pivot row by the variable’s name of the pivot column and go back to
Step 1.

4.4 THE MAXIMUM-FLOW PROBLEM


The transportation network can be represented by a connected weighted digraph with n
vertices numbered from 1 to n and a set of edges E, with the following properties:
 It contains exactly one vertex with no entering edges; this vertex is called the source
and assumed to be numbered 1.
 It contains exactly one vertex with no leaving edges; this vertex is called the sink and
assumed to be numbered n.
 The weight uij of each directed edge (i, j ) is a positive integer, called the edge
capacity. (This number represents the upper bound on the amount of the material that
can be sent from i to j through a link represented by this edge.)
A digraph satisfying these properties is called a flow network or simply a network. A small
instance of a network is given in Figure.

The total amount of the material entering an intermediate vertex must be equal to the total
amount of the material leaving the vertex. This condition is called the flow-conservation
requirement. If we denote the amount sent through edge (i, j ) by xij , then for any
intermediate vertex i, the flow-conservation requirement can be expressed by the following
equality constraint:

where the sums in the left- and right-hand sides express the total inflow and outflow entering
and leaving vertex i, respectively.
The total amount of the material leaving the source must end up at the sink. Thus, we have
the following equality

This quantity, the total outflow from the source—or, equivalently, the total inflow into the sink
—is called the value of the flow. We denote it by v. It is this quantity that we will want to
maximize over all possible flows in a network.
Thus, a (feasible) flow is an assignment of real numbers xij to edges (i, j ) of a given network

0 ≤ xij ≤ uij for every edge (i, j ) ∈ E.


that satisfy flow-conservation constraints and the capacity constraints

The maximum-flow problem can be stated formally as the following optimization problem:

Ford-Fulkerson Algorithm:
It was developed by L. R. Ford, Jr. and D. R. Fulkerson in 1956. Inputs required are network
graph G, source node S and sink node T.

St. Joseph’s College of Engineering Page 8 of 17


CS1410 – Design and Analysis of Algorithms
An augmenting path is a simple path from source to sink which do not include any cycles and
that pass only through positive weighted edges. A residual network graph indicates how much
more flow is allowed in each edge in the network graph. If there are no augmenting paths
possible from S to T, then the flow is maximum. The result i.e. the maximum flow will be the
total flow out of source node which is also equal to total flow in to the sink node.A
demonstration of working of Ford-Fulkerson algorithm is shown below with the help of
diagrams.

function: FordFulkerson(Graph G,Node S,Node T):


Initialise flow in all edges to 0
while (there exists an augmenting path(P) between S and T in residual network graph):
Augment flow between S to T along the path P
Update residual network graph
return

St. Joseph’s College of Engineering Page 9 of 17


CS1410 – Design and Analysis of Algorithms
Implementation:

 An augmenting path in residual graph can be found using DFS or BFS.


 Updating residual graph includes following steps: (refer the diagrams for better
understanding)
o For every edge in the augmenting path, a value of minimum capacity in the path
is subtracted from all the edges of that path.
o An edge of equal amount is added to edges in reverse direction for every
successive nodes in the augmenting path.

Limitation:
The complexity of Ford-Fulkerson algorithm cannot be accurately computed as it all
depends on the path from source to sink. For example, considering the network shown below,
if each time, the path chosen are S−A−B−T and S−B−A−T alternatively, then it can take a
very long time. Instead, if path chosen are only S−A−T and S−B−T, would also generate the
maximum flow.

Shortest-augmenting-path or first-labeled-first scanned algorithm,


There are several ways to generate flow-augmenting paths efficiently and avoid the
degradation in performance illustrated by the previous example. The simplest of them uses
breadth-first search to generate augmenting paths with the least number of edges (see
Section 3.5). This version of the augmenting-path method, called shortest-augmenting-
path or first-labeled-first scanned algorithm, was suggested by J. Edmonds and R. M.
Karp .
The labeling refers to marking a new (unlabeled) vertex with two labels. The first label
indicates the amount of additional flow that can be brought from the source to the vertex
being labeled. The second label is the name of the vertex from which the vertex being labeled
was reached. (It can be left undefined for the source.) It is also convenient to add the + or −
sign to the second label to indicate whether the vertex was reached via a forward or
backward edge, respectively. The source can be always labeled with∞, −. For the other
vertices, the labels are computed as follows.
If unlabeled vertex j is connected to the front vertex i of the traversal queue by a
directed edge from i to j with positive unused capacity rij = uij− xij , then vertex j is labeled
with lj, i+, where lj= min{li, rij}.
If unlabeled vertex j is connected to the front vertex i of the traversal queue by a
directed edge from j to i with positive flow xji, then vertex j is labeled with lj, I −, where lj =
min{li, xji}.
If this labeling-enhanced traversal ends up labeling the sink, the current flow can be
augmented by the amount indicated by the sink’s first label. The augmentation is performed
along the augmenting path traced by following the vertex second labels from sink to source:
the current flow quantities are increased on the forward edges and decreased on the
backward edges of this path. If, on the other hand, the sink remains unlabeled after the
traversal queue becomes empty, the algorithm returns the current flow as maximum and
stops.

Illustration of the shortest-augmenting-path algorithm.


The diagrams on the left show the current flow before the next iteration begins; the
diagrams on the right show the results of the vertex labeling on that iteration, the

St. Joseph’s College of Engineering Page 10 of 17


CS1410 – Design and Analysis of Algorithms
augmenting path found (in bold), and the flow before its augmentation. Vertices deleted from
the queue are indicated by the ↑ symbol.

4.5 MAXIMUM MATCHING IN BIPARTITE GRAPHS

 A matching in a graph is a subset of its edges with the property that no two edges
share a vertex.
 A maximum matching (maximum cardinality matching) is a matching with the
largest number of edges.
 The maximum-matching problem is the problem of finding a maximum matching in
a given graph.
 In a bipartite graph, all the vertices can be partitioned into two disjoint sets V and U,
not necessarily of the same size, so that every edge connects a vertex in one of these
sets to a vertex in the other set.
 In other words, a graph is bipartite if its vertices can be colored in two colors so that
every edge has its vertices colored in different colors; such graphs are also said to be
2-colorable. The graph in Figure is bipartite.

The iterative-improvement technique to the maximum cardinality- matching


problem.

Let M be a matching in a bipartite graph G = (V, U, E).

St. Joseph’s College of Engineering Page 11 of 17


CS1410 – Design and Analysis of Algorithms
 How can we improve it, i.e., find a new matching with more edges? Obviously, if every
vertex in either V or U is matched (has a mate), i.e., serves as an endpoint of an edge
in M, this cannot be done and M is a maximum matching.
 Therefore, to have a chance at improving the current matching, both V and U must
contain unmatched (also called free) vertices, i.e., vertices that are not incident to
any edge in M.
 For example, for the matching Ma = {(4, 8), (5, 9)} in the graph in Figure a,
o Vertices 1, 2, 3, 6, 7, and 10 are free, and
o Vertices 4, 5, 8, and 9 are matched.
 Another obvious observation is that we can immediately increase a current matching
by adding an edge between two free vertices. For example, adding (1, 6) to the
matching Ma = {(4, 8), (5, 9)} in the graph in Figure a yields a larger matching Mb =
{(1, 6), (4, 8), (5, 9)} (Figure b).
 Find a matching larger than Mb by matching vertex 2. The only way to do this would be
to include the edge (2, 6) in a new matching. This inclusion requires removal of (1, 6),
which can be compensated by inclusion of (1, 7) in the new matching. This new
matching Mc = {(1, 7), (2, 6), (4, 8), (5, 9)} is shown in Figure c.
 Moving further, 3, 8, 4, 9, 5, 10 is an augmenting path for the matching Mc (Figure c).
After adding to Mc the edges (3, 8), (4, 9), and (5, 10) and deleting (4, 8) and (5, 9), we
obtain the matching Md = {(1, 7), (2, 6), (3, 8), (4, 9), (5, 10)} shown in Figure d. The
matching Md is not only a maximum matching but also perfect, i.e., a matching that
matches all the vertices of the graph.

In general, we increase the size of a current matching M by constructing a simple path from a
free vertex in V to a free vertex in U whose edges are alternately in E −M and in M. That is,
the first edge of the path does not belong to M, the second one does, and so on, until the last
edge that does not belong to M. Such a path is called augmenting with respect to the
matching M. For example, the path 2, 6, 1, 7 is an augmenting path with respect to the
matching Mb in Figure b. Since the length of an augmenting path is always odd, adding to the
matching M the path’s edges in the odd-numbered positions and deleting from it the path’s
edges in the even-numbered positions yields a matching with one more edge than in M. Such
a matching adjustment is called augmentation. Thus, in Figure, the matching Mb was
obtained by augmentation of the matching Ma along the augmenting path 1, 6, and the
matching Mc was obtained by augmentation of the matching Mb along the augmenting path
2, 6, 1, 7.

St. Joseph’s College of Engineering Page 12 of 17


CS1410 – Design and Analysis of Algorithms

Efficiency of maximum-matching algorithm


Each iteration except the last one matches two previously free vertices—one from each
of the sets V and U. Therefore, the total number of iterations cannot exceed _n/2_ + 1, where
n = |V | + |U| is the number of vertices in the graph. The time spent on each iteration is in

St. Joseph’s College of Engineering Page 13 of 17


CS1410 – Design and Analysis of Algorithms
O(n + m), where m = |E| is the number of edges in the graph. Hence, the time efficiency of
the algorithm is in O(n(n + m)). The efficiency can be improved to O( √n(n + m)) by
combining several iterations into a single stage to maximize the number of edges added to
the matching with one search.

4.6 THE STABLE MARRIAGE PROBLEM

Consider a set Y = {m1, m2, . . . , mn} of n men and a set X = {w1, w2, . . . , wn} of n
women. Each man has a preference list ordering the women as potential marriage partners
with no ties allowed. (Figure a) Similarly, each woman has a preference list of the men, also
with no ties. (Figure b) . The same information can also be presented by an n × n ranking
matrix (Figure c).The rows and columns of the matrix represent the men and women of the
two sets, respectively. A cell in row m and column w contains two rankings: the first is the
position (ranking) of w in the m’s preference list; the second is the position (ranking) of m in
the w’s preference list. For example, the pair 3, 1 in Jim’s row and Ann’s column in the matrix
in Figure c indicates that Ann is Jim’s third choice while Jim is Ann’s first. Which of these two
ways to represent such information is better depends on the task at hand. For example, it is
easier to specify a match of the sets’ elements by using the ranking matrix, whereas the
preference lists might be a more efficient data structure for implementing a matching
algorithm.

 A marriage matching M is a set of n (m, w) pairs whose members are selected from
disjoint n-element sets Y and X in a one-one fashion, i.e., each man m from Y is paired

A pair (m, w), where m ∈ Y, w ∈ X, is said to be a blocking pair for a marriage


with exactly one woman w from X and vice versa.

matching M if man m and woman w are not matched in M but they prefer each other to
their mates in M. For example, (Bob, Lea) is a blocking pair for the marriage matching
M = {(Bob, Ann), (Jim, Lea), (Tom, Sue)} (Figure c) because they are not matched in M
while Bob prefers Lea to Ann and Lea prefers Bob to Jim.
 A marriage matching M is called stable if there is no blocking pair for it; otherwise, M is
called unstable. According to this definition, the marriage matching in Figure 10.11c is
unstable because Bob and Lea can drop their designated mates to join in a union they
both prefer.
 The stable marriage problem is to find a stable marriage matching for men’s and
women’s given preferences. Surprisingly, this problem always has a solution.

Stable marriage algorithm


 Input: A set of n men and a set of n women along with rankings of the women by
each man and rankings of the men by each woman with no ties allowed in the
rankings
 Output: A stable marriage matching

Step 0 Start with all the men and women being free.
Step 1 While there are free men, arbitrarily select one of them and do the following:
 Proposal The selected free man m proposes to w, the next woman on his
preference list (who is the highest-ranked woman who has not rejected him
before).
 Response If w is free, she accepts the proposal to be matched with m. If she is
not free, she compares m with her current mate. If she prefers m to him, she

St. Joseph’s College of Engineering Page 14 of 17


CS1410 – Design and Analysis of Algorithms
accepts m’s proposal, making her former mate free; otherwise, she simply
rejects m’s proposal, leaving m free.
Step 2 Return the set of n matched pairs.

Theorem
The stable marriage algorithm terminates after no more than n2 iterations with a stable
marriage output.
Proof
The algorithm starts with n men having the total of n2 women on their ranking lists. On
each iteration, one man makes a proposal to a woman. This reduces the total number of
women to whom the men can still propose in the future because no man proposes to the
same woman more than once. Hence, the algorithm must stop after no more than n2
iterations.

Application of the stable marriage algorithm:


An accepted proposal is indicated by a boxed cell; a rejected proposal is shown by an
underlined cell.

The stable marriage algorithm has a notable shortcoming. It is not “gender neutral.” In the
form presented above, it favors men’s preferences over women’s preferences. We can easily
see this by tracing the algorithm on the following instance of the problem:
Woman 1 Woman 2
Man 1 1, 2 2, 1
Man 2 2, 1 1, 2
The algorithm obviously yields the stable matching M = {(man 1, woman 1), (man 2, woman
2)}. In this matching, both men are matched to their first choices, which is not the case for
the women. One can prove that the algorithm always yields a stable matching that is man-
optimal: it assigns to each man the highest-ranked woman possible under any stable
marriage. Of course, this gender bias can be reversed, but not eliminated, by reversing the
roles played by men and women in the algorithm, i.e., by making women propose and men
accept or reject their proposals.

St. Joseph’s College of Engineering Page 15 of 17


CS1410 – Design and Analysis of Algorithms

UNIT IV UNIVERSITY QUESTION:


PART-A
1. Describe iterative improvement technique. (Dec 2018)(Dec 2016)
2. What is solution space? Give example. (Dec 2018)
3. How is a transportation network represented? (May 2018)
4. What is meant by maximum cardinality matching? (May 2018) (Dec 2016)
5. What are Bipartite Graphs? (Dec 2017)
6. State Extreme point theorem. (Dec 2017) (May 2016)
7. What do you mean by perfect matching in bipartite graphs? (May 2017) (May 2015)
8. Define network flow and cut. (Dec 2015)
9. Define flow cut. (May 2015)
10. Determine the dual linear program for the following LP: (Dec 2015)
Max 3a+2b+c
Subject to
2a+b+c≤ 3
a+b+c≤4
3a+3b+6c≤6
a,b,c≥0
PART-B
1. Illustrate the steps of the simplex methods with an example. (Dec 2018) (May 2018) (Dec
2017) (May 2017) (Dec 2016) (May 2016)
2. Write the stable marriage algorithm and trace it with an instance. Analyze its running time
complexity. (Dec 2018) (Dec 2016)
3. Prove that the stable marriage algorithm terminates after no more than n 2 iterations with a
suitable output. (May 2018) (Dec 2016)
4. What is stable marriage problem? Give the algorithm and analyze it. (Dec 2017) (May
2015)
5. State and prove max flow min cut theorem. (Dec 2016) (May 2016)
6. Apply the shortest augmenting path algorithm to the network shown below. (May 2016)

7. Maximize p = 2x +3y+z (May 2015)


Subject to
x+y+z≤40
2x+y-z≥10
-y+z≥10
x,y,z≥0

8. Write down the optimality condition and algorithmic implementation for finding M-
augmenting paths in bipartite graphs. (May 2015)
9. How do you compute maximum flow for the following graph using Ford-Fulkerson method?
(May 2015)
10. Explain Max-flow problem. (Dec 2015)
11. Explain the working of the maximum matching algorithm on the following weighted tree.
(Dec 2015)

St. Joseph’s College of Engineering Page 16 of 17


CS1410 – Design and Analysis of Algorithms

St. Joseph’s College of Engineering Page 17 of 17

You might also like