• No results found

(TES3111 / TIC3151 ) Artificial Intelligence. Lecture 5 Informed Search

N/A
N/A
Protected

Academic year: 2021

Share "(TES3111 / TIC3151 ) Artificial Intelligence. Lecture 5 Informed Search"

Copied!
55
0
0

Loading.... (view fulltext now)

Full text

(1)

Artificial Intelligence

Lecture 5

Informed Search

(TES3111 / TIC3151 )

(2)

5.1 Introduction to Informed Search Methods 5.2 Best-First Search

5.2.1 Greedy best-first search 5.2.2 A* search

5.2.3 Best-First Search Analysis 5.2.4 Heuristic Functions

5.3 Memory Bounded Search

5.3.1 Iterative Deepening A* Search 5.3.2 Simplified Memory Bounded A*

5.4 Local Search Algorithms

5.4.1 Hill-Climbing Search

5.3.2 Simulated Annealing, Local beam search and Genetic Algorithm

Contents

(3)

• Relies on additional knowledge about the problem or domain – frequently expressed through heuristics (“rules of thumb”)

‒ The term heuristic refers to a technique that is likely, but not guaranteed, to produce a good (not necessarily best) answer

• Informed search also called heuristic search

• It can distinguish more promising paths towards a goal

– But, may be misleading, depending on the quality of the heuristic

• In general, performs much better than uninformed search

– but frequently still exponential in time and space for realistic problems

Informed Search Methods

(4)

• Best-first search – is the general approach for informed search

• An evaluation function, f(n) is used to evaluate a node n in a search tree

• so that “best” node can be selected for expansion

Informed Search Methods

• A key component of an evaluation function is a heuristic function, h(n)

• estimates the cost of the cheapest path from node n to a goal node

• The most common form to impart additional knowledge to search algorithm

(5)

Informed Search Methods

• Often, we can decompose f:

f(n) = g(n) + h(n)

Cost function:

cost to get to node n

Heuristic function:

estimated cost of the cheapest path from node n to goal node Evaluation function

If n is goal then h(n)=0 If h(n) = then n is a dead end; a goal cannot

(6)

Informed Search Methods

f(n) = g(n) (uniform-cost)

f(n) = h(n) (greedy algorithm) f(n) = g(n) + h(n) (algorithm A*)

(7)

• Greedy search expands the node that appears to be closest to goal on the grounds that it will lead to a solution quickly

• Thus, the evaluation function is:

Greedy Best-First Search

f(n) = h(n)

Heuristic function:

estimated cost of the cheapest path from node n to goal node Evaluation function

(8)

Greedy Best-First Search

Romania driving problem

• Let hSLD(n) = straight-line distance heuristic

– If the goal is Bucharest, we will need to know the straight-line distances to Bucharest

– hSLD(n) cannot be computed from the problem description itself

Note: hSLD is correlated with actual road distances and thus a useful heuristic

(9)

Greedy Best-First Search

(10)

Greedy Best-First Search

Greedy best-first search finds a solution without ever expanding a node (i.e., not on

the solution path), hence its search cost is minimal

(11)

Greedy Best-First Search

• However, greedy best-first search is not optimal Actual path cost of the solution:

Arad-Sibu-Fagaras-Bucharest = 140 + 99 + 211 = 450 But, consider the path

Arad-Sibu-Rimnicu-Pitesti-Bucharest = 140 + 80 + 97 + 101 = 418

Refer to slide 14, lecture 3, for the path distance (in km)

This is why the algorithm is called ‘greedy’ since at each step it tries

32 km longer

(12)

• Contrast with uniform-cost search which expands the lowest cost path from the start

• Greedy best-first search resembles depth-first search since it prefers to follows a single path all the way to the goal, but it will backup when it hits a dead end.

– So,

• it is not complete

• it is not optimal

• time and space complexity is O(bm)

Greedy Best-First Search

(13)

Properties of greedy search

Completeness: No

 Fails in infinite-depth spaces

 Complete in finite spaces with repeated state checking

