35
Copyright R. Weber Search in Problem Search in Problem Solving Solving INFO 629 INFO 629 Dr. R. Weber Dr. R. Weber

Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Embed Size (px)

Citation preview

Page 1: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Search in Problem Search in Problem SolvingSolving

INFO 629INFO 629

Dr. R. WeberDr. R. Weber

Page 2: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

OutlineOutline problem-solvingproblem-solving algorithmsalgorithms parts of a problem: formulationparts of a problem: formulation state space modelstate space model example problemsexample problems general search algorithmgeneral search algorithm search strategiessearch strategies additional problems and strategiesadditional problems and strategies

Page 3: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Problem solvingProblem solving

What if deductive reasoning does not work?What if deductive reasoning does not work? What if case-based reasoning does not What if case-based reasoning does not

work?work? What if inductive reasoning does not work?What if inductive reasoning does not work?

Page 4: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Problem solving (ii)Problem solving (ii) Some problems motivate us to list all its Some problems motivate us to list all its

possible solutions, these are well possible solutions, these are well understood problems. understood problems. E.g., travel from Philly to NYCE.g., travel from Philly to NYC

Some problems have clear allowed actions Some problems have clear allowed actions but you don’t know which ones will take but you don’t know which ones will take you to the solution. you to the solution. E.g., some puzzles, route to arrive at the E.g., some puzzles, route to arrive at the train station in Hartfordtrain station in Hartford

Page 5: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Problem solving (iii)Problem solving (iii) Others have clear allowable actions but you don’t know Others have clear allowable actions but you don’t know

which will take you to the goal more efficiently (faster, which will take you to the goal more efficiently (faster, cheaper, economical design). cheaper, economical design). E.g., designing a chip, design layout of parts in autoclave, E.g., designing a chip, design layout of parts in autoclave, schedule parts for production, schedule experts in call schedule parts for production, schedule experts in call center.center.

Others also have constraints and may not be feasible. E.g. Others also have constraints and may not be feasible. E.g. travel planning, schedule exams for university.travel planning, schedule exams for university.

Others you are simply not capable of solving because of Others you are simply not capable of solving because of combinatorial explosion. E.g., travel salesmancombinatorial explosion. E.g., travel salesman

Page 6: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

SearchSearch search search consists of a set of methods consists of a set of methods

to systematically determine the next to systematically determine the next best action in order to search for a best action in order to search for a solution of a problemsolution of a problem

parts of a problem: initial state, parts of a problem: initial state, operators, goal test function, (path operators, goal test function, (path cost function).cost function).

Page 7: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

AlgorithmAlgorithm a search algorithm takes a problem as a search algorithm takes a problem as

input and returns a solution in the form of input and returns a solution in the form of an action sequence.an action sequence.

Formulate the problem in terms of Formulate the problem in terms of sequences of actions to perform sequences of actions to perform searchsearch

Environment: state space, path, solution.Environment: state space, path, solution. State space consists of all possible states State space consists of all possible states

e.g., (3,3,1), (1,1,0), (0,0,0), (2,2,1)e.g., (3,3,1), (1,1,0), (0,0,0), (2,2,1) Path represents the steps taken to reach a Path represents the steps taken to reach a

solutionsolution

Page 8: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

CANNIBALS AND CANNIBALS AND MISSIONARIESMISSIONARIES

http://www.dc.fi.udc.es/lidia/mariano/demos/Misioneros-Canibales/http://www.dc.fi.udc.es/lidia/mariano/demos/Misioneros-Canibales/cannibal.htm cannibal.htm

An example:An example:

Page 9: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

CANNIBALS AND CANNIBALS AND MISSIONARIES MISSIONARIES

initial state is (3,3,1)initial state is (3,3,1) operators are five: CC, MM, CM, C, Moperators are five: CC, MM, CM, C, M goal test is (0,0,0)goal test is (0,0,0) path cost: number of crossingspath cost: number of crossings

STATE SPACE MODEL

Page 10: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Problem Solving with SearchProblem Solving with Search

• Formulate problemFormulate problem goal and problem formulationgoal and problem formulation

• Choose search algorithmChoose search algorithm determine the next best action in order to determine the next best action in order to

search for a solution of a problemsearch for a solution of a problem• ExecuteExecute

execute search method until solution is execute search method until solution is foundfound

