Presentation is loading. Please wait.

Presentation is loading. Please wait.

AI – Week 5 More on HEURISTICS and domain modelling Lee McCluskey, room 2/09

Similar presentations


Presentation on theme: "AI – Week 5 More on HEURISTICS and domain modelling Lee McCluskey, room 2/09"— Presentation transcript:

1 AI – Week 5 More on HEURISTICS and domain modelling Lee McCluskey, room 2/09 Email lee@hud.ac.uklee@hud.ac.uk http://scom.hud.ac.uk/scomtlm/cha2555/

2 Artform Research Group This week … -- TOPIC 1 – Continue from last week to look at how heuristics are implemented – use code under “Application 5” – called “planblocksGH” -TOPIC 2 – Domain Modelling – how to encode domains

3 Search Tree Example INITIAL STATE Goal condition: A&B&C&D&E A&B&C&D solved A&B solved A&B&C solved C&D solved A&B solved E solved C&D solved 1+3 3+3 4+2 3+2 2+1 3+1 Greedy Scores in Red

4 Adding Heuristics to the Prolog Code-1 Heuristic: Prune the tree: don't add a new open node to the search if it contains a state (X below) which is the SAME state that is already in an open node. assert_and_record_node(X) :- not_already_there(X), % If it is there, don’t assert it … assertz(X), ETC not_already_there(node(X,_,_)) :- node(X,_,_),!,fail. % not_already_there(_) :- !. Q: does this affect search completeness? Does this affect optimality?

5 Adding Heuristics to the Prolog Code-2 Pseudo-A* Heuristic Recall node n = (list of object states, sequence of actions, node COST), Where COST(n ) = g(n)+h(n) g(n) = length of sequence of actions (length of list of ops) it took to get there h(n) = how many subgoals still to solve. Prolog Fragments: plan(Goal) :- retract_the_best(node(Advanced_state, Op_sequence, COST)), ETC ……. cal_cost(Goal, New_Advanced_state, New_action_seq, COST) :- goals_left(Goal, New_Advanced_state, LEFT), length(LEFT, HN), length(New_action_seq,GN), COST is GN + HN,!.

6 Artform Research Group Topic 2: Domain Modelling NB Improvement to basic STRIPS encoding: I have added the ability to put EVALUABLE predicates in states such as maths operators and assignment, so we can easily deal with RESOURCES Domain: Robot moves around Canalside West and can carry things around. We want to give it tasks and it has to work out a correct and efficient plan to carry out the tasks, within its resource limit.

7 Objects Cargo (c1, c2, ….) Robots (r1, r2, ….) Places (Rooms – room319, landing3,..)

8 Objects + Attributes/Relations Cargo (c1, c2, ….) at(Cargo, Place), in(Cargo, Robot), Robots (r1, r2, ….) position(Robot, Place), fuel_level(Robot, Int) Places (Rooms – room319, landing3,..) connects(Place, Place) Built-in predicates – is(Int Parameter, Int Expression) – always true with a side effect ge(Int Parameter, Int Expression) – true or false

9 World State (see applic. 7 code) A “world state” is a set of the states of each object in the problem. A state of an object is the object name, followed by a set of predicates that are true of the object. NB 1. Sets are represented by lists 2. Normally predicates are only represented once 3. Some objects are STATIC – that is their predicates (attributes and relations) cannot be change by operators

10 Example of Initial State (see applic. 7 code) [ state(c1,[at(c1,landing)]), state(c2,[at(c2,landing)]), state(c3,[at(c3,landing)]), state(c4,[at(c4,landing)]), state(r1,[position(r1,landing),fuel_level(r1,4)]), state(r2,[position(r2,landing),fuel_level(r2,4)]), state(landing, [connects(landing,menstoilet), connects(landing,corridor)]), state(menstoilet, [connects(menstoilet,landing), connects(menstoilet,corridor)]), state(corridor, [connects(corridor,menstoilet), connects(corridor,landing)])

11 Goal Condition (see applic. 7 code) A “goal condition” is a set of conditions on objects that have to be achieved. Eg from application 7 [ condition(r2,[position(r2,menstoilet)]) ] [ condition(c1,[at(c1,corridor)]), condition(r2,[position(r2,menstoilet)]) ],

12 Operator Schema Move robot Pickup Cargo Putdown Cargo op(move(R,A,B), % prevail [condition(A,[connects(A,B)])], % necessary [ trans(R,[position(R,A), fuel_level(R,X), ge(X,1), is(XX,X-1)], [position(R,B), fuel_level(R,XX)] ) ], % conditional [ ]).

13 PDDL Syntax (:types Cargo - object Robot - object Place - object ) (:predicates (at ?c - Cargo ?p - Place) (in ?c - Cargo?r - Robot) (fuel_level ?r – Robot ?l - Int) (position ?r – Robot, ?p – Place) (connected ?p1 – Place ?p2 - Place) ) (:action load :parameters (?c – Cargo ?r - Robot ?a - Place) :precondition (and (position ?r ?a) (at ?c ?a) ) :effect (and (in ?c ?r) (not (at ?c ?a)) )

14 Domain Modelling – another example Seller (apollo, amazon, ….) Product (star_wars, terminator, cats,..) constants - bank, service state(bank, [have_password(bank,abcd),balance(bank,100)]), state(money, [haveresource(money,10)]), state(service,[logged_off]), state(apollo,[service(apollo), freeseat(apollo,cats), seat_price(apollo,25)]), state(amazon, [service(amazon), dvd_price(amazon,terminator,10), instock(amazon, terminator), instock(amazon, star_wars), ETC

15 Artform Research Group Operator Schema- example op( book_theatre_seat(Ticket,Seller,Prod), [condition(Seller,[freeseat(Seller,Prod), seat_price(Seller,X)]), condition(S,[logged_on(S,Seller)]) ], [trans(Money, [haveresource(Money,Y), ge(Y, X), is(YX,Y-X)], [haveresource(Money,YX)]), trans(Ticket, [have_no_ticket(Seller,Prod)], [have_ticket(Ticket,Seller,Prod)]) ], [ ]).

16 Summary Heuristics are vital to make a Planner work efficiently Domain Modelling is the art of constructing a model of a domain within some knowledge representation language such as OCL or PDDL.


Download ppt "AI – Week 5 More on HEURISTICS and domain modelling Lee McCluskey, room 2/09"

Similar presentations


Ads by Google