Planejamento em Inteligncia Artificial Captulo 9 Heursticas em

  • Slides: 35
Download presentation
Planejamento em Inteligência Artificial Capítulo 9 Heurísticas em Planejamento Leliane Nunes de Barros MAC

Planejamento em Inteligência Artificial Capítulo 9 Heurísticas em Planejamento Leliane Nunes de Barros MAC 5788 IME-USP 2005 Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Planejamento como Busca Não-determinística: uma visão conceitual O nó u representa um conjunto de

Planejamento como Busca Não-determinística: uma visão conceitual O nó u representa um conjunto de planos soluções u : conjunto de todas as soluções alcançáveis de u. Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Planejadores como instâncias de Abstract-search (I) l Planejamento no espaço de estados: u é

Planejadores como instâncias de Abstract-search (I) l Planejamento no espaço de estados: u é uma seqüência de ações. Toda solução alcançável apartir de u contém essa seqüência como prefixo ou sufixo. l Planejamento no espaço de planos: u é um conjunto de ações com vínculos causais, restrições de ordenação e restrições de unificações. Toda solução alcançável apartir de u contém todas as ações e satisfazem as restrições l Algoritmo Graphplan: u é um sub-grafo de um grafo de planejamento, isto é, uma seqüência de conjuntos de ações junto com restrições de pré-condições, efeitos e exclusões mútuas. Toda solução alcançável apartir de u contém as ações em u correspondente aos níveis já resolvidos (da busca no grafo) e pelo menos uma ação de cada nível qua ainda não foi resolvido em u. Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Planejadores como instâncias de Abstract-search (II) l Planejamento basead em SAT: u é um

Planejadores como instâncias de Abstract-search (II) l Planejamento basead em SAT: u é um conjunto de literais valorados e o restante das cláusulas, cada uma sendo uma disjunção de literais que descrevem ações e estados. Toda solução alcançável apartir de u corresponde a uma atribuição de valores verdade ou falso aos literais não valorados tal que todas as cláusulas restantes sejam satisfeitas. l Planejamento baseado em CSP: u é um conjunto de variáveis CSP e restrições com algumas variáveis com valores já atribuidos. Toda solução alcançável apartir de u inclue essas variáveis valoradas e atribuições para as outras variáveis CSP que satisfazerm as restrições. Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Planejadores como instâncias de Abstract-search (III) l Planejamento no espaço de estados: u é

Planejadores como instâncias de Abstract-search (III) l Planejamento no espaço de estados: u é um plano parcial l Planejamento no espaço de planos: u é um plano parcial l Algoritmo Graphplan: nem todas as ações em u farão parte do plano solução l Planejamento basead em SAT: nem todas as ações em u farão parte do plano solução l Planejamento baseado em CSP: nem todas as ações em u farão parte do plano solução Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Planejadores como instâncias de Abstract-search (III) l Planejamento no espaço de estados: u é

Planejadores como instâncias de Abstract-search (III) l Planejamento no espaço de estados: u é um plano parcial l Planejamento no espaço de planos: u é um plano parcial Disjunctive refinement approaches: l Algoritmo Graphplan: nem todas as ações em u farão parte do plano solução l Planejamento basead em SAT: nem todas as ações em u farão parte do plano solução l Planejamento baseado em CSP: nem todas as ações em u farão parte do plano solução Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Planejadores como instâncias de Abstract-search (IV) l Refine: modifica a coleção de ações e/ou

Planejadores como instâncias de Abstract-search (IV) l Refine: modifica a coleção de ações e/ou restrições associadas com um nó u l Branch: gera um ou mais filhos de u que serão os nós candidatos para ser o próximo nó visitado. Cada filho v representa um sub-conjunto de soluções v u l Prune: remove do conjunto de nós candidatos {u 1, u 2, . . . , uk} alguns nós que parecem ser não promissores para a busca (por exemplo, um nó já visitado que não levou a solução) l Planejadores podem: » Variar a ordem em que esses 3 procedimentos são executados » Usar diferentes mecanismos de controle, como IDS ou A* l Como os planejadores que estudamos realizam esses procedimentos (páginas 195 à 197) Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Tornando Abstract-search Determinística Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated

Tornando Abstract-search Determinística Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heurística de seleção de nós: resolve o problema da escolha não-determinística l Suponha que

Heurística de seleção de nós: resolve o problema da escolha não-determinística l Suponha que para cada estado s, temos uma estimativa h(s) da distância de s para uma solução u h(s) é usada para decidir qual será o próximo nó a ser expandido u quanto mais informativa for h(s) menor será o número de escolhas erradas u h(s) deve ainda ser facilmente computável » Heurísticas são geralmente baseadas mo princípio de relaxação de problemas: para avaliar o quão desejável é um nó consideramos um problema mais simples obtido apartir do original fazendo suposições de simplicação e relaxando restrições Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heurística de seleção de nós l Suppose we’re searching a tree in which each

