Presentation is loading. Please wait.

Presentation is loading. Please wait.

AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07

Similar presentations


Presentation on theme: "AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07"— Presentation transcript:

1 AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07 Email lee@hud.ac.uklee@hud.ac.uk http://scom.hud.ac.uk/scomtlm/cha2555/

2 Artform Research Group Overview How do we make automated planning programs? - we will consider several planning algorithms How do we model planning application knowledge? - we will study several ways of encoding planning domains

3 Artform Research Group PLANS Are what planners generate. They are orders of instantiated operator schemas. They should be: CORRECT - preconditions are satisfied COMPLETE - achieve the final goal OPTIMAL - n shorter plan exists

4 Artform Research Group Simple Planning Worlds A simple planning problem can be formulated by: - An INITIAL STATE - A GOAL - A set of OPERATOR schema Later we will see other formulations.,.

5 Artform Research Group Recall Last Week: The Modelling of States A STATE represents a situation or snapshot of an application. This is sometimes called a WORLD STATE STATES of a planning world are most simply defined (as in PDDL) as conjunctions of ground literals (like a relational database for each state) In object centred representations, dynamic OBJECTS have their own state also (sometimes called ‘sub- state’). A world state therefore consists of a conjunction of the states of each object.

6 Artform Research Group Recall Last Week: The Modelling of Actions This is CENTRAL to planning. Most simply, actions are modelled as OPERATORS with PRE and POST conditions in the form of n PRECONDITION SET n ADD SET n DELETE SET In object – centred notations we use a more structured form: n PREVAIL CONDITION n NECESSARY OBJECT TRANSITIONS n CONDITIONAL OBJECT TRANSITIONS

7 Artform Research Group The Relationship: from O-C to Literal-based (assume no conditional transitions) n PRECONDITION SET = PREVAIL + LHS of NECESSARY OBJECT TRANSITIONS n ADD SET = RHS of NECESSARY OBJECT TRANSITIONS n DELETE SET = LHS of NECESSARY OBJECT TRANSITIONS So can define things in terms of a literal-based representation, and they will also apply to an OC one.

8 Artform Research Group Operators - An Operator Schema O has Precons(O), Deletes(O) and Adds(O) - An instance of an Operator Schema (a ground operator) is one which has all its parameters are replaced by constants. (NB two instances may have different effects because of conditional effects) A ground operator O can be applied to a state S IF Precons(O) are satisfied in S If operator O is applied/executed to state S then new state O(S) = S minus Deletes(O) plus Adds(O) [More complex for a conditional Operator]

9 Artform Research Group Automated Planning How can algorithms solve planning problems? - Easiest answer: 1. Apply ‘applicable’ OPERATORS to INITIAL STATE to create new states, then repeat this process from new states (use breadth, depth or heuristic search). 2. Stop when a state S is reached in which S satisfies the GOAL condition BUT this leads to an exponential explosion of states!

10 Artform Research Group Solution to Plan Generation Problems A “goal achievement” plan generation problem is given by an Initial state, a Goal and a set of Operator Schema. A linear SOLUTION to a plan generation problem is a sequence of ground operators that are COMPLETE and CORRECT: Complete: The preconditions of the first operator are satisfied by the Initial state, and the preconditions of each subsequent operator in the sequence are satisfied by the corresponding intermediate states Correct: The Goal is satisfied in the final state

11 Artform Research Group FORWARD, STATE SPACE SEARCH INITIAL STATE Main source of inefficiency in search algorithms is the branching factor EXHAUSTIVE SEARCH IS VERY INEFFICIENT!!! Assume each state is modelled as a set of LITERALS

12 Artform Research Group Planning Algorithm: breadth-first forward search through state-space 1. Store the first node (initial state + empty solution) Repeat 2. pick and “retract” a node(State, Soln, heuristic value) 3. pick an operator and parameter grounding - 'O' - that can be applied to State 4. apply O to State to get State' 5. assert(node(State', Soln++[O], heuristic value) 6. if possible, backtract to 3. and make a different choice. until a node has been asserted that contains a solution

13 Artform Research Group Building your own forward searching planner INITIAL NODE Each node is a state + sequence of operators that lead to the state + heuristic value

14 Artform Research Group Initialisation – assert the first node % asserts the root node in the search.. start(Goal, Initial_State) :- % this records the run-time clock statistics(runtime,[_,Time]), % initialise node count to 0 retractall(count(_)), assert(count(0)), assert_and_record_node( node(Initial_State,[ ])), plan(Goal).

15 Artform Research Group Pick a node to EXPAND % Retracts the first node in the prolog program and expands it.. % a node is of the form node(Advanced_state, Op_sequence) plan(Goal) :- retract(node(Advanced_state, Op_sequence)), length(Op_sequence,Len), tell(user),write(Len), process_node(Goal, Advanced_state, Op_sequence), % then keep searching.. plan(Goal). % SEARCH FINISHES: if no nodes left - end - close trace file plan(_) :- tell(trace), told.

16 Artform Research Group But wait.. have we found a complete plan? process_node(Goal, Advanced_state, Op_sequence):- achieved(Goal, Advanced_state), ETC.. Collect stats and tidy up retractall(node(_,_)),!. % if no success, generate more nodes process_node(Goal, Advanced_state, Op_sequence):- generate_new_nodes(Advanced_state, Op_sequence),!.

17 Artform Research Group Heart of the Algorithm – generate new nodes generate_new_nodes(Advanced_state, Op_sequence) :- op(Op_name, Prev, Nec, Cond), achieved(Prev,Advanced_state), lhs_achieved(Nec,Advanced_state), % apply(Op_name, Advanced_state, New_Advanced_state), append(Op_sequence, [Op_name], New_Op_sequence), assert_and_record_node(node(New_Advanced_state, New_Op_sequence)), fail. % after all operators are tried, this procedure should succeed - generate_new_nodes(_,_).

18 Artform Research Group Are object states achieved in a state? NB no cuts to allow for backtracking lhs_achieved([],_). lhs_achieved([trans(O,E,_)|Tail],State) :- member(state(O,S),State), is_a_subset(E,S), lhs_achieved(Tail,State). achieved([],_). achieved([condition(O,E)|Tail], State) :- member(state(O,S),State), is_a_subset(E,S), achieved(Tail,State).

19 Artform Research Group Summary n Creating forward search AI Planners in Prolog is fairly easy n The main part is the generation of ALL new nodes possible from an existing node n The sample AI Planners can be augmented with heuristics (next week)


Download ppt "AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07"

Similar presentations


Ads by Google