Page 11: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

General Search AlgorithmGeneral Search Algorithm identify initial stateidentify initial state expand (generate new states)expand (generate new states) choose optionchoose option test goal functiontest goal function expand until goal not attained/no more expand until goal not attained/no more

states to expandstates to expand

Page 12: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

The NY tourist algorithmThe NY tourist algorithm1.identify initial state:- you are in a corner in NY

2.expand (use operators to generate new states)- identify legal operations3.choose option (search strategy)- always make a right if you can otherwise go left- go to the side which is closest to your visual view of the goal

4.test goal function:Are you there yet?

5.If goal not attained (and there are still states to expand), continue from 2

Page 13: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Example problemsExample problems

toy problemstoy problems used to test search algorithmsused to test search algorithms

real world problemsreal world problems used to solve real problemsused to solve real problems

Page 14: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Toy problemsToy problems

Page 15: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

The 8-puzzle The 8-puzzle (Russel&Norvig)(Russel&Norvig)

Page 16: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Cryptarithmetic Cryptarithmetic (Russel&Norvig)(Russel&Norvig)

Page 17: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

General puzzles algorithm General puzzles algorithm 1.1. identify initial state as originidentify initial state as origin

2.2. expand to all possible locationsexpand to all possible locations

3.3. the blank space changes place with tile on its the blank space changes place with tile on its rightright

4.4. test goal function, is it the destiny?test goal function, is it the destiny?

5.5. if yes, return configurationif yes, return configurationelse, return to 2else, return to 2

Page 18: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Real world problemsReal world problems

Page 19: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Applications of route findingApplications of route finding

Route planningRoute planning Routing in computer networksRouting in computer networks Automated travel advisory systemsAutomated travel advisory systems Airline travel planningAirline travel planning Garbage collection/cleaning trucksGarbage collection/cleaning trucks Food/document deliveryFood/document delivery Does this mean that search is the only Does this mean that search is the only

method to perform route planning??method to perform route planning??

Page 20: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

General route finding algorithm General route finding algorithm

1.1. identify initial state as originidentify initial state as origin

2.2. expand to all possible locationsexpand to all possible locations

3.3. choose location with smallest cost/fastest choose location with smallest cost/fastest route/favor highwaysroute/favor highways

4.4. test goal function, is it the destiny?test goal function, is it the destiny?

5.5. if yes, return locationif yes, return locationelse, return to 2else, return to 2

Page 21: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Traveling salesperson problemsTraveling salesperson problems

is a category of problemsis a category of problems each city has to be visited onceeach city has to be visited once goal is to find the shortest tourgoal is to find the shortest tour

Exams in universityExams in university Nurses in hospitalsNurses in hospitals Experts in call centersExperts in call centers

SchedulingScheduling

Page 22: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

VLSI layoutVLSI layout

Very large scale integrationVery large scale integration Design of silicon chipDesign of silicon chip Define the position and connections of a million gates Define the position and connections of a million gates

in a chipin a chip Tasks: cell layout, channel routingTasks: cell layout, channel routing Goal is to min area & connection lengthGoal is to min area & connection length

Page 23: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Robot navigationRobot navigation

Generalization of route finding problemGeneralization of route finding problem Any route can be chosen in a continuous spaceAny route can be chosen in a continuous space Possible actions and states in a continuous space are Possible actions and states in a continuous space are

infiniteinfinite The more actions a robot can perform the more The more actions a robot can perform the more

dimensions are needed to describe states and actionsdimensions are needed to describe states and actions To identify the result of an action, a robot must use To identify the result of an action, a robot must use

visionvision

Page 24: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Assembly sequencingAssembly sequencing

Many industries use automatic assembly of Many industries use automatic assembly of objectsobjects

Find an order to assemble parts of an objectFind an order to assemble parts of an object Find an order to submit parts to a given processFind an order to submit parts to a given process

Design for autoclave layoutDesign for autoclave layout

Layout DesignLayout Design

Page 25: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Constraint Satisfaction ProblemConstraint Satisfaction Problem1.1. Initial is given by values of variablesInitial is given by values of variables

2.2. Expand to all possible valuesExpand to all possible values

3.3. Variables change valuesVariables change values

4.4. Do the variables’ values respect constraints?Do the variables’ values respect constraints?