Heurística de seleção de nós l Suppose we’re searching a tree in which each edge (s, s') has a cost c(s, s') u If p is a path, let c(p) = sum of the edge costs u For classical planning, this is the length of p l For every state s, let u g(s) = cost of the path from s 0 to s u h*(s) = least cost of all paths from s to goal nodes u f*(s) = g(s) + h*(s) = least cost of all paths u from s 0 to goal nodes that go through s l Suppose h(s) is an estimate of h*(s) u Let f(s) = g(s) + h(s) » f(s) is an estimate of f*(s) u h is admissible if for every state s, 0 ≤ h(s) ≤ h*(s) u If h is admissible then f is a lower bound on f* Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

The A* Algorithm l A* on trees: loop choose the leaf node s such

The A* Algorithm l A* on trees: loop choose the leaf node s such that f(s) is smallest if s is a solution then return it and exit expand it (generate its children) l On graphs, A* is more complicated: additional machinery to deal with multiple paths to the same node l If a solution exists (and certain other conditions are satisfied), then: u If h(s) is admissible, then A* is guaranteed to find an optimal solution u The more “informative” the heuristic is (i. e. , the closer it is to h*), the smaller the number of nodes A* expands u If h(s) is within c of being admissible, then A* is guaranteed to find a solution that’s within c of optimal Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heuristic Functions for Planning l *(s, p): minimum distance from state s to a

Heuristic Functions for Planning l *(s, p): minimum distance from state s to a state containing p l *(s, s’): minimum distance from state s to a state containing every p in s’ l i(s, p) and i(s, s’), where i = 0, 1, 2, … u estimates of *(s, p) and *(s, s’) 0 ignora os efeitos negativos das ações and p s, l h(s) = 0(s, g), where g is the goal Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heurística da relaxação de independência (polinomial no número de proposições e ações) l Given

Heurística da relaxação de independência (polinomial no número de proposições e ações) l Given s, can compute 0(s, p), for every proposition p: l From this, can compute h(s) = 0(s, g) = p g 0(s, p) Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heuristic Forward Search l Note: this is depth-first search; thus admissibility is irrelevant Leliane

Heuristic Forward Search l Note: this is depth-first search; thus admissibility is irrelevant Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heuristic Backward Search l Same comment as on the previous slide Leliane Nunes de

Heuristic Backward Search l Same comment as on the previous slide Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

and p s, l h(s) = 0(s, g) is an inadmissible heuristic l 1:

and p s, l h(s) = 0(s, g) is an inadmissible heuristic l 1: like 0 except that 1(s, g) = maxp g 0(s, p) u This heuristic is admissible; thus it could be used with A* u It is not very informative Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

A More Informed Heuristic l Instead of computing the maximum distance to each p

A More Informed Heuristic l Instead of computing the maximum distance to each p in g, compute the maximum distance to each pair {p, q} in g: Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

More Generally, … Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated

