CS G120 Artificial Intelligence - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

CS G120 Artificial Intelligence

Description:

A sequence of actions to change the initial state into one that satisfies the goal ... Brute force: DFS, BFS, Iterative Deepening, .., Heuristic: A ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 47
Provided by: carole5
Category:

less

Transcript and Presenter's Notes

Title: CS G120 Artificial Intelligence


1
CS G120 Artificial Intelligence
  • Prof. C. Hafner
  • Class Notes Feb 26, 2009

2
AI planning
  • Generating plans
  • Given
  • A way to describe the world
  • An initial state of the world
  • A goal description
  • A set of possible actions to change the world
  • Find
  • A sequence of actions to change the initial state
    into one that satisfies the goal
  • Note similarity to state space search (e.g., 8
    puzzle)
  • Planning extends to more complex worlds

3
Applications
  • Mobile robots
  • An initial motivator, and still being developed
  • Simulated environments
  • Goal-directed agents for training or games
  • Web and grid environments
  • Intelligent Web bots
  • Workflows on a computational grid
  • Managing crisis situations
  • E.g. oil-spill, forest fires, urban evacuation,
    in factories,
  • And many more
  • Factory automation, flying autonomous spacecraft,
    playing bridge, military planning,

4
Plannning Representing change
  • As actions change the world OR we consider
    possible actions, we need to
  • Know how an action will alter the world
  • Keep track of the history of world states (have
    we been here before?)
  • 3 approaches
  • Situation calculus
  • Strips approach
  • With total order planning (state space search)
  • Partial order planning (POP)

5
Classical Planning Assumptions
  • Discrete Time
  • Instantaneous actions
  • Deterministic Effects
  • Omniscience
  • Sole agent of change
  • Goals of attainment (not avoidance)

6
The situation calculus revisited(McCarthy 63)
  • Key idea represent a snapshot of the world,
    called a situation explicitly.
  • Fluents are statements that are true or false
    in any given situation, e.g. I am at home
  • Actions map situations to situations.

7
S1
S1 result(go(store), S0)
holds(at(home), S1)
S0
go(store)
holds(at(store), S1)
mow_lawn()
S2
holds(at(home), S0) holds(color(door, red), S0)
8
Monkeys and Bananas ProblemAssignment 5a
Planning by Logical Inference
  • The monkey-and-bananas problem is faced by a
    monkey standing under some bananas which are
    hanging out of reach from the ceiling. There is a
    box in the corner of the room that will enable
    the monkey to reach the bananas if he climbs on
    it.
  • Use situation calculus to represent this problem
    and solve it using resolution theorem proving.

9
Representation of Monkey/Banana problem
  • Fluents Constants
  • At(x, loc, s) - BANANAS
  • On(x, y, s) - MONKEY
  • Reachable(x, Bananas, s) - BOX
  • Has(x, y, s) - S0
  • Other predicates - CORNER
  • Moveable(x), Climbable(x) - UNDER-BANANAS
  • Can-move(x)
  • Actions
  • Climb-on(x, y) -- Move(x, loc)
  • Reach(x, y) -- Push(x, y, loc)

10
Monkey/Bananas axioms
  • ? x, s Reachable(x, BANANAS, s) ? Has(x,
    BANANAS, Result(Reach(x, BANANAS), s))
  • ? s At(BOX, UNDER-BANANAS, s)
    On(MONKEY, BOX, s) ? Reachable(x, BANANAS, s)
  • ? x, loc, s Can-move(x) ? At(x, loc,
    Result(Move(x, loc), s))
  • ? x, y, s ? loc At(x, loc, s) At(y, loc, s)
    Climbable(y) ? On(x, y, Result(Climb-on(x, y),
    s))
  • ? x, y, loc, s ? loc2 At(x, loc2, s) At(y,
    loc2, s) Moveable(y) ? At(y, loc,
    Result(Push(x, y, loc), s))
  • At(x, loc, Result(Push(x, y,
    loc), s))

