+ All Categories
Home > Technology > State Space Search(2)

State Space Search(2)

Date post: 05-Dec-2014
Category:
Upload: luzenithg
View: 4,125 times
Download: 2 times
Share this document with a friend
Description:
Descripcion de espacios de estados
15
State Space Search Readings: Rich and Knight: Sect 2.1
Transcript
Page 1: State Space Search(2)

State Space Search

• Readings: Rich and

Knight: Sect 2.1

Page 2: State Space Search(2)
Page 3: State Space Search(2)
Page 4: State Space Search(2)
Page 5: State Space Search(2)
Page 6: State Space Search(2)
Page 7: State Space Search(2)
Page 8: State Space Search(2)
Page 9: State Space Search(2)
Page 10: State Space Search(2)

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

Page 11: State Space Search(2)

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

Page 12: State Space Search(2)

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) ;;"A state description is the solution if the everything is on the west" (and (eqv? 'west (side.farmer state)) (eqv? 'west (side.wolf state)) (eqv? 'west (side.goat state)) (eqv? 'west (side.cabbage state))))

Page 13: State Space Search(2)

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"(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))

Page 14: State Space Search(2)

• Operator 1

(define (fill-four state) (when (< (jug-contents.four state) 4) (make-jug-contents 'three (jug-contents.three state) 'four 4)))

Page 15: State Space Search(2)

Applying the operators• ? *start-state*• #S(JUG-CONTENTS :FOUR 0 :THREE 0)• ? (fill-four *start-state*)• #S(JUG-CONTENTS :FOUR 4 :THREE 0)• ? (fill-three-from-four (fill-four *start-state*))• #S(JUG-CONTENTS :FOUR 1 :THREE 3)• ? (fill-three-from-four• (fill-four• (empty-four-into-three• (dump-three• (fill-three-from-four• (fill-four *start-state*))))))• #S(JUG-CONTENTS :FOUR 2 :THREE 3)• ? (solution-state? (fill-three-from-four• (fill-four• (empty-four-into-three• (dump-three• (fill-three-from-four• (fill-four *start-state*)• ))))))


Recommended