Title: Intelligent Systems 2II40 C3
1Intelligent Systems (2II40)C3
September 2003
2Outline
- Intelligent agents
- Search
- Uninformed
- Informed
- Heuristic
- Local
- Online
3Uniform cost search
- Expand least cost node first
- Implementation increasing cost order queue
- e min(cost/step) the smallest step cost
4Ex Romania w. step costs (km)
5Uniform cost example
Arad
6Uniform cost example
Arad
118
75
140
Zerind
Sibiu
Timisoara
7Uniform cost example
Arad
118
75
140
Sibiu
Zerind
Timisoara
7575 150
111118 229
7571 146
236
Arad
Oradea
Arad
Lugoj
8Uniform cost example
Arad
118
75
140
Sibiu
Zerind
Timisoara
150
229
146
280
220
239
291
236
Arad
Oradea
Arad
Lugoj
Arad
Oradea
Ramnicu Valcea
Fagarash
9Uniform cost example
Arad
118
75
140
Sibiu
Zerind
Timisoara
150
229
146
280
220
239
291
236
Arad
Oradea
Arad
Lugoj
Arad
Oradea
Ramnicu Valcea
Fagarash
297
217
Sibiu
Zerind
10Uniform cost example
Arad
118
75
140
Sibiu
Zerind
Timisoara
150
229
146
280
220
239
291
236
Arad
Oradea
Arad
Lugoj
Arad
Oradea
Ramnicu Valcea
Fagarash
297
217
Sibiu
225
Zerind
290
268
11Uniform cost example
Arad
118
75
140
Sibiu
Zerind
Timisoara
150
229
146
280
220
239
291
236
Arad
Oradea
Arad
Lugoj
Arad
Oradea
Ramnicu Valcea
Fagarash
297
217
300
382
317
Sibiu
225
Sibiu
Pitesti
Craiova
Zerind
290
268
12Uniform cost example
Arad
118
75
140
Sibiu
Zerind
Timisoara
150
229
146
280
220
239
291
236
Arad
Oradea
Arad
Lugoj
Arad
Oradea
Ramnicu Valcea
Fagarash
297
217
300
382
317
Sibiu
225
Sibiu
Pitesti
Craiova
Zerind
290
268
13Properties of uniform cost search
- Complete? Yes (b,d finite cost/step ? e)
- Time? O(bC/e) (C total cost)
- Space? O(bC/e)
- Optimal? Yes (b,d finite cost/step ? e)
14III.2. Informed search algorithms
15III.2. Informed Search Strategies
- A. Heuristic
- Best-first search
- Greedy search
- A search
- B. Local
- Hill climbing
- Simulated annealing
- Genetic algorithms
16Best first search
- f(n) evaluation function
- estimates desirability of the node to be expanded
- Implementation queue of decreasing order of
desirability - Special cases
- Greedy search
- A
17Greedy search
- f(n) h(n), where
- h(n) heuristic that estimates distance (cost)
from n to goal - Expands node that appears closest to goal
18Example Greedy search
- Map of Romania
- A possible heuristic is
- hsld(n) straight line distance from n to
Bucharest
19Greedy search example
Arad
366
20Greedy search example
Arad
366
Zerind
Timisoara
Sibiu
374
329
253
21Greedy search example
Arad
366
Zerind
Timisoara
Sibiu
329
374
253
Arad
Oradea
Ramnicu Valcea
Fagarash
366
380
178
193
22Greedy search example
Arad
366
Zerind
Timisoara
Sibiu
329
374
253
Arad
Oradea
Ramnicu Valcea
Fagarash
366
380
178
193
Sibiu
Bucharest
253
0
23Properties of Greedy search
- Complete? No (could get stuck in loops)
- Time? O(bm)
- Space? O(bm)
- Optimal? No
24A search
- f(n) g(n) h(n), where
- g(n)cost from start to n (real cost!!)
- h(n) heuristic that estimates distance or cost
from n to goal - considers the whole cost incurred from start to
goal at all times - Important heuristic should be admissible
- h(n) ? h(n), w. h(n) real cost from n to goal
25A search example
Arad
366
26A search example
Arad
366
118
75
140
Zerind
Timisoara
Sibiu
37475 449
447
393
27A search example
Arad
366
118
75
140
Zerind
Timisoara
Sibiu
449
447
393
140
80
99
151
Arad
Oradea
Ramnicu Valcea
Fagarash
646
526
417
413
28A search example
Arad
366
118
75
140
Zerind
Timisoara
Sibiu
449
447
393
140
80
99
151
Arad
Oradea
Ramnicu Valcea
Fagarash
646
526
417
413
146
80
97
Sibiu
Craiova
Pitesti
553
526
415
29A search example
Arad
366
118
75
140
Zerind
Timisoara
Sibiu
449
447
393
140
80
99
151
Arad
Oradea
Ramnicu Valcea
Fagarash
646
526
417
413
146
80
97
Sibiu
Pitesti
Craiova
553
526
415
97
138
101
Ramnicu Valcea
Bucharest
Craiova
615
607
418
30A search example
Arad
366
118
75
140
Zerind
Timisoara
Sibiu
449
447
393
140
80
99
151
Arad
Oradea
Ramnicu Valcea
Fagarash
646
526
417
413
146
80
99
97
211
Sibiu
Pitesti
Craiova
Sibiu
Bucharest
553
526
415
97
138
591
450
101
Ramnicu Valcea
Bucharest
Craiova
615
607
418
31Properties of A search
- Complete? Yes (if nodes w. f ? C finite)
- Time? O (b(rel. err. in h) x (length of
solution)) - Space? All nodes in memory
- Optimal? Yes
32Improved A alg.
- IDA A iterative deepening depending on f
- RBFS recursive depth first search remembering
value of best ancestor spaceO(bd) - MA memory bound A (use of available memo
only) - SMA simple MA (A if memo full, discard
worst node, but store f value of children w.
parents)
33Summary (un-)informed search
- Non-informed search is also called blind
- Informed search can be computationally cheaper
than uninformed, depending on heuristic - Research continues on finding better search
(i.e., problem solving) algorithms - Informed uninformed search are global search
algorithms gt exponential timespace (10120
no. molecules in universe)
34Homework 3 part I
- Prove that the A search is optimal (Hint use
the admissibility of the heuristic) - Read the LAO paper find the different notations
used by the author for the properties of the
search algorithm and make a table of
equivalences Describe LAO in terms of
properties (as in C2, C3) comment upon
dimensions of AI (as in C1) that you find in the
LAO algorithm. - Check the FAQ and perform the next project steps
that are missing (1-4)!
35II.2.B. Local Search
- Greedy local search (hill-climbing)
- Simulated annealing
- Genetic algorithms
36Why local search?
- If path is not part of the solution
- If the problem is an optimization problem (I.e.,
finding max or min of an objective function) - If there is no goal (to do goal test or path cost)
Objective function
State space
37Hill-climbing (gradient ascent/descent)
- Like climbing Everest in thick fog with amnesia
38Visualizing hill-climbing
- Problem alg. can get stuck in local maxima/minima
39Simulated annealing
40Properties of simulated annealing
- created 53 by Metropolis et al., for physical
process modeling - Metallurgy annealing heating metals/ glass to
high temperature, then cooling gradually (to
harden them) - used in airline scheduling, VLSI layout, etc.
- allowing moves up-hill
- why?
41Simulated annealing probability
- Probability of state occupation
- At fixed temperature T, probability Boltzman
distribution - If T decreases slowly enough, the best state is
always reached
42Simulated Annealing Algorithm
- function S_A(problem, schedule) returns a
solution state - inputs problem, a problem
- schedule, a mapping from time to temperature
- local variables current, a node
- next, a node
- T, a temperature controlling the
probability of downwards steps - current?MAKE-NODE(INITIAL-STATEproblem)
- for t ?1 to ? do
- T ? schedulet
- if T0 then return current
- next ? a randomly selected successor of
current - ?E ? VALUEnext VALUEcurrent
- if ?E gt 0 then current ?next
- else current ?next only with probability
e?E/T
43Genetic Algorithms(stochastic hill-climbing)
44GA terminology
- Chromosome state (in search space),
made up of genes - Genes state variables
- Alleles possible values for genes
- Locus position along the chromosome
- Crossover new child chromosome generation by
aligning two parents - Mutation new chromosome generation from one
individual (altering val. of loci)
45Crossover
Single point cross-over
Multiple point cross-over
46Mutation
Problems validity check!!
47Genetic Algorithm
- function G_A(population, FITNES-FN) returns an
individual - inputs population, a set of individuals
- FITNESS-FN, a fct. measuring fitness of an
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 the population,
according to the FITNESS-FN
48Selection some examples
- Fitness-proportionate no. offspring proportional
w. fitness (roulette wheel selection) - Linear fitness scaling (simfic)
- Boltzmann fitness sc. (siexp(fi/T))
- Tournament selection (binary 2 by 2)
- Elitism (a group of individuals pass unchanged)
49III.2.c. Online search agents and unknown
environments
50Online search
- Exploration problem
- Agent doesnt know the environment (states,
actions) - Local algorithms are fine for online search, as
they only require knowledge of a limited vicinity
of the current state - A good algorithm has to outperform random walk
51- function LTRA(s) returns an action
- inputs s, a percept that identifies the current
state - static result, a table, indexed by action and
state, initially empty - H, a table of cost estimates indexed by
state, initially empty - s,a, the previous state and action,
initially null - if GOAL-TEST(s) then return stop
- if s is a new state (not in H) then Hs ?h(s)
- unless s is null
- resulta,s ?s
- Hs ? min (b?ACTIONS(s)) LRTA-COST(s,b,resu
ltb,s,H) - s ?s
- return a
- function LRTA-COST(s,a,s,H) returns a cost
estimate - if s is undefined then return h(s)
- else return c(s,a,s) Hs
-
52LTRA steps (in 1-dimensional space)
Initial state
8
9
2
2
4
3
(1)
53Homework 3 part II
- Find the memory requirements (propertiesspace)
of the simulated annealing algorithm (Hint
express space in states kept in memory). - How many alleles are there for a binary-encoded
gene that is N bits wide? - Find out where the name LTRA comes from? What
does the L stand for, and how do you explain it?