- E.g. going from Iasi-Neamt-Iasi-Vaslui-…

Greedy Best-First Search

Goal

Initial

Based on heuristic, Neamt will be expanded first since it is closest to Fagaras, but it is a dead end

Goal

(14)

Properties of greedy search

Optimality: No. Optimal path goes through Pitesti, not through Fagaras.

Time Complexity: O(bm), like depth-first, but a good heuristic function gives dramatic improvement on average

Space Complexity : O(bm), keeps all nodes in memory

Greedy Best-First Search

b = branching factor m = maximum depth of the search

(15)

Greedy Best-First Search

• For greedy best-first search, evaluation function is:

f(n) = h(n)

estimated cost of the cheapest path from node n to goal node

•[Recall]: For uniform cost search, evaluation function is:

f(n) = g(n)

cost to get to node n

(16)

• Best-known form of best-first search.

• Combines greedy and uniform-cost search to find the (estimated) cheapest path through the current node

• Evaluation function:

A* Search

f(n) = g(n) + h(n)

cost to get to node n estimated cost of the cheapest path from node n to goal node

f(n) is the estimated cost of cheapest solution that passes through node n

(17)

• Its goal is to find a minimum total cost path.

• A* expands node with the lowest f(n) value first

• This leads to both complete and optimal search algorithm, provided that h(n) satisfies certain conditions

A* Search

A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n.

– provided that h(n) never overestimates the cost to reach the goal

• A* is optimal if h(n) is an admissible heuristic

(18)

A* Search

hSLD

g(n)

(19)

A* Search

220+193

(20)

A* Search

… from Arad

(21)

• Complete? Yes (when the branching factor is finite and every operator has a fixed positive cost)

• Time? Exponential

• Space? Keeps all nodes in memory

• Optimal? Yes (optimally efficient among all such algorithms)

Properties of A*

A* Search

Drawback

(22)

The effect of heuristic accuracy on performance

Heuristic Functions

• One way to determine the quality of a heuristic is the effective branching factor, b*

N + 1 = 1 + b* + (b*)2 + (b*)3 + ... + (b*)d

N: total number of nodes generated by A*

d: solution depth

b*: branching factor that a uniform tree of depth d would have in order to contain N + 1 nodes

(23)

Dominance

Heuristic Functions

1 2 3 4 5

6 7

8

1 2 3 4 5 6 7 8

Start state Goal state

• h1(s) = 7

• h2(s) = 2 + 3+ 3 + 2 + 4 + 2 + 0 + 2 = 18

h2 dominates h1

if h2(s) >= h1(s) for all s

• If h2 dominates h1

then A* is more efficient with h2 (i.e., it expands fewer states)

(24)

• Given two admissible heuristics h1(n) and h2(n), which is better?

• If h2(n) h1(n) for all n, then – h2 is said to dominate h1 – h2 is better for search

Heuristic Functions

(25)

Limitations of A*

• It can use a lot of memory

• In principal, O(no. of states)

• For really big search spaces, A* will run out of memory

• Good news: A* is optimally efficient

• For a given h(.), no other optimal algorithm will expand few nodes

Memory-bounded Search

(26)

• Search algorithms that try to conserve memory

• Most are modifications of A*

– Iterative-deepening A* (IDA*)

– Recursive best-first search (RBFS)

– Simplified memory-bounded A* (SMA*)

Memory-bounded Search

(27)

Memory-bounded Search

Iterative-deepening A* (IDA*)

• The main difference between IDA* and IDA:

• The cutoff used is f-cost (g+h) rather than depth

• At each iteration, the cutoff value is the smallest f-cost of any node that exceeded the cutoff on the previous iteration;

• It can avoid the substantial overhead associated with keeping a sorted queue nodes.

(28)

Memory-bounded Search

Recursive Best-First Search (RBFS)

• Mimic the operation of best-first search, but using only linear space

• It is similar to that of a recursive depth-first search with record keeping to prevent following the current path indefinitely

