Upload
sirfanalizaidi
View
216
Download
0
Embed Size (px)
Citation preview
7/27/2019 Introduction to AI Unit 4
1/8
3/5/2
Introduction to Artificial
Intelligence
Unit # 4
Artif icial Intelligence Lab, IBA 1Spring2011
Acknowledgement
The slides of this lecture have been taken from
the lecture slides of CS307 Introduction to
Artificial Intelligence by Dr. Sajjad Haider.
Artificial Intelligence Lab, IBA 2Spring2011
A* search
Idea: avoid expanding paths that are already
expensive
Evaluation function f(n) = g(n) + h(n)
g(n) = cost so fa r to reach n
h(n) = es tima ted cost from n to goal
f(n) = e sti mated total cost of path through n to
goal
Artif icial Intelligence Lab, IBA 3Spring2011
A* Search
(Using Heuristic # 1)
We add a depth factor
to f: f(n) = g(n) + h(n).
g(n) is an estimate of the
depth of n in the graph.
h(n) is a heuristic
evaluation of node n.
Artificial Intelligence Lab, IBA 4Spring2011
7/27/2019 Introduction to AI Unit 4
2/8
3/5/2
A* Search(Using Heuristic # 2)
Expand the tree
Goal State
2 8 3
1 6 4
7 5
Artif icial Intelligence Lab, IBA 5Spring2011
N-Queen
The N-queens problem is a
search problem where the
desired result is an N by N board
with N queens such that no
queen threatens another
The problem can be simplified
by assigning a queen to each
row on the board.
Enumerating the search space is
then defined as looking at the
possible moves of queens
horizontally.
Artificial Intelligence Lab, IBA 6Spring2011
Romania with step costs in km
(Russell & Norvig)
Artif icial Intelligence Lab, IBA 7Spring2011
Best-first search example
Artificial Intelligence Lab, IBA 8Spring2011
7/27/2019 Introduction to AI Unit 4
3/8
3/5/2
Best-first search example
Artif icial Intelligence Lab, IBA 9Spring2011
Best-first search example
Artificial Intelligence Lab, IBA 10Spring2011
Best-first search example
Artif icial Intelligence Lab, IBA 11Spring2011
A* search example
Artificial Intelligence Lab, IBA 12Spring2011
7/27/2019 Introduction to AI Unit 4
4/8
3/5/2
A* search example
Artif icial Intelligence Lab, IBA 13Spring2011
A* search example
Artificial Intelligence Lab, IBA 14Spring2011
A* search example
Artif icial Intelligence Lab, IBA 15Spring2011
A* search example
Artificial Intelligence Lab, IBA 16Spring2011
7/27/2019 Introduction to AI Unit 4
5/8
3/5/2
A* search example
Artif icial Intelligence Lab, IBA 17Spring2011
The Modified Traveling Salesman Problem
Each node represents a town,and the vertices betweennodes represent roads that jointowns together.
A is the starting node, and F isthe goal node.
Each vertex is labeled with adistance, which shows howlong that road is.
The aim of this problem is tofind the shortest possible pathfrom city A to city F.
Artificial Intelligence Lab, IBA 18Spring2011
Search Tree for the Modified TSP
Artif icial Intelligence Lab, IBA 19Spring2011
Search Demo
http://www.cs.rochester.edu/u/kautz
/Mazes/search_algorithm_demo.htm
Artificial Intelligence Lab, IBA 20Spring2011
7/27/2019 Introduction to AI Unit 4
6/8
3/5/2
Result
Artif icial Intelligence Lab, IBA 21Spring2011
Karachi Path Finding by Google
Artificial Intelligence Lab, IBA 22Spring2011
Karachi Path Finding by Google
(Contd)
Artif icial Intelligence Lab, IBA 23Spring2011
Karachi Path Finder Developed at IBA
Artificial Intelligence Lab, IBA 24Spring2011
7/27/2019 Introduction to AI Unit 4
7/8
3/5/2
Informed vs. Uniformed Search
A se arch method or heuristic i s informed if it usesaddi tional information about nodes that have not yetbee n e xplored to decide which no des to examinenext.
If a me thod is not informed, it is uninformed orblind.
Bes t-first search is an e xample of i nformed search,wherea s breadth-first and depth-first s earch areuni nformed or blin d.
The more in formed a s earch method is, the moreeffi ciently it will se arch.
Artif icial Intelligence Lab, IBA 25Spring2011
Summary: Search
Depth-first s earch and breadth-first search are extremelycommonly used and well understood exhaustive searchmethods.
A search method is complete if it will always find a solutionif one exists. A se arch method is optimal (or admiss ible) if italways finds the bes t solution that exists.
Heuris tics can be use d to make search methods moreinformed about the proble m they are solving. A heuristic is amethod that provides a bett er guess about the correctchoice to make at any junction that would be achieved byrandom guess ing.
One heuris tic i s more informed than another heuristic if asearch method that use s it needs to examine fewer nodes toreach a goal.
Artificial Intelligence Lab, IBA 26Spring2011
More Search
Greedy Algorithm(Source: Wikipedia)
Greedy algorithms can be characterized as being 'short sighted',and as 'non-recoverable'. They are ideal only for problems whichhave 'optimal substructure'. Despite this, greedy algorithms arebest suited for simple problems (e.g. giving change).
Greedy choice property
We can make whatever choice seems best at the moment andthen solve the subproblems that arise later. The choice made bya greedy algorithm may depend on choices made so far but noton future choices or all the solutions to the subproblem. I t
iteratively makes one greedy choice after another, reducing eachgiven problem into a smaller one. In other words, a greedyalgorithm never reconsiders its choices.
Artif icial Intelligence Lab, IBA Spring 2011 27
Hill Climbing(Source: Wikipedia)
In computer science, hill climbing is amathematical optimizationtechnique which belongs to the family oflocal search. It is an ite rativealgorithm that starts with an arbitrary solution to a problem, thenattempts to find a better solution byincrementally changing a singleelemen t of the solution. If the change produces a better solution, anincremental change is made to the new solution, repeating until nofurther improve ments can be found.
For example, hill climbing can be applied to the traveling salesmanproblem. It is easy to find an initial so lution that visits all the cities but willbe very poor compared to the optimal solution. The algorithm starts withsuch a solution and makes small improvements to it, such as switching theorder in which two citie s are visited. Eventually, a much s horter route is
likely to be obtained. Hill climbing is good for finding a local optimum (a good solution that lies
relatively near the initial solution) but it is not guaranteed to find the bestpossible solution (the global o ptimum) out of all possible solutions (thesearch space).
Artificial Intelligence Lab, IBA Spring2011 28
http://en.wikipedia.org/wiki/Computer_sciencehttp://en.wikipedia.org/wiki/Optimization_(mathematics)http://en.wikipedia.org/wiki/Optimization_(mathematics)http://en.wikipedia.org/wiki/Local_search_(optimization)http://en.wikipedia.org/wiki/Optimization_(mathematics)http://en.wikipedia.org/wiki/Local_search_(optimization)http://en.wikipedia.org/wiki/Incremental_heuristic_searchhttp://en.wikipedia.org/wiki/Incremental_heuristic_searchhttp://en.wikipedia.org/wiki/Incremental_heuristic_searchhttp://en.wikipedia.org/wiki/Traveling_salesman_problemhttp://en.wikipedia.org/wiki/Traveling_salesman_problemhttp://en.wikipedia.org/wiki/Traveling_salesman_problemhttp://en.wikipedia.org/wiki/Local_optimumhttp://en.wikipedia.org/wiki/Global_optimumhttp://en.wikipedia.org/wiki/Search_spacehttp://en.wikipedia.org/wiki/Global_optimumhttp://en.wikipedia.org/wiki/Search_spacehttp://en.wikipedia.org/wiki/Search_spacehttp://en.wikipedia.org/wiki/Global_optimumhttp://en.wikipedia.org/wiki/Local_optimumhttp://en.wikipedia.org/wiki/Traveling_salesman_problemhttp://en.wikipedia.org/wiki/Traveling_salesman_problemhttp://en.wikipedia.org/wiki/Incremental_heuristic_searchhttp://en.wikipedia.org/wiki/Local_search_(optimization)http://en.wikipedia.org/wiki/Optimization_(mathematics)http://en.wikipedia.org/wiki/Computer_science7/27/2019 Introduction to AI Unit 4
8/8
3/5/2
Local vs Global Optimum?
Artif icial Intelligence Lab, IBA Spring 2011 29
What is the optimum point?
Local vs Global Optimum?
Artificial Intelligence Lab, IBA Spring2011 30
What do you think about the optimum point now?