Title: Last time: ProblemSolving
1Last time Problem-Solving
- Problem solving
- Goal formulation
- Problem formulation (states, operators)
- Search for solution
- Problem formulation
- Initial state
- ?
- ?
- ?
- Problem types
- single state accessible and deterministic
environment - multiple state ?
- contingency ?
- exploration ?
2Last time Problem-Solving
- Problem solving
- Goal formulation
- Problem formulation (states, operators)
- Search for solution
- Problem formulation
- Initial state
- Operators
- Goal test
- Path cost
- Problem types
- single state accessible and deterministic
environment - multiple state ?
- contingency ?
- exploration ?
3Last time Problem-Solving
- Problem solving
- Goal formulation
- Problem formulation (states, operators)
- Search for solution
- Problem formulation
- Initial state
- Operators
- Goal test
- Path cost
- Problem types
- single state accessible and deterministic
environment - multiple state inaccessible and deterministic
environment - contingency inaccessible and nondeterministic
environment - exploration unknown state-space
4Last time Finding a solution
Solution is ??? Basic idea offline, systematic
exploration of simulated state-space by
generating successors of explored states
(expanding)
- Function General-Search(problem, strategy)
returns a solution, or failure - initialize the search tree using the initial
state problem - loop do
- if there are no candidates for expansion then
return failure - choose a leaf node for expansion according to
strategy - if the node contains a goal state then return
the corresponding solution - else expand the node and add resulting nodes to
the search tree - end
5Last time Finding a solution
Solution is a sequence of operators that bring
you from current state to the goal state. Basic
idea offline, systematic exploration of
simulated state-space by generating successors of
explored states (expanding).
- Function General-Search(problem, strategy)
returns a solution, or failure - initialize the search tree using the initial
state problem - loop do
- if there are no candidates for expansion then
return failure - choose a leaf node for expansion according to
strategy - if the node contains a goal state then return
the corresponding solution - else expand the node and add resulting nodes to
the search tree - end
Strategy The search strategy is determined by ???
6Last time Finding a solution
Solution is a sequence of operators that bring
you from current state to the goal state Basic
idea offline, systematic exploration of
simulated state-space by generating successors of
explored states (expanding)
- Function General-Search(problem, strategy)
returns a solution, or failure - initialize the search tree using the initial
state problem - loop do
- if there are no candidates for expansion then
return failure - choose a leaf node for expansion according to
strategy - if the node contains a goal state then return
the corresponding solution - else expand the node and add resulting nodes to
the search tree - end
Strategy The search strategy is determined by
the order in which the nodes are expanded.
7Last time search strategies
- Uninformed Use only information available in the
problem formulation - Breadth-first
- Uniform-cost
- Depth-first
- Depth-limited
- Iterative deepening
- Informed Use heuristics to guide the search
- Best first
- A
8Evaluation of search strategies
- Search algorithms are commonly evaluated
according to the following four criteria - Completeness does it always find a solution if
one exists? - Time complexity how long does it take as a
function of number of nodes? - Space complexity how much memory does it
require? - Optimality does it guarantee the least-cost
solution? - Time and space complexity are measured in terms
of - b max branching factor of the search tree
- d depth of the least-cost solution
- m max depth of the search tree (may be
infinity)
9Last time uninformed search strategies
- Uninformed search
- Use only information available in the problem
formulation - Breadth-first
- Uniform-cost
- Depth-first
- Depth-limited
- Iterative deepening
10Um algoritmo robusto e limpo
Function UniformCost-Search(problem, Queuing-Fn)
returns a solution, or failure open ?
make-queue(make-node(initial-stateproblem)) clo
sed ? empty loop do if open is empty then
return failure currnode ? Remove-Front(open) i
f Goal-Testproblem applied to State(currnode)
then return currnode children ?
Expand(currnode, Operatorsproblem) while
children not empty see next slide
end closed ? Insert(closed,
currnode) open ? Sort-By-PathCost(open) end
11Um algoritmo robusto e limpo
see previous slide children ?
Expand(currnode, Operatorsproblem) while
children not empty child ? Remove-Front(childre
n) if no node in open or closed has childs
state open ? Queuing-Fn(open, child) else
if there exists node in open that has childs
state if PathCost(child) lt PathCost(node)
open ? Delete-Node(open, node) open ?
Queuing-Fn(open, child) else if there exists
node in closed that has childs state if
PathCost(child) lt PathCost(node) closed ?
Delete-Node(closed, node) open ?
Queuing-Fn(open, child) end see previous
slide
12Informed search (busca com informação)
- Informed search
- Uso de heurísticas para guiar a busca
- Best first
- A
- Heuristica
- Hill-climbing
- Simulated annealing
13Best-first search
- Idéia
- usar uma função de avaliação para cada nó
estimação de desejabilidade - Expandir nó não expandido mais desejável.
- Implementação
- QueueingFn insere successores em ordem
decrescente de desejabilidade - Casos especiais
- greedy search
- A search
14Romania com custo de cada passo em km
15Greedy search (gula é um pecado capital?)
- Função de estimação
- h(n) estimação do custo de nó ao objetivo
(heuristica) - Por exemplo
- hSLD(n) distância em linha reta do nó a
Bucharest - Greedy search expande primeiro o nó que
aparentemente é o mais próximo do objetivo, de
acordo com h(n).
16(No Transcript)
17(No Transcript)
18(No Transcript)
19(No Transcript)
20Propriedades do Greedy Search
- Completo?
- Tempo?
- Memória?
- Ótimo?
21Properties of Greedy Search
- Completo? Não pode ficar parado em loops
- e.g., Iasi gt Neamt gt Iasi gt Neamt gt
- Completo espaço finito com teste de estado
repetido. - Tempo? O(bm) mas uma boa heurística pode dar
- uma melhora dramática
- Memória? O(bm) mantém todos os nós em memória
- Ótimo? Não.
22A search
- Idéia evitar expandir caminhos que já são caros
- função de avaliação f(n) g(n) h(n) com
- g(n) custo do caminho para atingir o nó
- h(n) custo estimado ao objetivo, do nó
- f(n) custo estimado total do caminho pelo nó
ao objetivo - A search usa uma heurística admissível, isto é,
- h(n) ? h(n) onde h(n) é o custo verdadeiro a
partir de n. - Por exemplo hSLD(n) nunca sobre-estima
distância real da estrada. - Teorema A search é ótimo
23(No Transcript)
24(No Transcript)
25(No Transcript)
26(No Transcript)
27(No Transcript)
28(No Transcript)
29Properties of A
- Complete?
- Time?
- Space?
- Optimal?
30Properties of A
- Complete? Yes, unless infinitely many nodes with
f ? f(G) - Time? Exponential in (relative error in h) x
(length of solution) - Space? Keeps all nodes in memory
- Optimal? Yes cannot expand fi1 until fi is
finished
31Prova do lema caminho máximo
32Otimalidade de A (prova mais usual)
33Otimalidade de A (prova standard)
- Suponha que um objetivo G sub-ótimo2 foi gerado e
está na fila. Seja n um nó não expandido num
caminho mais curto para um objetivo G ótimo.
34Heurísticas admissíveis
35Heurísticas admissíveis
36Problema relaxado
- Heurísticas admissíveis podem ser derivadas do
custo exato de uma solução para uma versão
relaxada do problema. - Se as regras do 8-puzzle forem relaxadas de
maneira que uma casa possa mover a qualquer
lugar, então h1(n) produz a solução mais curta. - Se as regras são relaxadas de modo que uma casa
possa se mover a qualquer posição adjacente,
então h2(n) produz a solução mais curta.
37Next time
- Iterative improvement
- Hill climbing
- Simulated annealing