11
Monkey/Bananas axioms (initial state S0)
  • Moveable(BOX)
  • Climbable(BOX)
  • Can-move(MONKEY)
  • At(BOX, CORNER, S0)
  • At(MONKEY, UNDER-BANANAS, S0)
  • You will need to
  • Convert to clause form
  • Apply resolution to prove something like this
  • Has(MONKEY, BANANAS, Result(Reach( . . . ),
    Result(. .) . .), S0)
  • which gives you the plan in reverse order.
  • (dont forget to standardize!)

12
Assignment 5b Due March 9
  • Implement the backward chaining algorithm from
    your text book, in one file with the following
    interface/API
  • readKB(file) returns a data structure of your
    choice
  • folBCAsk(KB, goals, THETA)
  • Goals is a list of FOLexps
  • Theta is a substitution
  • Returns ANS, a LIST of substitutions (initially
    empty)
  • displayANS(ANS) prints the result
  • These must be 3 separate functions callable by
    the user. Also KB must not be changed by
    folBCAsk or displayANS, so these can be called
    repeatedly.

13
Assignment 5b input file format
  • FACT
  • LikesJohn, Pizza
  • RULE
  • Likesx, Pizza
  • gt
  • Likesx, Spaghetti
  • RULE
  • Richx
  • Healthyx
  • gt
  • Happyx

14
Refutation Resolution as the theoretical basis of
BC
  • A query is conceptualized with existential
    variables
  • ? Likes(John, x) means ? ?x Likes(John, x)
  • to answer the question, assert its NEGATION, and
    attempt to derive a contradiction by RESOLVING TO
    THE EMPTY CLAUSE!
  • ?x Likes(John, x) is equivalent to ? x
    Likes(John, x), so add that to the KB and try to
    derive the empty clause
  • Resolution rule
  • A1 V A2 V . . . An
  • B1 V B2 V . . Bm V A1 where A1 and A1 unify
  • --------------------------------------------------
    -------------
  • A2 V . . . An B1 V B2 V . . . Bm
  • Likes(John, Pizza) Likes(John, x) resolves to
    , given x/John

15
Return to Planning
16
A Limitation of Situation Calculus The Frame
problem
  • I go from home (S) to the store, creating a new
    situation S. In S
  • My friend is still at home
  • The store still sells chips
  • My age is still the same
  • Los Angeles is still the largest city in
    California
  • How can we efficiently represent everything that
    hasnt changed?

17
Successor state axioms
  • Normally, things stay true from one state to the
    next --
  • unless an action changes them
  • holds(at(X),result(A,S)) iff A go(X)
  • or holds(at(X),S) and A ! go(Y)
  • We need one or more of these for every fluent
  • Now we can use theorem proving (or possibly
    backward chaining) to deduce a plan not very
    practical

18
Strips (Fikes and Nilsson 71)
  • For efficiency, separates theorem-proving within
    a world state from searching the space of
    possible states
  • Highly influential representation for actions
  • Preconditions (list of propositions to be true)
  • Delete list (list of propositions that will
    become false)
  • Add list (list of propositions that will become
    true)

19
Example problem
  • Initial state at(home), have(beer),
    have(chips)
  • Goal have(beer), have(chips), at(home)
  • Actions
  • Buy (X)
  • Pre at(store)
  • Add have(X)

Go (X, Y) Pre at(X) Del at(X) Add at(Y)
20
Frame problem (again)
  • I go from home to the store, creating a new
    situation S. In S
  • The store still sells chips
  • My age is still the same
  • Los Angeles is still the largest city in
    California
  • How can we efficiently represent everything that
    hasnt changed?
  • Strips provides a good solution for simple actions

21
Another problem Ramification problem
  • I go from home to the store, creating a new
    situation S. In S
  • I am now in Marina del Rey
  • The number of people in the store went up by 1
  • The contents of my pockets are now in the store..
  • Do we want to say all that in the action
    definition?

22
Solutions to the frame and ramification problems
  • In Strips, some facts are inferred within a world
    state,
  • e.g. the number of people in the store
  • All other facts, e.g. at(home) persist between
    states unless changed (remain unless on delete
    list)
  • A challenge for programmer to avoid mistakes

