MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

download MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

of 8

Transcript of MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    1/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 1 of 18

    TOPIC TITLE: Coping with the Limitations of Algorithm Power

    Speci f ic Object ives:

     At the end of the topic session, the students are expected to:

    Cognitive:

    Understand the idea of coping up with the limitations ofalgorithm power.

    Understand the concept of Backtracking algorithm designtechnique.

    Understand the application of Backtracking using algorithmdesign technique N-queen problem.

    Know the definition of branch and bound algorithm designtechnique. 

     Affective:

    1. Listen to others with respect.2. Participate in class discussions actively.3. Share ideas to the class.

    MATERIALS/EQUIPMENT:

    o  topic slideso  OHP

    TOPIC PREPARATION:

    o

      Have the students research on the following:The importance of coping up with the limitation ofalgorithm power.

    Definition of Backtracking algorithm design technique.

     Application of Backtracking algorithm design techniqueusing N-queen problem.

    Definition of branch and bound algorithm designtechnique. 

    o  Provide sample problems that show how to cope up with thelimitations of algorithm power. 

    o  It is imperative for the instructor to incorporate various kinds ofteaching strategies while discussing the suggested topics. Theinstructor may use the suggested learning activities below to

    facilitat e a thorough and creative discussion of the topic.o  Prepare the slides to be presented in the class.o  Prepare seatwork for the students to apply the lessons learned

    under coping with the limitations of algorithm power.

    TOPIC PRESENTATION:

    The topic will cover how to cope up with the limitations of algorithmpower.

    The following is the suggested flow of discussion for the course topic:

    Discuss the idea of coping up with the limitation of algorithm

    power.Discuss the concept of Backtracking algorithm design

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    2/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 2 of 18

    technique.

    Provide example of Backtracking algorithm design techniqueusing N-queen problem.

    Discuss the definition of branch and bound algorithm designtechnique.

    Coping with the Limitations of Algorithm PowerPage 1 of 47

    Copingwith theLimitationsof algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page1of 27

    The following are the topics to be discussed under

    coping with the limitations of algorithm power:

    Understand the idea of coping up with the

    limitation of algorithm power

    Understand the concept of Backtracking

    algorithm design technique.

    Understand the application of Backtracking

    using algorithm design technique N-queen

    problem.

    Know the definition of branch and bound

    algorithm design technique.

     

    Coping with the Limitations of Algorithm Power

    The following are the topics to be discussed under coping with thelimitations of algorithm power:

    Understand the idea of coping up with the limitation of algorithmpower

    Understand the concept of Backtracking algorithm designtechnique.

    Understand the application of Backtracking using algorithmdesign technique N-queen problem.Know the definition of branch and bound algorithm designtechnique.

    Coping with the Limitations of Algorithm PowerPage 2 of 47

    Copingwith theLimitationsof algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page2of 27

    There are problems that are difficult to solve

    where algorithms takes too much time for arbitrary

    instances of problem.

    To cope up with this, it is important to understand

    what makes a problem difficult and makes a

    problem easy.

    Theoretically, a problem will turn out to be difficult

    if there is only one instance of the problem that

    demands an exponential time to solve by any

    algorithm.

     

    Coping with the Limitations of Algorithm Power  

    We are aware that there are problems that are difficult to solve wherealgorithms take too much time for arbitrary instances of problem.Sometimes, we need to consider a number of approaches to solve

    problems that occur to be intractable like problems that do not haveefficient solutions. To cope up with this, it is important to understandwhat makes a problem difficult and easy. We can say that a problem iseasy if and only if there is at least one algorithm that solves everyinstance of the problem efficiently. Theoretically, a problem will turn outto be difficult if there is only one instance of the problem that demandsan exponential time to solve by any algorithm.

    It is evident that there is infinite number of instances for any problem, sothe subsistence of some problem instances needing exponential timewould be difficult to perceive. However, a fixed percentage of allproblem instances usually require exponential time. The implication ofthis statement is that even for difficult problems, there are percentages

    of problem instances that can be efficiently solved.

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    3/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 3 of 18

    Coping with the Limitations of Algorithm PowerPage 3 of 47

    Copingwith theLimitationsof algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page3of 27

    Problems can be solved using 

    back-tracking 

    branch-and-bound

    Both strategies are improvements over exhaustive

     

    Backtracking and branch-and-bound algorithm design techniques areapplied in creating a problem-search-tree whose nodes mirror specificchoices prepared for a solution’s component. Both techniques terminatea node as soon as it can be guaranteed that no solution to the problemcan be achieved by considering choices that correspond to the nodes’successors. The techniques vary in the nature of problems these can

    be applied to.

    [Coping with the Limitations of Algorithm Power, Pages 1-3 of 47]

    BacktrackingPage 4 of 47

    Copingwith theLimitationsof algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page4of 27

    Backtracking: is a refinement of the exhaustive

    search strategy where solutions to a problem are

    developed and evaluated one step

    at a time.

    Each partial solution is evaluated for feasibility

    and is said to be feasible if it can be developed by

    further choices without violating any of the

    problem’s constraints.

     BacktrackingPage 5 of 47

    Copingwith theLimitationsof algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page5of 27

    The following are the steps in evaluating a

    problem thru backtracking:

     

    Backtracking

    Backtracking is a refinement of the exhaustive search (brute force)strategy where solutions to a problem are developed and evaluated onestep at a time. Each partial solution is evaluated for feasibility and issaid to be feasible if it can be developed by further choices withoutviolating any of the problem’s constraints.  In addition, partial solution issaid to be infeasible if there are no legitimate options for any remainingchoices.

    The following are the steps in evaluating a problem throughbacktracking:

     Figure 17.1 Illustration of backtracking algorithm 

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    4/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 4 of 18

    BacktrackingPage 6 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page6of 27

    Example: N-Queen problem

    A standard chess board is an eight-by- eight arrayconsisting eight rows of eight columns each.

    To further understand the constraints on this

    problem, we shall examine the simpler 4-queens

    problem that is set on a four-by -four board.

     

    Backtracking

    Page 7 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page7of 27

    The possible moves for this queen are the

    following:

     

    BacktrackingPage 8 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page8of 48

    Solution to the problem can be attained thru the

    following:

     

    Example: N-Queen Problem

     A standard chess board is an eight-by-eight array consisting of eightrows and eight columns. The eight-queen problem is set in the contextof this standard chess board and its main objective is to place eightqueens on the board subject to the constraint that no two queens can

    attack each other.

    To further understand the constraints of this problem, we shall examinethe simpler 4-queens problem that is set on a four-by-four board.

    .

     Figure 17.2 Illustration of four-by-four board  

    In the given figure, the board is represented as either a number ofhorizontal rows or vertical columns. One should be able to show it interms of diagonals. In the real chess games, we consider the queen asthe most powerful piece, which is allowed to move horizontally,vertically, or along either of the two diagonals on which it is placed. Inthis example, the queen is located in row 2 and column 1, or position (2,1).

    The possible moves for this queen are the following:

    1. Any other position on row 2: (2, 2), (2, 3), or (2, 4)

    2. Any other position on column 1: (1, 1), (3, 1), or (4, 1)3. Any other position on the NE diagonal: (1, 2)4. Any other position on the SE diagonal: (3, 2) or (4, 3)

    If any other queen is in one of the signified locations, the two queenscan attack each other and the solution is not allowed. On the other hand,the solution to the problem can be attained using the following:

     Figure 17.3 Illustration of problem solution 

    Usually, one has a structured way to place the queens. It is easier torepresent the one that is needed only at the start with two initialpositions, either in column 1 or row 1. For simplicity, let us go by thesolution that begins with placing in a column. It is easier to envision thatthere are two starting positions for this problem. We can simply say that

    other solutions can be generated by symmetry arguments. Once wehave one applicable solution, we can use symmetry to get the others, asillustrated below:

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    5/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 5 of 18

    BacktrackingPage 9 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page9of 48

    It can be argued that other solutions can be

    generated by symmetry arguments, once we have

    one applicable solution we shall use symmetry to

    get the others as illustrated below:

     

    BacktrackingPage 10 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page10of 48

    The empty board is considered as the root node of

    the tree which is the starting position of the

    problem. The figure below are the first two levels

    of the tree:

     Backtracking

    Page 11 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page11of 48

    Each of the two leaf nodes in the partial tree is the

    root node of a tree with the following leaf count:

     

     Figure 17.4 Illustration of the solution through symmetry arguments 

     Afterwards, we will set these two possible initial positions within thestate-space-tree. The empty board is considered as the root node of thetree which is the starting position of the problem. The figure below arethe first two levels of the tree:

     Figure 17.5 Illustration of the first two level of the tree 

    This time, we will position the queens by columns, thus the first potentialsolution would observe that there are four different positions in eachcolumn. The fact that no two queens can be in the same row yields 3positions for column 2, 2 positions for column 3, and only 1 for column 4.Each of the two leaf nodes in the partial tree above is the root node of atree with the following leaf count:

     Figure 17.6 Illustration of leaf count of the tree

    In the given figure, the simplest solution for 43 is equal to 64 leaf nodesand no two n-queens in a row. That is why we have the factor of 3,which is 6 leaf nodes. In this case, we can see immediately that a simpleobservation will trim the number of solutions that needs to be

    considered.

    We now consider the subtree on the left and see backtracking in action.

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    6/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 6 of 18

    BacktrackingPage 12 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page12of 48

    We now consider the subtree on the left and see

    backtracking in action. Think an incorrect solution

    that places another queen in position (2, 2) as

    illustrated below:

     You will observe that we have a diagonal conflict

    since the first queen at position (1, 1) can attack

    the second queen at position (2, 2) by using a

    diagonal move.

     

    BacktrackingPage 13 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page13of 48

    This method of stating every node in the subtree

    to violate a constraint and therefore dropping the

    set of solutions is called pruning the state tree.

    It is simple to see that there are 6! = 720 trial

    solutions with one queen at (1, 1) and the other at

    (2, 2).

     

    BacktrackingPage 14 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page14of 48

    Again, we will look at the other subtree of the

    solution space, beginning with the node illustrated

    below:

     

    Think of an incorrect solution that places another queen in position (2,2), as illustrated below:

     Figure 17.7 Illustration of placing the queen in position (2, 2)

    In the given figure, you will observe that we have a diagonal conflictsince the first queen at position (1, 1) can attack the second queen at

    position (2, 2) by a diagonal move. As a result, we deny this partialsolution, without generating any more of this subtree. This method ofstating every node in the subtree to violate a constraint and dropping theset of solutions is called pruning the state tree. At this point, the pruning

    of the tree keeps consideration of only two needless solutions. It issimple to see that there are 6! = 720 trial solutions with one queen at (1,1) and the other at (2, 2). Therefore, none of these solutions require tobe considered as each defies a diagonal constraint. The completion ofthe first subtree, drawn horizontally in order to save space is illustratedin the following figure.

     Figure 17.5 Illustration of completion of the first subtree

     Again, we will look at the other subtree of the solution space, beginningwith the node, as illustrated in the figure below:

     Figure 17.6 Illustration of the solution of the other subtree

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    7/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 7 of 18

    BacktrackingPage 15 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page15of 48

    Only possible placement is at (2, 4), Let’s follow

    the search tree for the (2, 4) placement, then

    again, we draw it horizontally as illustrated below:

     BacktrackingPage 16 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page16of 48

    Remember that there is only one alternative for

    positioning the queen in the third column because

    of the following reasons:

     

    BacktrackingPage 17 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page17of 48

    Alternative for placing the queen in the fourth

    column since:

     

    In reality, the student will note immediately that the options for placing incolumn 2 are quite constrained placing at (2, 1) gives a diagonal conflict,placing at (2, 2) gives a row conflict, and placing at (2, 3) gives adiagonal conflict. Therefore, the only possible placement is at (2, 4).

    Let’s follow the search tree for the (2, 4) placement, then again, we drawit horizontally, as illustrated in the figure below:

     Figure 17.7 Illustration of the solution of the other subtree

    In the given illustration, we should remember that there is only onealternative for positioning the queen in the third column since:

     Figure 17.8 Illustration of the reason why there is only one alternative for positioningthe queen in the third column

    Similarly, there is only one alternative for placing the queen in the fourthcolumn, since :

     Figure 17.9 Illustration of the reason why there is only one alternative for positioning

    the queen in the third column

    [Backtracking, Pages 4-17 of 47] 

    •positioning a queen at(4, 1) will result a row

    conflict with Q31

    •positioning a queen at(4, 2) will result a row

    conflict with Q12

    •positioning a queen at

    (4, 4) will result a row

    conflict with Q23

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    8/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 8 of 18

    Branch and BoundPage 18 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page18of 48

    Branch and Bound is most commonly applied to

    optimization problems.

    Bounding solution does not satisfy the constraints

    but can be shown to be a bound for any optimal

    solution.

     

    Branch and Bound

    Branch and bound is most commonly applied to optimization problems,although it can be applied to any problem generated by stages in whichthere are easy methods to rank the solutions.

    Since the branch-and-bound technique is generally applied tooptimization problems, it would be helpful to remember some of theterminologies. Basically, we are presented with a problem in which wewant to optimize some target function subject to constraints. On theother hand, a bounding solution does not satisfy the constraints but canbe shown to be a bound for any optimal solution. For instance, in theassignment problem, it calls for creating assignments in a way tominimize cost. We can easily come up at a bounding solution for thisproblem that gives a value that will be considered as a strong lowerbound on the objective function for any optimal solution. Though, it ispossible that the bounding solution will suit the constraints, consequentlyit is not a feasible solution and therefore unacceptable as an optimalsolution.

    Branch and BoundPage 19 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page19of 48

    Assessing the Problem State Space Tree

    Branch-and-bound algorithm design technique

    is useful to a problem in which a solution can

    be viewed as generating nodes in a state-

    space tree.

    The leaf nodes can represent a solution to the

    problem, which may not be a reasonable

    solution.

    Usually, the root node denotes the problem

    prior to any decisions made, like the chess

    board before any queens has been placed or

    the job status before anybody has been

    assigned a job.

     

     Assessing the Problem State-Space Tree

    The branch-and-bound algorithm design technique is useful to aproblem in which a solution can be viewed as generating nodes in astate-space tree. The leaf nodes can represent a solution to theproblem, which may not be a reasonable solution. On the other hand,the internal nodes of the tree correspond to partial solutions to theproblem. This will then, produce the state-space tree one node at a time,starting with the root node, which is used to specify the starting point forall solutions. Usually, the root node denotes the problem prior to anydecisions made, like the chess board before any queens has beenplaced or the job status before anybody has been assigned a job. 

    Branch and BoundPage 20 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page20of 48

    Usually, in the state-space tree the previously

    generated node must be able to assess the node

    and specifically we ask the following questions.

    1. How does the partial solution compare to the

    best existing solution?

    2. Is the solution represented by this node a

    feasible solution?

     

    In the state-space tree, the previously generated node must be able toassess the node and specifically we ask the following questions.

    1. How does the partial solution compare to the best existingsolution?

    2. Is the solution represented by this node a feasible solution?

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    9/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 9 of 18

    Branch and BoundPage 21 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page21of 48

    To make the branch-and-bound work, it is

    necessary to assess each node just generated as

    the root node of a tree that represents all

    solutions that can be generated based on the

    partial solution we have just generated.

    Therefore, we “prune” the search tree if any of the

    following holds:

    1. It can prove that no solution in the subtree will

    gratify the problem constraints.

    2. It can prove that no solution in the subtree will

    be better than the best solution produced

    thus far.

    3. The node created symbolizes an absolute

    feasible solution that can be compared to the

    best solution so far generated and possibly

    replace it.

     

    To make the branch-and-bound work, it is necessary to assess eachnode generated as the root node of a tree that represents all solutionsand can be produced based on the partial solution we have justgenerated. Therefore, we “prune” the search tree if any of the followingoccurs:

    1. It can prove that no solution in the subtree will gratify theproblem constraints.

    2. It can prove that no solution in the subtree will be better than thebest solution produced thus far.

    3. The node created symbolizes an absolute feasible solution thatcan be compared to the best solution so far generated andpossibly replace it.

    Branch and BoundPage 22 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page22of 48

    Live node: is a node that can possibly represent a

    partial solution leading to an optimal solution of

    the whole problem.

    If we can assess the live nodes as to the best

    solution that can be associated with the node’s

    subtree, we can apply best first branch and bound

    The key approach to branch-and-bound is to view

    each newly generated node as the root node of a

    subtree leading to a set of solutions.

     Branch and BoundPage 23 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page23of 48

    We first choose the assignment problem, which

    amounts to assigning each of N workers to N jobs

    so that the total costs of the jobs are minimized.

    We are given an N-by-N matrix describing the cost

    for each worker to do each job

    It should be noted that this method can be used to

    assign N workers to M jobs, with M < N.

    This is done by creating (N – M) dummy jobs, each

    with a cost representing the expense of having a

    worker do nothing.

    We shall assume one job per worker.

     

    Live node is a node that can possibly represent a partial solution leadingto an optimal solution of the whole problem.

    If we assess the live nodes as to the best solution that can beassociated with the node’s subtree, we can apply best-first branch-and-bound , which is a deviation that repeatedly examines the best nodegenerated so far. There are different ways of evaluating a node, forinstance, suppose we are looking for a least-cost solution. Since costsare typically non-negative and are additive, we can assess the cost of aninterior node and its subtree as being the cost of the solution up to thatpoint. On the other hand, it may be possible to estimate a remainingcost coupled with producing the rest of the subtree and add that to thevertex cost.

    Here, we make an obvious and almost-useless observation. One way toassess any solution in a subtree rooted at an interior node is to expandthat subtree and assess all of its leaf nodes. We are looking for a muchfaster way to assess subtrees.

    Thus, the key approach to branch-and-bound is to view each newlygenerated node as the root node of a subtree leading to a set ofsolutions. We want a reasonably fast way to make a useable evaluationof each of these subtrees, so that we may chase the best options.

    To further understand the branch-and-bound algorithm technique, wewill examine an example. We first choose the assignment problem,which amounts to assigning each N worker to N jobs so that the totalcosts of the jobs are minimized. We are given an N-by-N matrixdescribing the cost for each worker to do each job.

    It should be noted that this method can be used to assign N workers toM jobs, with M < N. This is done by creating (N – M) dummy jobs, eachwith a cost representing the expense of having a worker do nothing. Weshall assume one job per worker.

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    10/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 10 of 18

    Branch and BoundPage 24 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page24of 48

    Consider the matrix of costs. E ach row in the

    matrix represents a worker and each column

    represents a job. The constraints of a feasible

    solution are:

    1. We pick one entry from each row,

    corresponding to the assignment of exactly

    one worker to a job.

    2. We pick one entry from each column, so that

    each job has someone working on it.

     

    Consider the matrix of costs. Each row in the matrix represents aworker and each column represents a job. The constraints of a feasiblesolution are:

    1. We pick one entry from each row, corresponding to theassignment of exactly one worker to a job.

    2. We pick one entry from each column, so that each job has

    someone working on it.

    Branch and BoundPage 25 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page25of 48

    Set another method, a feasible solution

    corresponds to the selection of one entry in each

    row of the matrix so that no two selected elements

    are in the same column.

    An optimal solution is that feasible solution of

    lowest cost.

     

    Set another method, a feasible solution corresponds to the selection ofone entry in each row of the matrix so that no two selected elements arein the same column.

    The table below shows the matrix representing the Worker problem:

    Job 1 Job 2 Job 3 Job 4

    Worker A 9 2 7 8 

    Worker B 6 4 3 7 

    Worker C 5 8 1 8 

    Worker D 7  6  9  4 

    Table 17.1 Sample problem table

    We first describe the bounding solutions. It is obvious that the total

    cost of the jobs must include a cost for each worker and this cost cannotbe less than what each worker is working as cheaply as possible. Thus,the sum of the lowest cost in each row is a lower bound on the cost ofthe job. One may likewise make a column argument, saying that each

     job has to be done at a cost by a worker.

    Branch and BoundPage 26 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page26of 48

    For the first bounding solution, find the minimum

    cost per row and add it up.

     

    For the first bounding solution, find the minimum cost per row and add itup.

    Job 1  Job 2  Job 3  Job 4  Minimum 

    Worker A 9 2 7 8 2 Worker B 6 4 3 7 3 

    Worker C 5 8 1 8 1 

    Worker D 7 6 9 4 4 

    10

    Table 17.2 First bounding solution

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    11/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 11 of 18

    Branch and BoundPage 27 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page27of 48

    For the second bounding solution consider the

    column minimum.

     

    Remember that the first bounding solution is not a feasible solution, asJob 3 is assigned to two workers. Nevertheless, this is a lower boundon the cost. For the second bounding solution, consider the columnminimum.

    Job 1 Job 2 Job 3 Job 4  Minimum 

    Worker A 9 2 7 8 2 Worker B 6 4 3 7 0 

    Worker C 5 8 1 8 6 

    Worker D 7 6 9 4 4 

    Minimum 5 2 1 4  12 

    Table 17.3 Second bounding solution

     Again, the solution is not feasible since Worker C has two jobs to do.Nevertheless, we have a better lower bound on the cost. Given twoequally valid lower bounds on a cost function, we may choose the higherone as our best guess – that is 12.

    Branch and BoundPage 28 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page28of 48

    We need something generated quickly and

    guaranteed to be feasible, so we pick as follows,

     just moving down the diagonal of the matrix.

     

    We now generate a feasible solution to be used as a guide to ourbranch-and-bound solution. We need something generated quickly andguaranteed to be feasible, so we will select the following jobs by movingdown the diagonal of the matrix.

    Job 1 Job 2 Job 3 Job 4 

    Worker A 9 2 7 8 

    Worker B 6 4 3 7 

    Worker C 5 8 1 8 

    Worker D 7  6  9  4 

    Table 17.4 Diagonal matrix

    The total cost associated with this feasible solution is 9 + 4 + 1 + 4 = 18.Thus, we know that the limits on any optimal solution are 12 and 18.

    We can either assign by rows (jobs to workers) or by columns (workersto jobs). The root of the state-space tree is the start node, indicatingthat no assignment has been made. This has 4 child nodes (in general,it has N child nodes), one for each of the 4 jobs that can be assigned tothe first worker.

    Branch and BoundPage 29 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page29of 48

    For the first bounding solution, find the minimum

    cost per row and add it up.

     

    Branch and BoundPage 30 of 47

    Copingwith theLimitationso f algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page30of 48

    For the second bounding solution consider the

    column minimum.

    The total cost associated with this feasible

    solution is 9 + 4 + 1 + 4 = 18. Thus we know that

    the limits on any optimal solution are 12 and 18

     

    Branch and BoundPage 31 of 47

    Copingwith theLimitationso f algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page31of 48

    We need something generated quickly and

    guaranteed to be feasible, so we pick as follows,

     just moving down the diagonal of the matrix.

     

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    12/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 12 of 18

    Branch and BoundPage 32 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page32of 48

    We now generate a version of the search tree and

    consider how to improve it.

    We label each node with the total cost of the

    allocation so far, here just the cost of the job.

     

    We now generate a version of the search tree and consider how toimprove it. We label each node with the total cost of the allocation sofar, the figure below includes the cost of each job.

     Figure 17.10 Illustration that shows the cost of each job

    Branch and BoundPage 33 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page33of 48

    Let’s return to the examination of minimum costs

    per row. The table is repeated here for easy

    reference.

    The lower bound for the rest of the workers, after

    Worker A has been assigned a job, is 3 + 1 + 4 =

    8.

     Although this is a valid approach, we can improve it considerably.Consider again the table on the examination of minimum costs per row.

    Job 1  Job 2  Job 3  Job 4  Minimum 

    Worker A 9 2 7 8 2 

    Worker B 6 4 3 7 3 

    Worker C 5 8 1 8 1 

    Worker D 7  6  9  4  4 

    Table 17.5 Illustrates the minimum cost of each job

    Note that the lower bound for the rest of the workers, after Worker A hasbeen assigned a job, is 3 + 1 + 4 = 8. Thus, we may immediately

    generate a lower bound  on any partial solution: the total cost of thepartial solution plus the minimum cost of the remaining assignments.With that in mind, we arrive at a new start to the search tree (refer to thefigure below).

    Branch and BoundPage 34 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page34of 48

    Thus, we may immediately generate a lower bound

    on any partial solution:

    The total cost of the partial solution plus the

    minimum cost of the remaining assignments.

    With that in mind, we arrive at a new start to the

    search tree.

     

     Figure 17.11 Illustrates the cost of the partial solution plus the minimum cost

    These lower bounds on cost are an improvement, and considered as thenode labeled “A gets job 3”. Under that assignment, no other workercan get job 3, so the row minimal must select from columns 1, 2, and 4.

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    13/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 13 of 18

    Branch and BoundPage 35 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page35of 48

    Here are the adjusted matrices to be used in

    assessing the subtrees:

    Here are the adjusted matrices to be used in

    assessing the subtrees.

    A gets job1 with cost = 9

     

    Here are the adjusted matrices to be used in assessing the subtrees.

     A gets job 1 with cost = 9

    Job 2  Job 3  Job 4  Minimum 

    Worker B 4 3 7 3 

    Worker C 8 1 8 1 Worker D 6  9  4  4 

    Table 17.6 Resulting table if A gets job 1 with cost = 9

    The subtree assesses at 8, so the total lower bound is 17, as shownabove.

    Branch and BoundPage 36 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page36of 48

    A gets job 2 with cost = 2

    The subtree assesses again at 8, so the total

    lower limit is 10

     

     A gets job 2 with cost = 2

    Job 1 Job 3 Job 4 Minimum 

    Worker B 6 3 7 3 

    Worker C 5 1 8 1 

    Worker D 7  9  4 4 

    Table 17.7 Resulting table if A gets job 2 with cost = 2

    The subtree assesses again at 8, so the total lower limit is 10, as shownabove.

    Branch and BoundPage 37 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page37of 48

    A gets job 3 with cost = 7

    Here we have a new assessment for the subtree –

    a new lower limit of 13, so that the total lower limit

    evaluation of the node is 20

     

     A gets job 3 with cost = 7

    Job 1 Job 2 Job 4 Minimum

    Worker B 6 4 7 4 

    Worker C 5 8 8 5 

    Worker D 7  6  4 4 

    Table 17.8 Resulting table if A gets job 3 with cost = 7

    Here, we have a new assessment for the subtree  – a new lower limit of13, so the total lower limit evaluation of the node is 20.

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    14/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 14 of 18

    Branch and BoundPage 38 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page38of 48

    A gets job 4 with cost = 8

    Here we also have a new assessment for the

    subtree – a new lower limit of 10, so that the total

    lower limit evaluation is 18.

     

     A gets job 4 with cost = 8

    Job 1 Job 2 Job 3 Minimum

    Worker B 6 4 3 3 

    Worker C 5 8 1 1 

    Worker D 7  6 9  6 

    Table 17.9 Resulting table if A gets job 4 with cost = 8

    Here, we also have a new assessment for the subtree  –  a new lowerlimit of 10, so the total lower limit evaluation is 18.

    Branch and BoundPage 39 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page39of 48

    Given these more computationally intensive

    calculations, we have the following for the

    problem state-space tree.

     

    Given these intensive calculations, we have the following for theproblem state-space tree.

     Figure 17.12 Problem-state space tree

    Branch and BoundPage 40 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page40of 48

    One of the nodes – “A gets job 3” – has a lower

    bound exceeding the cost of a known feasible

    solution.

    For this reason it is pruned and the remaining tree

    is as follows.

     

    Note what this complex and accurate lower bound calculation has givenus. One of the nodes  – “A gets job 3” – has a lower bound exceedingthe cost of a known feasible solution. With this reason, it is pruned andthe remaining tree is as follows:

     Figure 17.13 Pruning of tree

    Let’s now begin working on the best looking node “A gets job 2” andconsider Worker B. If Worker A gets job 2, then Worker B can have jobs

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    15/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 15 of 18

    1, 3, or 4.

    Branch and BoundPage 41 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page41of 48

    Here are the three possibilities for this subtree.

    A gets job 2 B gets job 1

    The remaining jobs assess at 5, so the node

    assesses at a value of 13.

     

    Here are the three possibilities for this subtree.

     A gets job 2, B gets job 1

    The total cost is 2 + 6 = 8. The matrix for the rest of the jobs andworkers is:

    Job 3 Job 4 Minimum

    Worker C 1 8 1 

    Worker D 9  4 4 

    Table 17.10 Resulting table after getting the total cost

    The remaining jobs assess at 5, so the node assesses at value 13.

    Branch and BoundPage 42 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page42of 48

    A gets job 2 B gets job 3

    The total cost is 2 + 3 = 5.

    The matrix for the rest of the jobs and workers is

    The remaining jobs assess at 9, so the node

    assesses at a value of 14.

     

     A gets job 2, B gets job 3

    The total cost is 2 + 3 = 5. The matrix for the rest of the jobs andworkers is:

    Job 1 Job 4 Minimum

    Worker C 5 8 5

    Worker D 7 4  4

    Table 17.11 Resulting table if   A gets job 2, B gets job 3

    The remaining jobs assess at 9, so the node assesses at value 14.

    Branch and BoundPage 43 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page43of 48

    A gets job 2 B gets job 4

    The total cost is 2 + 7 = 9.

    The matrix for the rest of the jobs and workers is

    The remaining jobs assess at 8, so the node

    assesses at a value of 17

     

     A gets job 2, B gets job 4

    The total cost is 2 + 7 = 9. The matrix for the rest of the jobs andworkers is:

    Job 1 Job 3 Minimum

    Worker C 5 1 1 

    Worker D 7  9  7 

    Table 17.12 Resulting table if   A gets job 2, B gets job 4

    The remaining jobs assess at 8, so the node assesses at value 17.

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    16/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 16 of 18

    Branch and BoundPage 44 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page44of 48

    Here is the state-tree after the node “A gets job 2”

    has been expanded.

    At this point, we have five live nodes to consider.

    These are labeled as

    1) “A gets job 1”,

    2) “B gets job 1”,

    3) “B gets job 3”,

    4) “B gets job 4”, and

    5) “A gets job 4”.

     

    The figure below shows the state-tree after the node “A gets job 2” hasbeen expanded.

     Figure 17.14 Illustrates the state-space tree

     At this point, we have five live nodes to consider. These are labeled as:1) “A gets job 1”,2) “B gets job 1”, 3) “B gets job 3”, 4) “B gets job 4”, and 5) “A gets job 4”. 

    Branch and BoundPage 45 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page45of 48

    The best looking node is the one labeled “B gets

     job 1” with a lower bound of 13.

    We consider two possibilities for the subtree

    rooted at this partial solution.

    Recall our matrix of choices for workers and D.

    A gets job 2 B gets job 1

    The total cost is 2 + 6 = 8. The matrix for workers

    C and D is

     

    The best node is the one labeled “B gets job 1” with a lower bound of 13.We consider two possibilities for the subtree rooted at this partialsolution. Recall our matrix of choices for workers C and D.

     A gets job 2, B gets job 1

    The total cost is 2 + 6 = 8. The matrix for workers C and D is:

    Job 3 Job 4 Minimum

    Worker C 1 8 1 

    Worker D 9  4 4 

    Table 17.13 Resulting table if A gets job 2, B gets job 1

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    17/18

     Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 17 of 18

    Branch and BoundPage 46 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI 

    Page46of 48

    Here is the status: we have two feasible solutions,

    one with total cost of 13.

    We have four non-terminal live nodes, none of

    which have a lower bound less than 14.

     Figure 17.15 Illustrates the state-space tree

    Branch and BoundPage 47 of 47

    Copingwith theLimitations of algorithm Power 

    Designand Analysisof Algorithm

    * Property of STI Page47of 48

    So we have a solution: A gets job 2, B gets job 1,

    C gets job 3, and D gets job 4.

    The solution generated 9 of the possible (4 + 12 +

    24) 40 nodes – an 75% saving.

     

    We have four non-terminal live nodes, none of which have a lowerbound less than 14. So we have a solution: A gets job 2, B gets job 1,C gets job 3, and D gets job 4.

    The solution generated 9 of the possible (4 + 12 + 24) 40 nodes – a 75%saving.

    [Branch and Bound, Pages 18-47 of 47]

    GENERALIZATION:

    o  It is important to understand what makes a problem difficult andeasy. We can say that a problem is easy if and only if there is atleast one algorithm that solves every instance of the problemefficiently.

    o  Backtracking is a refinement of the exhaustive search strategywhere solutions to a problem are developed and evaluated onestep at a time.

    o  Branch and bound is commonly applied to optimizationproblems, although it can be applied to any problem generatedby stages in which there are easy method to rank the solutions. 

  • 8/21/2019 MELJUN CORTES ALGORITHM_Coping With the Limitations of Algorithm Power

    18/18

     

    Design and Analysis of Algorithm

    Coping with the Limitations of Algorithm Power *Property o f STIPage 18 of 18

    REFERENCES:

    §  http://www.csc.lsu.edu/~karki/DA-08/DA21.pdf§  http://csc.colstate.edu/Bosworth/cpsc5115/LectureNotes/CPSC

    5115_Ch11.htm

    §  Anany Levitin,(2007), The design and analysis of algorithm (2nd

    ed.), Pearson Education Inc.