• It records the f-cost of the best alternative path available from any ancestor of the current node

• if current f-cost is greater, backtrack to the alternative path as unwind recursion, store best f-cost of any child node

• This allows revisiting abandoned subtree if the current f-cost becomes greater

• Issue:

• possible repeated re-generation of subtrees

(29)

Memory-bounded Search

Recursive Best-First Search (RBFS)

f-limit for recursive calls

f(n) = g(n) + h(n)

 Path to Rimnicu Vilcea is already expanded

 Follows path to Pitesti: f-cost worse than the f-limit (417>415)

(30)

Memory-bounded Search

Recursive Best-First Search (RBFS)

• Unwind the recursion

• Update best f-cost from that of current best leaf: Pitesti

• Now Fagaras is best, expand Fagaras

• Best value is now 450

Update

(31)

Memory-bounded Search

• Unwind the recursion

• Update best f-cost from that of current best leaf: Bucharest

• Now Rimnicu Vilcea is best, expand Rimnicu Vilcea

• Because the best alternative path (through Timisoara) costs 447,

Update

(32)

Memory-bounded Search

Simplified Memory-bounded A* (SMA*)

• Uses all available memory for the search

– drops nodes from the queue when it runs out of space

 those with the highest f-value

• Basic idea:

– Do A* until runs out of memory

• Expand the best (lowest f-value) leaf until memory is full – Throw away node with highest f-value

• Store f-value in ancestor node

• Expand node again if all other nodes in memory are worse

(33)

• Idea: start with an initial guess at a solution and incrementally improve it until it is one

• Advantages:

– Use very little memory

– Find often reasonable solutions in large or infinite state spaces.

• Since only information about the current state is kept, such methods are called local

Local Search Algorithms

(34)

• Local search algorithms are also useful for solving pure optimization problems

– The aim is to find the best state according to an objective function for some problems

Local Search Algorithms

• This class of problems includes many applications such as – Integrated-circuit design

– Factory-floor layout – Job-shop scheduling

– Telecommunications network design – Vehicle routing

– Portfolio management

(35)

• Landscape has both “location” (defined by the state) and

“elevation” (defined by the value of the heuristic cost function or objective function)

Local Search Algorithms

State space landscape

elevation

(36)

• If the elevation corresponds to cost

– Then, the aim is to find lowest valley – global minimum

• If the elevation corresponds to an objective function,

– Then the aim is to find the highest peak – global maximum

• One can convert one to the other just by inserting a minus (-) sign

• Local search algorithms explore this landscape

• A complete local search algorithm always finds a goal if one exists

• An optimal algorithm always finds a global minimum/maximum.

Local Search Algorithms

(37)

Hill climbing on a surface of states

Hill-Climbing Search

It is a simply loop that continuously moves in the direction of increasing value – that is, uphill.

(38)

• Terminates when a peak is reached, where no neighbor has a higher value

• It does not maintain a search tree,

– current node data structure only record the state and its objective function value

• Does not look ahead of the immediate neighbors of the current state.

• Chooses randomly among the set of best successors, if there is more than one.

• Doesn’t backtrack, since it doesn’t remember where it’s been

Hill-Climbing Search

Properties

(39)

Hill-Climbing Search

Algorithm

At each step, the current node is replaced by the best neighbor, i.e., neighbor with the

highest value

(40)

8-queens problem

Hill-Climbing Search

Use a complete-state formulation, where each state has 8 queens on the board, one per column

(41)

Successor function:

- move a single queen to another square in the same column.

- It returns all possible states

generated by moving a single queen to another square in the same column - Each state has 8 x 7 = 56 successors

Hill-Climbing Search

8-queens problem

(42)

Heuristic function, h(n):

- The no. of pairs of queens that are

attacking each other (directly/indirectly) - Thus, h = 17

Hill-Climbing Search

8-queens problem

(43)

8-queens problem

Hill-Climbing Search

(44)

• Also called greedy local search

