Presentation is loading. Please wait.

Presentation is loading. Please wait.

AI – Week 3 An Introduction to AI Planning Lee McCluskey, room 3/10

Similar presentations


Presentation on theme: "AI – Week 3 An Introduction to AI Planning Lee McCluskey, room 3/10"— Presentation transcript:

1 AI – Week 3 An Introduction to AI Planning Lee McCluskey, room 3/10 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 Languages for writing Domain Models… Literal Based: The “Planner Domain Definition Language” (PDDL) is the most commonly used language to communicate Planning Domain Models and associated Tash Descriptions Object-Centred: At Huddersfield we have pioneered the use of “object based” languages – the simple rocket world domain model is object centred.

6 Artform Research Group 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) An alternative way of encoding states is using an “ object centred representation”, where 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.

7 Artform Research Group The Modelling of Actions This is CENTRAL to planning. In a literal based domain model, actions are modelled as PRE and POST conditions in the form of PRECONDITION SET ADD SET DELETE SET In an object-centred domain model, we use a more structured form: PREVAIL CONDITION NECESSARY OBJECT TRANSITIONS CONDITIONAL OBJECT TRANSITIONS

8 Artform Research Group The Relationship: from O-C to Literal-based (assume no conditional transitions) PRECONDITION SET = PREVAIL + LHS of NECESSARY OBJECT TRANSITIONS ADD SET = RHS of NECESSARY OBJECT TRANSITIONS 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.

9 Artform Research Group Operator Schema – rocket world op(move(R,A,B), % prevail [condition(A,[can_fly(A,B)])], % necessary [ trans(R,[position(R,A), fuel_full(R)], [position(R,B), fuel_empty(R)] ) ], % conditional [ ]).

10 Artform Research Group Operators - An Operator Schema O has Precons(O), Deletes(O) and Adds(O) - An instance/instantiation of an Operator Schema (aka a ground operator) is one which has all its parameters replaced by constants. 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)

11 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!

12 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

13 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!!!

14 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, PartialSoln, heuristic value) 3. pick an operator and parameter instantiation - 'O' - that can be applied to State 4. apply O to State to get State' 5. assert(node(State', Add(O, PartialSoln), heuristic value) 6. if possible, backtrack to 3. and make a different choice. until a node has been asserted that contains a solution

15 Artform Research Group Building your own forward searching planner INITIAL NODE Each node contains several pieces of information: - a state - sequence of operators that lead to the state - heuristic value

16 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).

17 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.

18 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),!.

19 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(_,_).

20 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).

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


Download ppt "AI – Week 3 An Introduction to AI Planning Lee McCluskey, room 3/10"

Similar presentations


Ads by Google