23
Questions about Strips
  • What would happen if the order of goals was
  • at(home), have(beer), have(chips) ?
  • When Strips returns a plan, is it always correct?
    efficient?
  • Can Strips always find a plan if there is one?

24
Example blocks world (Sussman anomaly)
Initial
A
Goal
C
B
A
B
C
  • State I (on-table A) (on C A) (on-table B)
    (clear B) (clear C)
  • Goal (on A B) (on B C)
  • Naïve planning algorithm output Put C on
    table, put A on B goal 1 accomplished, put A on
    table, put B on C both goals accomplished
    DONE!!!!

25
Partial Order Planning (POP)
  • Explicitly views plans as a partial order of
    steps. Add ordering into the plan as needed to
    guarantee it will succeed.
  • Avoids the problem in Strips, that focussing on
    one subgoal forces the actions that resolve that
    goal to be contiguous.

26
How to get dressed
  • State
  • Goal RightShoeOn, LeftShoeOn
  • Actions
  • PutRshoe, Precond RightSockOn, Effect
    RightShoeOn
  • PutLshoe, Precond LeftSockOn, Effect LeftShoeOn
  • PutRsock, Effect RightSockOn
  • PutLsock, Effect LeftSockOn
  • Create a POP graph of solutions with causal
    links A achieves P for B A
    B (also called protection links). This
    prevents another goal from causing a sock to be
    removed before the shoe goes on.

p
27
Total-Order vs Partial-Order Plans
28
Remember the Sussman Anomaly
Initial State (on-table A) (on C A) (on-table B)
(clear B) (clear
C) Goal (on A B) (on B C)
29
POP using Nets Of Action Hierarchies
on(a, b)
S
J
on(b, c)
clear(a)
puton(a, b)
S
J
clear(b)
S
J
clear(b)
puton(b, c)
S
J
clear(c)
30
Nets Of Action Hierarchies
on(a, b)
S
J
on(b, c)
clear(a)
puton(a, b)
S
J
clear(b)
S
J
clear(b)
puton(b, c)
S
J
clear(c)
Add a threat link to the network of plan actions
31
Resolve threat with an order link
clear(a)
puton(a, b)
S
J
clear(b)
S
J
clear(b)
puton(b, c)
S
J
clear(c)
clear(a)
puton(a, b)
S
J
clear(b)
S
J
clear(b)
puton(b, c)
S
J
clear(c)
32
clear(a)
puton(a, b)
S
J
clear(b)
S
J
clear(b)
puton(b, c)
S
J
clear(c)
clear(a)
puton(a, b)
J
S
clear(b)
puton(b, c)
S
J
clear(c)
33
clear(a)
puton(a, b)
J
S
clear(b)
puton(b, c)
S
J
clear(c)
puton(c, X)
clear(a)
puton(a, b)
J
S
clear(b)
puton(b, c)
S
J
clear(c)
34
Final plan
puton(c, X)
clear(a)
puton(a, b)
puton(b, c)
J
S
clear(b)
35
Action RepresentationPropositional STRIPS (real
STRIPS uses variables)
  • Move-C-from-A-to-Table
  • preconditions (on C A) (clear C)
  • effects
  • add (on-table C)
  • delete (on C A)
  • add (clear A)
  • Solution to frame problem explicit effects are
    the only changes to the state.

36
Total-Order Plan GenerationSearch space of
world states
  • Planning as a search problem
  • Nodes world states
  • Arcs actions
  • Solution path from the initial state to one
    state that satisfies the goal
  • Initial state is fully specified
  • There may be many goal states

37
Search Space Blocks World
38
ProgressionForward search (I -gt G)
  • ProgWS(state, goals, actions, path)
  • If state satisfies goals, then return path
  • else a choose(actions), s.t.
  • preconditions(a) satisfied in state
  • if no such a, then return failure
  • else return
  • ProgWS(apply(a, state), goals, actions,
  • concatenate(path, a))
  • First call ProgWS(IS, G, Actions, ())