– Tries to grab a good neighbor state without thinking ahead where to go next

• Problem: depending on initial state, can get stuck in local maxima

• It is simply loop continually moves in the direction of increasing value – that is, uphill

• Hill-climbing also known as gradient ascent/descent;

steepest ascent

Hill-Climbing Search

Like climbing Everest in thick fog with amnesia

(45)

• Local maxima (foothills): a local maximum is a peak i.e, higher than each of its neighboring states, but lower than the global

maximum

Problems with Hill Climbing

Hill-climbing Search

A local maximum (i.e., a local minimum for cost h)

Every move of a single queen

makes the situation worse

(46)

• Plateaus: All neighbors look the same (the space has a broad flat region that gives the search algorithm no direction)

• Ridges: going through a sequence of local maxima

Problems with Hill Climbing

Hill-climbing Search

(47)

Overcoming Local Optimum and Plateau

• Simulated annealing

• Genetic algorithms

• Etc.

Hill-climbing Search

(48)

• Combine two parent states, rather than modifying a single state to generate successor states

• GA begin with a set of k randomly generated states: population

• Each state is represented as a string over a finite alphabet, most commonly a string of 0s and 1s

Genetic Algorithms

16257483

(49)

A state or individual is rated by an evaluation function/

objective function (fitness function)

A fitness function returns higher values for better states

Fitness is used in selecting the parent pair

– The probability of being chosen for reproducing is directly proportional to the fitness score

Produce the next generation of states (offspring):

– Crossover – Mutation

Genetic Algorithms

(50)

Genetic operators: Crossover

Genetic Algorithms

Generate two offspring

– Use Parent 1 for the first part of the string and up to the crossover point and Parent 2 for the rest

Parent 1 Parent 2

(51)

Genetic operators: Mutation

Genetic Algorithms

The value of each element of the string is changed with some probability.

(52)

function GENETIC_ALGORITHM( population, FITNESS-FN) return an individual input: population, a set of individuals

FITNESS-FN, a function which determines the quality of the individual repeat

new_population empty set

loop for i from 1 to SIZE(population) do

x RANDOM_SELECTION(population, FITNESS_FN) y RANDOM_SELECTION(population, FITNESS_FN)

child REPRODUCE(x,y)

if (small random probability) then child MUTATE(child ) add child to new_population

population new_population

until some individual is fit enough or enough time has elapsed return the best individual in population, according to FITNESS-FN

Genetic Algorithms

(53)

function REPRODUCE(x,y) returns an individual inputs: x, y, parent individual

n  LENGTH(x)

c  random number from 1 to n

return APPEND(SUBSTRING(x, 1, c), SUBSTRING(y, c+1, n))

Genetic Algorithms

(54)

No. of nonattacking pairs of queens

(55)

The End

References

Related documents

[r]

l Meter Total VA-h current value Integer SHARK200IECMeas/eneMMTR1$ST$TotVAh$q (Good) 0000000000000 Bit stream quality.. SHARK200IECMeas/eneMMTR1$ST$TotVAh$t Meter Time Stamp UTC time

Perfor- mance comparisons among the presented method and using the backpropagation (BP) neural network and the conventional Hysteresis method are given in forms of (1) handoff

Modify the depth-first search pseudocode to detect and return TRUE if there is a cycle in the graph and FALSE if not. How does this affect the

The study shall include the longitudinal Rate Command-Attitude Hold (RCAH) controllers design using the state space pole placement design procedure, handling qualities assessment

Examples are illegal communication (e.g. by email, web, cell phone), hiding of computer objects with the aim of accessing or utilizing it, impersonation of

1. Mmetaphysical school of poetry 4. Puritan Age 11. Anglican Church 12. Mystery play 16. Oxford Reformers 19. Iambic Pentameter 26. Miracle Play 29. Morality Play 31. Narrative

the default auto mode.. Press and hold the [ MHz ] key for two seconds to find the next available vacant memory channel. To change the memory bank, rotate the sub dial. To