More Generally, … Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Complexity of Computing the Heuristic l Takes time (nk). l If k = max(|g|,

Complexity of Computing the Heuristic l Takes time (nk). l If k = max(|g|, max{|precond(a)| : a is an action}) then computing (s, g) is as hard as solving the entire planning problem Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Get Heuristic Values from a Planning Graph l The planning graph provides not only

Get Heuristic Values from a Planning Graph l The planning graph provides not only the distance estimates from s 0 to every reachable proposition p but also the mutex relations Pi u The Solution extraction procedure selects a set of propositions g in a layer only if no pair of elements in g is mutex. Theorem: if a pair of elements in not mutex in a layer, then it remains nonmutex in the following layers this is very close to 2(s, g) Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Get Heuristic Values from a Planning Graph l Recall how Graph. Plan works: loop

Get Heuristic Values from a Planning Graph l Recall how Graph. Plan works: loop Graph expansion: this takes polynomial time extend a “planning graph” forward from the initial state until we have achieved a necessary (but insufficient) condition for plan existence this takes exponential time Solution extraction: search backward from the goal, looking for a correct plan if we find one, then return it repeat Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Using the Planning Graph to Compute h(s) l In the graph, there alternating l

Using the Planning Graph to Compute h(s) l In the graph, there alternating l l layers of ground literals and actions The number of “action” layers is a lower bound on the number of actions in the plan Construct a planning graph, starting at s g(s, p) = level of the first layer that “possibly achieves” p g(s, g) is very close to 2(s, g) u 2(s, g) counts each action individually u g(s, g) groups together the independent actions in a layer Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

The Fast. Forward Planner l Use a heuristic function similar to h(s) = g(s,

The Fast. Forward Planner l Use a heuristic function similar to h(s) = g(s, g) u Some ways to improve it (I’ll skip the details) l Don’t want an A*-style search (takes too much memory) l Instead, use a greedy procedure: until we have a solution, do expand the current state s s : = the child of s for which h(s) is smallest (i. e. , the child we think is closest to a solution) l There are some ways to improve this (I’ll skip the details) l Can’t guarantee how fast it will find a solution, or how good a solution it will find u However, it works pretty well on many problems Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Fast. Forward in the AIPS-2000 Planning Competition l Fast. Forward did quite well l

Fast. Forward in the AIPS-2000 Planning Competition l Fast. Forward did quite well l In the AIPS-2000 competition, all of the planning problems were classical problems l Two tracks: u Fully automated planners u Fast. Forward participated in the fully automated track » It got an “outstanding performance” award u Large variance in how close its plans were to optimal » However, it found them very fast compared with the other automated classical planners Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Fast. Forward in the AIPS-2002 Planning Competition l Among the automated planners, Fast. Forward

Fast. Forward in the AIPS-2002 Planning Competition l Among the automated planners, Fast. Forward was roughly in the middle l LPG (graphplan + local search) did much better, and got a “distinguished performance of the first order” award l One of thing that caused difficulty for Fast. Forward u The problems in the AIPS-2002 went beyond classical planning » Numbers, optimization, time durations l Example: u A domain inspired by the Hubble space telescope (a lot simpler than the real domain, of course) » A satellite needs to take observations of stars » Gather as much data as possible before running out of fuel u Any amount of data gathered is a solution » Thus, Fast. Forward always returned the null plan Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Heuristics for Plan-Space Planning l How to select the next flaw to work on?

Heuristics for Plan-Space Planning l How to select the next flaw to work on? Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

One Possible Heuristic l Fewest Alternatives First (FAF) Leliane Nunes de Barro. Slides extraidos

One Possible Heuristic l Fewest Alternatives First (FAF) Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Do Others Work Better? l Sometimes yes, sometimes no l Limits to how good

Do Others Work Better? l Sometimes yes, sometimes no l Limits to how good any flaw-selection heuristic can do Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Serializing and AND/OR Tree Partial plan p l The search space is an AND/OR

Serializing and AND/OR Tree Partial plan p l The search space is an AND/OR tree Goal g 2 … Variable … Goal constraint ordering Operator o 1 … Operator on Goal g 1 l Deciding what flaw to work on next = serializing this tree (turning it into a state-space tree) u at each AND branch, Partial plan p choose a child to Goal g 1 expand next, and Operator o 1 Operator on delay expanding … the other children Partial plan p 1 Partial plan pn Goal g 2 … Variable … Order constraint tasks Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

One Serialization Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning

One Serialization Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Another Serialization Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning

Another Serialization Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Why Does This Matter? l Different refinement strategies produce different serializations u the search

Why Does This Matter? l Different refinement strategies produce different serializations u the search spaces have different numbers of nodes l In the worst case, the planner will search the entire serialized search space l The smaller the serialization, the more likely that the planner will be efficient l One pretty good heuristic: fewest alternatives first (FAF heuristic) => choose the flaw having the smallest number of resolvers. This will limit the cost of eventual backtracks. Takes O(n) where n is the number of flaws in a partial plan. Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

How Much Difference Can the Refinement Strategy Make? l Case study: build an AND/OR

How Much Difference Can the Refinement Strategy Make? l Case study: build an AND/OR graph from repeated occurrences of this pattern: l Example: u number of levels k = 3 u branching factor b = 2 l Analysis: u Total number of nodes in the AND/OR graph is n = (bk) u How many nodes in the best and worst serializations? Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Case Study, Continued l k 2 The best serialization contains (b ) nodes l

Case Study, Continued l k 2 The best serialization contains (b ) nodes l k k 2 The worst serialization contains (2 b ) nodes u The size differs by an exponential factor, but the best serialization still is exponentially large u To do better, need good node selection, branching, pruning Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/

Resolver selection heuristics l Let be the set of all plans generated with all

Resolver selection heuristics l Let be the set of all plans generated with all the possible reasolvers. Select a plan that has the smallest set of sug-goal whithout causal links (not very informed heuristic). l A more informative heuristic: construct an AND/OR graph along regression steps defined by -1 down to some fixed level k l Select the plan that minimizes the wheighted sum of: 1. The number of actions in this graph that are not in and 2. The number of subgoals remaining in its leaves that are not in the initial state Leliane Nunes de Barro. Slides extraidos de Lecture slides for Automated Planning by Dana Nau. Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/