150 likes | 300 Views
CSE 471-Project 3 Regression Planner using A*. Sreelakshmi Vaddi. Example: Regression planner. Initial: {P,Q} Goal: {P,Q,R,S}. operator O1 prec: P Eff: R, ~S operator O2 prec: Q Eff: S operator O3 prec: P Eff: M operator O4 prec: R,S Eff: P,Q,R,S operator O5 prec: R,S Eff: P.
E N D
CSE 471-Project 3Regression Planner using A* Sreelakshmi Vaddi
Example: Regression planner Initial: {P,Q} Goal: {P,Q,R,S} operator O1 prec: P Eff: R, ~S operator O2 prec: Q Eff: S operator O3 prec: P Eff: M operator O4 prec: R,S Eff: P,Q,R,S operator O5 prec: R,S Eff: P Number of elements {curr state MINUS Goal} G=1 h=1 PQ O1 PQR G=2 h=0 O2 PQRS H0: USING SET DIFFERENCE HEURISTIC – A* G=0 h=0 O4 RS G=1 h=2 O5 Goal: {P,Q} Initial: {P,Q,R,S} QRS G=1 h=1
Example: Regression planner operator O1 prec: P Eff: R, ~S operator O2 prec: Q Eff: S operator O3 prec: P Eff: M operator O4 prec: R,S Eff: P,Q,R,S operator O5 prec: R,S Eff: P P -> 0, Q -> 0, R -> 1, S-> 1 SUM (set-level-val-without-mutex (each condition)) G=1 h=1 PQ O1 PQR G=2 h=0 O2 PQRS G=0 h=0 H1: Heuristic function that computes the cost of a set as the sum of the levels of the individual elements of the set - A* O4 RS G=1 h=2 O5 QRS Goal: {P,Q} Initial: {P,Q,R,S} G=1 h=2
Example: Regression planner operator O1 prec: P Eff: R, ~S operator O2 prec: Q Eff: S operator O3 prec: P Eff: M operator O4 prec: R,S Eff: P,Q,R,S operator O5 prec: R,S Eff: P PQRS -> 1, PQR -> 1, RS -> 1, QRS-> 1, PQ->0 set-level-val-without-mutex (list of all conditions) G=1 h=1 PQ O1 PQR G=2 h=0 O2 PQRS H2: Heuristic function that computes the cost of a set as the level at which that particular set occurs first– A* G=0 h=0 O4 RS G=1 h=1 O5 QRS Goal: {P,Q} Initial: {P,Q,R,S} G=1 h=1
Example: Regression planner operator O1 prec: P Eff: R, ~S operator O2 prec: Q Eff: S operator O3 prec: P Eff: M operator O4 prec: R,S Eff: P,Q,R,S operator O5 prec: R,S Eff: P PQRS -> 2, PQR -> 1, RS -> 2, QRS-> 2, PQ->0 set-level-val-with-mutex (list of all conditions) G=1 h=1 PQ O1 PQR G=2 h=0 O2 PQRS H3: Heuristic function that computes the cost of a set as the level at which that particular set occurs first without any mutexes– A* G=0 h=0 O4 RS G=1 h=2 O5 QRS Goal: {P,Q} Initial: {P,Q,R,S} G=1 h=2
What you need to get started • Load the code given to you on Allegro • You need not touch/modify this code at all • Loading instructions on project webpage :problems file + graph plan code • You will need from Project 1 – A* search • Node structure • Children function • A* main function • Trace path • Display stats part • Puzzle children • F-value fn NEW FUNCTIONS: Heuristics: H0,H1,H2,H3 Goalp: (Actually initialp)
Heuristics and Goalp functions H0: Number of elements {curr state MINUS Goal} H1: SUM (set-level-val-without-mutex (each condition)) H2: set-level-val-without-mutex (list of all conditions) H3: set-level-val-with-mutex (list of all conditions) Goalp: find if current state is equal to the goal state Eg: {PQR} = {PQ} FALSE
Puzzle Children Function • Generates the children of current state, by checking if there is an operator applicable to current state • When can you apply an op to state s? • None of effects of op negate conditions in S (Reason why we don’t apply O1 in Eg) • At least one effect of op is in S (Reason why we don’t apply O3 in Eg) • And May be more conditions Negative literals Op-adds, op-deletes
Puzzle Children Function Contd • New state generation? op-preconditions U (parent state – op-effects) • IMPORTANT: Handling negative literals • ‘P is (:NOT (P)) (So check car of every condition to see if its negative literal and then *special*) • Op-deletes, op-adds can be useful than op-effects • PQR on o1 ? (operator O1 prec: P Eff: R, ~S) {p} U {{p,q,r}-{r,~s}}={p,q}
Useful functions-Graph Plan code • (get-ground-operators ‘Eg-problem) : returns O1..O5 • (op-name op1) : returns (UNSTACK A A) • (op-preconditions op1) • ((ON A A) (CLEAR A) (ARM-EMPTY)) • (op-effects op1) • ((HOLDING A) (CLEAR A) (:NOT (CLEAR A)) (:NOT (ARM-EMPTY)) (:NOT (ON A A))) • (op-adds op1) • ((HOLDING A) (CLEAR A)) • (op-deletes op1) • ((CLEAR A) (ARM-EMPTY) (ON A A))
Useful functions-Graph Plan code • (problem-init 'class-problem) : Initial state of the problem • ((OBJECT A) (OBJECT B) (ON-TABLE A) (ON-TABLE B) (CLEAR A) (CLEAR B) (ARM-EMPTY)) • (problem-goal 'class-problem) : Goal state of the problem • ((:NOT (CLEAR B)) (ARM-EMPTY)) • Heuristic Functions • (Compute-pg problem) : Has to be called in the beginning of every problem so that you can call all the above functions as well as heuristic functions.
Other functions • Lisp set operations (list1 list2 :test #’equal) • Set Difference • Union • Intersection
Possible Program Flow • Call compute-gp, get-ground-operators, problem-init, problem-goal • Make goal node from problem-init • Call A*(list goal-node, goalp,…) • Change puzzle-children function as discussed above • Write Goalp function • Write heuristic functions calling set-level functions from the given code
Progression Planner - Simpler • When an OP can apply to state S? • S contains OP-preconditions • New child state • (S Union OP-effects) • Rest remain same • And don’t forget to change the compute-pg code part as said by Dr.Rao in project description
Example: Progression planner Initial: {P,Q} Goal: {P,Q,R,S} operator O1 prec: P Eff: R, ~S operator O2 prec: Q Eff: S operator O3 prec: P Eff: M operator O4 prec: R,S Eff: P,Q,R,S operator O5 prec: R,S Eff: P H0: Using Set difference heuristic G=1 h=1 PQ O1 PQR G=0 h=0 O2 PQRS O2 G=0 h=0 PQS G=1 h=1 O2 on PQ? Child : {P,Q} U {Q,S}={P,S} O4,O5 on PQ? NO R Not in PQ, S not in PQ O3 PQM G=1 h=2