39
Progression Example Sussman Anomaly
  • I (on-table A) (on C A) (on-table B) (clear B)
    (clear C)
  • G (on A B) (on B C)
  • P(I, G, BlocksWorldActions, ())
  • P(S1, G, BWA, (move-C-from-A-to-table))
  • P(S2, G, BWA, (move-C-from-A-to-table,
  • move-B-from-table-to-C))
  • P(S3, G, BWA, (move-C-from-A-to-table,
  • move-B-from-table-to-C,
  • move-A-from-table-to-B))

G ? S3 gt Success!
40
RegressionBackward Search (I lt- G)
  • RegWS(init-state, current-goals, actions, path)
  • If init-state satisfies current-goals, then
    return path
  • else a choose (actions), s.t. some effect of
    a satisfies one of current-goals
  • If no such a, then return failure
    unachievable
  • If some effect of a contradicts some of
    current-goals, then return failure
    inconsistent state
  • CG current-goals effects(a)
    preconditions(a)
  • If current-goals ? CG, then return failure
    useless
  • RegWS(init-state, CG, actions,
    concatenate(a,path))
  • First call RegWS(IS, G, Actions, ())

41
Regression Example Sussman Anomaly
  • I (on-table A) (on C A) (on-table B) (clear B)
    (clear C)
  • G (on A B) (on B C)
  • R(I, G, BlocksWorldActions, ())
  • R(I, ((clear A) (on-table A) (clear B) (on B C)),
    BWA,

  • (move-A-from-table-to-B))
  • R(I, ((clear A) (on-table A) (clear B) (clear C),
    (on-table B)),
  • BWA, (move-B-from-table-to-C,
    move-A-from-table-to-B))
  • R(I, ((on-table A) (clear B) (clear C) (on-table
    B) (on C A)),
  • BWA, (move-C-from-A-to-table,
    move-B-from-table-to-C,
  • move-A-from-table-to-B))

current-goals ? I gt Success!
42
Progression vs. Regression
  • Both algorithms are
  • Sound the result plan is valid
  • Complete if valid plan exists, they find one
  • Non-deterministic choice gt search!
  • Brute force DFS, BFS, Iterative Deepening, ..,
  • Heuristic A
  • Regression often faster, focused by goals
  • Progression full state to compute heuristics

43
Plan Generation Search space of plans
  • Partial-Order Planning (POP)
  • Nodes are partial plans
  • Arcs/Transitions are plan refinements
  • Solution is a node (not a path).
  • Principle of Least commitment
  • e.g. do not commit to an order of actions until
    it is required

44
Partial Plan Representation
  • Plan (A, O, L), where
  • A set of actions in the plan
  • O temporal orderings between actions (a lt b)
  • L causal links linking actions via a literal
  • Causal Link
  • Action Ac (consumer) has precondition Q that
    is established in the plan by Ap (producer).
  • move-a-from-b-to-table
    move-c-from-d-to-b

(clear b)
45
Threats to causal links
  • Step At threatens link (Ap, Q, Ac) if
  • 1. At has (not Q) as an effect, and
  • 2. At could come between Ap and Ac, i.e.
  • O ? (Ap lt At lt Ac ) is consistent
  • Whats an example of an action that threatens the
    link example from the last slide?

46
POP algorithm takes account of threats to
causal links
  • POP((A, O, L), agenda, actions)
  • If agenda () then return (A, O, L)
  • Pick (Q, aneed) from agenda
  • aadd choose(actions) s.t. Q ?effects(aadd)
  • If no such action aadd exists, fail.
  • L L ? (aadd, Q, aneed) O O ? (aadd
    lt aneed)
  • agenda agenda - (Q, aneed)
  • If aadd is new, then A A ? aadd and
  • ?P ?preconditions(aadd), add (P, aadd) to
    agenda
  • For every action at that threatens any causal
    link (ap, Q, ac) in L
  • choose to add at lt ap or ac lt at to O.
  • If neither choice is consistent, fail.
  • POP((A, O, L), agenda, actions)

Termination
Goal Selection
Action Selection
Update goals
  • Protect causal links
  • Demotion at lt ap
  • Promotion ac lt at
Write a Comment
User Comments (0)
About PowerShow.com