5.5. if yes, return valuesif yes, return valueselse, return to 2else, return to 2

Another class of problemsAnother class of problems Design and scheduling problemsDesign and scheduling problems Algorithms designed specifically for CSP perform Algorithms designed specifically for CSP perform

better than general onesbetter than general ones

Page 26: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Constraint Satisfaction Constraint Satisfaction SearchSearch

type of formulation indicated for many type of formulation indicated for many design and scheduling problemsdesign and scheduling problems

specific algorithms for CSP assign values specific algorithms for CSP assign values for all variables and iteratively improve the for all variables and iteratively improve the solution within the area of the constraintssolution within the area of the constraints

scheduling, PERT/CPMscheduling, PERT/CPM

project planning and managementproject planning and management4242

Page 27: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Search strategiesSearch strategies

Page 28: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Uninformed search Uninformed search strategiesstrategies

breadth-first searchbreadth-first search uniform cost searchuniform cost search depth-first searchdepth-first search depth-limited depth-limited

searchsearch iterative deepening iterative deepening

searchsearch bidirectional searchbidirectional search

Informed /heuristic Informed /heuristic strategiesstrategies

best-first searchbest-first search A*A* Heuristic functionsHeuristic functions memory bounded memory bounded

searchsearch simulated simulated

annealingannealing Hill-climbingHill-climbing

Page 29: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Breadth-first searchBreadth-first search

all nodes at all nodes at depth ddepth d are expanded before the are expanded before the nodes at depth d+1nodes at depth d+1

if there is a solution, it will findif there is a solution, it will find if there are more than one, it will find the if there are more than one, it will find the

shallowestshallowest planning puzzles; large memory planning puzzles; large memory

requirementsrequirements

Page 30: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Depth-first searchDepth-first search

expands the deepest node to the deepest level of a expands the deepest node to the deepest level of a treetree

only expands nodes at shallower levels after reaching only expands nodes at shallower levels after reaching the endthe end

it does not guarantee a solution it does not guarantee a solution (neither complete or optimal)(neither complete or optimal)

less memory requirementsless memory requirements may be faster than breadth-first, but it may get stuck may be faster than breadth-first, but it may get stuck

on a bad pathon a bad path

Page 31: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Depth-limited searchDepth-limited search imposes a bound on the maximum depth of a pathimposes a bound on the maximum depth of a path guarantees that a solution is found if it existsguarantees that a solution is found if it exists

Iterative deepening searchIterative deepening search tries to bound the search iterativelytries to bound the search iteratively it is optimal and completeit is optimal and complete implement depth first search up to the Nth level. N implement depth first search up to the Nth level. N

should start at either 0 or 1 and be incremented after should start at either 0 or 1 and be incremented after each search up to N is complete.each search up to N is complete.

Page 32: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Uniform cost searchUniform cost search

expands the lowest-cost nodeexpands the lowest-cost node to find the best solution it requires that all operators to find the best solution it requires that all operators

have positive costs (the cost of a path does not have positive costs (the cost of a path does not decrease as we go along that path)decrease as we go along that path)

route-findingroute-finding

Page 33: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Bidirectional searchBidirectional search

start searching from the origin and start searching from the origin and from the goal and stop when from the goal and stop when searches meetsearches meet

Page 34: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Informed strategiesInformed strategies

best-first searchbest-first search nodes are ordered by an evaluation functionnodes are ordered by an evaluation function

A*A* uses an estimated costuses an estimated cost

Heuristic functionsHeuristic functions memory bounded searchmemory bounded search simulated annealingsimulated annealing

to escape local maximato escape local maxima

Hill-climbingHill-climbingcontinually moves in the direction of increasing valuecontinually moves in the direction of increasing value

Page 35: Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber

Copy

right

R. W

eber

Search strategiesSearch strategies

When do you solve a problem using a search When do you solve a problem using a search strategy?strategy?

When there is an algorithm to solve it when:When there is an algorithm to solve it when: it is guaranteed to find a solutionit is guaranteed to find a solution when it finds a solution in a timely mannerwhen it finds a solution in a timely manner when the memory requirements are reasonablewhen the memory requirements are reasonable when it can find the best solution or at least one of when it can find the best solution or at least one of

the bestthe best sometimes, one can combine searches to improve sometimes, one can combine searches to improve

the quality of a solutionthe quality of a solution