Upcoming SlideShare
Loading in …5
×

# State Space Search(2)

3,993 views
3,744 views

Published on

Descripcion de espacios de estados

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

No Downloads
Views
Total views
3,993
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
78
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

### State Space Search(2)

1. 1. State Space Search • Readings: Rich and Knight: Sect 2.1
2. 10. Train Problem • State Representation: A Lisp atom: the current city • Initial State (define *start-state* 'sacramento) • Goal State (define *goal-state* 'austin.texas) (define (solution-state? s) (eqv? s *goal-state*)) • Operators (50) – Go from neighboring capitals to each capital (define *state-operators* (list goto-atlanta goto-montgomery goto-juneau goto-phoenix goto-sacramento goto-santa-fe goto-austin)) (define (goto-montgomery state) (if (member state '(juneau atlanta)) 'montgomery #f))
3. 11. Farmer Wolf Goat and Cabbage problem A problem description consists of ;;;1. A structure to represent the state description: jug-contents A fixed sized data structure comprised of a number of fields • (defstruct name field-1 field-2 ... fieldn) defines a structure (defstruct side farmer wolf goat cabbage) => side ;;;2. A list of operators: *jug-problem-operators* ;;; These functions define legal moves in the state space (define *farmer-wolf-goat-cabbage-operators* '(farmer-takes-self farmer-takes-wolf farmer-takes-goat farmer-takes-cabbage)) ;;;3. A definition of each operator: ;;; An operator is a scheme function, that given a state description, returns a new ;;; state description (Or null if the operator can't be applied) (define (farmer-takes-self state) (safe (make-side 'farmer (opposite (side.farmer state)) 'wolf (side.wolf state) 'goat (side.goat state) 'cabbage (side.cabbage state))))
4. 12. A particular problem requires ;;;.1. A start state (define *start-state* (make-side 'farmer 'east 'wolf 'east 'goat 'east 'cabbage 'east)) ;;;2. A function to determine whether a state is the goal state. ;;; By covention, we'll call this (solution-state? x) (define (solution-state? state) ;;&quot;A state description is the solution if the everything is on the west&quot; (and (eqv? 'west (side.farmer state)) (eqv? 'west (side.wolf state)) (eqv? 'west (side.goat state)) (eqv? 'west (side.cabbage state))))
5. 13. Water Jug Problem State Representation • State Representation (defstruct jug-contents four three) • Initial State (define *start-state* (make-jug-contents 'three 0 'four 0)) • Goal State ;;A state description is the solution if the four galloon jug has 2 gallons in it&quot; (define (solution-state? state) (= 2 (jug-contents.four state))) • A list of operators (define *jug-problem-operators* '(fill-four fill-three dump-four dump-three fill-four-from-three fill-three-from-four empty-three-into-four empty-four-into-three))
6. 14. • Operator 1 (define (fill-four state) (when (< (jug-contents.four state) 4) (make-jug-contents 'three (jug-contents.three state) 'four 4)))
7. 15. Applying the operators <ul><li>? *start-state* </li></ul><ul><li>#S(JUG-CONTENTS :FOUR 0 :THREE 0) </li></ul><ul><li>? (fill-four *start-state*) </li></ul><ul><li>#S(JUG-CONTENTS :FOUR 4 :THREE 0) </li></ul><ul><li>? (fill-three-from-four (fill-four *start-state*)) </li></ul><ul><li>#S(JUG-CONTENTS :FOUR 1 :THREE 3) </li></ul><ul><li>? (fill-three-from-four </li></ul><ul><li>(fill-four </li></ul><ul><li>(empty-four-into-three </li></ul><ul><li>(dump-three </li></ul><ul><li>(fill-three-from-four </li></ul><ul><li>(fill-four *start-state*)))))) </li></ul><ul><li>#S(JUG-CONTENTS :FOUR 2 :THREE 3) </li></ul><ul><li>? (solution-state? (fill-three-from-four </li></ul><ul><li>(fill-four </li></ul><ul><li>(empty-four-into-three </li></ul><ul><li>(dump-three </li></ul><ul><li>(fill-three-from-four </li></ul><ul><li>(fill-four *start-state*) </li></ul><ul><li>)))))) </li></ul>