0% found this document useful (0 votes)
8 views16 pages

Operation Research lecture 14

Operation Research

Uploaded by

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

Operation Research lecture 14

Operation Research

Uploaded by

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

DEPARTMENT OF COMPUTING (FCIT), Indus University 1

INDUS UNIVERSITY

DEPARTMENT OF COMPUTING (FCIT), Indus University 2


Week 14 - Topics

• 2.Optimal Solution:
The Stepping Stone Method, Modified
Distribution (MODI) Method.

DEPARTMENT OF COMPUTING (FCIT), Indus University 3


Hungarian Method
Understanding the Hungarian Method for Assignment Problems:

The Hungarian method provides an efficient solution to assignment problems. But first,
let's understand what an assignment problem is.

DEPARTMENT OF COMPUTING (FCIT), Indus University 4


Defining an Assignment Problem

An assignment problem is a type of transportation problem where the goal is to assign


resources to tasks in such a way that the total cost of assignment is minimized or the total
profit is maximized.
The complexity arises when resources such as employees, machines, etc., have different
efficiencies for performing different tasks. This variation in efficiency leads to differences
in cost, profit, or loss for each task.
Imagine having ‘n’ tasks to be performed on ‘m’ machines (one task per machine). The
objective is to assign tasks to machines in such a way that the total cost is minimized (or
profit is maximized). This is based on the assumption that each machine can perform each
task, albeit with varying efficiency.

DEPARTMENT OF COMPUTING (FCIT), Indus University 5


Steps of the Hungarian Method
The first step is to check if the problem is balanced i.e., the number of rows and columns
are equal. If not, the problem needs to be balanced before applying the algorithm.

Step 1: Subtract the smallest element in each row from all the elements of that row.
Ensure that each row has at least one zero.
Step 2: From the matrix obtained in Step 1, subtract the smallest element in each column
from all the elements of that column. Ensure that each column has at least one zero.
Step 3: Assign zeros
Go through each row and find a row with exactly one unmarked zero. Circle this zero and
assign it a task. Cross out all other zeros in the column of this circled zero as they can't be
used for future assignments. Repeat this for all rows.
Repeat the process with columns. Find a column with exactly one unmarked zero, circle it
and cross out any other zero in its row. Repeat this for all columns.

DEPARTMENT OF COMPUTING (FCIT), Indus University 6


Steps of the Hungarian Method
Step 4: Perform the Optimal Test
If each row and column has exactly one circled zero, the current assignment is optimal.
If there are rows or columns without a circled zero, the current assignment is not optimal.
Proceed to step 5. Subtract the smallest element from all the entries in each column of the
matrix obtained in Step 1, ensuring each column has at least one zero.

Step 5: Draw the minimum number of straight lines needed to cover all the zeros as
follows:
(a) Mark the rows without an assignment.
(b) Mark the columns containing zeros in the marked rows.
(c) Mark the rows containing assignments in the marked columns.
(d) Repeat steps (b) and (c) until no further marking is required.
(e) Draw lines through all unmarked rows and columns. If the number of lines equals the
order of the matrix, the solution is optimal; otherwise, it is not.

DEPARTMENT OF COMPUTING (FCIT), Indus University 7


Steps of the Hungarian Method
Step 6: Find the smallest element not covered by the lines. Subtract this element from all
uncovered elements and add it to all elements at the intersection of the lines. Leave all
other elements as they are.
Step 7: Repeat Steps 1 to 6 until an optimal assignment is found.

DEPARTMENT OF COMPUTING (FCIT), Indus University 8


Dijkstra's algorithm
Understanding the Dijkstra's algorithm for Shortest path Problems:

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a
weighted graph, which may represent, for example, road networks.

DEPARTMENT OF COMPUTING (FCIT), Indus University 9


Dijkstra's algorithm
Dijkstra's algorithm finds the shortest path from a given source node to every other node.
It can also be used to find the shortest path to a specific destination node, by terminating
the algorithm once the shortest path to the destination node is known.

For example, if the nodes of the graph represent cities, and the costs of edges represent
the average distances between pairs of cities connected by a direct road, then Dijkstra's
algorithm can be used to find the shortest route between one city and all other cities.

DEPARTMENT OF COMPUTING (FCIT), Indus University 10


Dijkstra's algorithm
A common application of shortest path algorithms is network routing protocols, most
notably IS-IS (Intermediate System to Intermediate System) and OSPF (Open Shortest Path
First).

It is also employed as a subroutine in other algorithms such as Johnson's algorithm.

Dijkstra's algorithm is commonly used on graphs where the edge weights are positive
integers or real numbers. It can be generalized to any graph where the edge weights are
partially ordered, provided the subsequent labels (a subsequent label is produced when
traversing an edge) are monotonically non-decreasing.

DEPARTMENT OF COMPUTING (FCIT), Indus University 11


Dijkstra's algorithm
Djikstra used this property in the opposite direction i.e we overestimate the distance of
each vertex from the starting vertex. Then we visit each node and its neighbors to find the
shortest subpath to those neighbors.

The algorithm uses a greedy approach in the sense that we find the next best solution
hoping that the end result is the best solution for the whole problem.

DEPARTMENT OF COMPUTING (FCIT), Indus University 12


Floyd algorithm
In graph theory there are two fundamental issues in the calculation of shortest paths. This
object is achieved with the Dijkstra algorithm (described in chapter 1). The second case
investigates the shortest paths from each node to all other nodes. This could be solved
with a list of all possible trees and the calculation using also the Dijkstra algorithm.
However, this would be very expensive. Such a problem can much easier be solved by
using the Floyd algorithm.

DEPARTMENT OF COMPUTING (FCIT), Indus University 13


Floyd algorithm
Named after Robert Floyd, the algorithm is very easy to calculate and can be programmed
easily as well. Mr. Floyd was an computer scientist. His contributions include the design of
the Floyd–Warshall algorithm, which efficiently finds all shortest paths in a graph, Floyd's
cycle-finding algorithm for detecting cycles in a sequence. A significant achievement was
pioneering the field of program verification using logical assertions with the 1967 paper
Assigning Meanings to Programs. This was an important contribution to what later became
Hoare logic.

DEPARTMENT OF COMPUTING (FCIT), Indus University 14


Floyd algorithm

Example
The task is to determine the shortest paths between all pairs of nodes on transportation
network which are placed in the graph below. A length of a branch is shown with a
number at a line.
Before starting one needs a starting matrix D0. Furthermore this tells one how long the
distances to other nodes are.

DEPARTMENT OF COMPUTING (FCIT), Indus University 15


Thank You

DEPARTMENT OF COMPUTING (FCIT), Indus University 16

You might also like