UNIT 4 Algo Min Notes
UNIT 4 Algo Min Notes
We start with node 1 (root node) which become E-node. The child nodes are generated.
Then node 1 dies and children 2 and 3 become live nodes.
Assignment problem : There are n people to whom n jobs have to be assigned so that total
cost of assignment is least. The cost that would accrue if the i th person is assigned to the jth
job is a known quantity C[i, j] for each pair i, j = 1, 2, ... , n
We can describe feasible solutions to the assignment problem as n-tuples where xi indicates
the job number assigned to the i th person. For example, for the cost matrix above, (2, 3, 4, 1)
indicates a feasible assignment of Person A to Job 2, Person B to Job 3, Person C to Job 4,
and Person D to Job 1
In terms of this matrix, the problem calls for a selection of one element in each row of the
matrix so that all selected elements are in different columns and the total sum of the
selected elements is the smallest possible.
We cannot select the smallest element in each row because the smallest elements may
happen to be in the same column. In fact, the smallest element in the entire matrix need not
be a component of an optimal solution
Brute force method generate all permutation of job assignment and chose the best.
Complexity is high O(n!)
Can be solved using branch and bound method.
Knapsack Problem
Given ‘n’ items of known weights ‘wi’ and values ‘vi’, i = 1, 2, ... , n, and a knapsack of
capacity ‘W’, find the most valuable subset of the items that fit in the knapsack.
There are three types of knapsack problem
1) 0/1 knapsack 2) Fractional knapsack 3) unbounded Knapsack
Step 1: Arrange the items of a given instance in descending order by their value-to-weight
ratios.
Step 2: Construct state space tree. Total weight ‘w’ and the total value ‘v’ of this selection in
the node, along with some upper bound ‘ub’ on the value of any subset that can be
obtained are recorded. Solution is determined by the path from the root to the node: a
branch going to the left indicates the inclusion of the next item, while a branch going to the
right indicates its exclusion
Step 3: Upper Bound is computed by adding to ‘v’, (the total value of the items already
selected), the product of the remaining capacity of the knapsack (W – w) and the best per
unit payoff among the remaining items, which is
Problem
Initially sort the items in decreasing order of value/weight. At the root of the state-space
tree, no items have been selected as yet. Hence, both the total weight of the items already
selected (w) and their total value (v) are equal to 0. The value of the upper bound computed
using ‘ub’ formula is $100.
Travelling Salesman Problem: Given a set of cities and the distance between each pair of
cities, find the shortest possible route that visits every city exactly once and return to the
starting city. Can be solved by finding a minimum weight Hamiltonian cycle.
a) Naïve solution:
Step1: Consider city 1 as starting and ending point.
Step 2: Generate all permutations of remaining (n-1) cities.
Step 3: Calculate cost if the route is feasible routes.
Step 4: Return permutation with minimum cost
Complexity is high O(n!)
b) Using Branch and bound
Solve Travelling salesman problem using branch and bound algorithm
At root node
a=(a-b)+(a-c)=2+5=7 (among three edges of a these were the least)
LB=[(2+5)+(2+3)+(1+5)+(1+3)]/2=11
At level 1 we will consider a-b, a-c and a-d distances
Consider Node 1 Since it is a-b we must consider it whereever applicable
a=(a-b)+(a-c)=2+5=7
b=(a-b)+(b-d)=2+3=5
c=(a-c)+(c-d)=5+1=6 here (a-b) edge not considered since it is not connect to c
d=(b-d)+(c-d)=3+1=4
LB=(7+5+6+4)/2=11
Similarly for node 2 a-c hence consider edge (a-c) whenever applicable
LB=11
Node 3 is a-d hence consider a-d whenever applicable
LB=14
In level 1 smallest is 11. Consider node 1. Expand node1 into node 4 and 5
Node 4 a-b-c Hence consider edges a-b and b-c whenever applicable
LB=(7+10+9+4)/2=15
Node 5 is a-b-d hence consider edges a-b and b-d wherever applicable
LB=(7+5+6+4)/2=11
The full state space graph is shown below. Node 2 and Node 3 are not explored since the
bounds are inferior to already found best solution.