1/16 problem solving by searching problem formulation

16
1/16 Problem solving by Searching Problem Formulation

Upload: heather-griffith

Post on 18-Jan-2018

237 views

Category:

Documents


0 download

DESCRIPTION

3/16 8-Puzzle Problem formulation State Representation: matrix of tiles Initial state Goal State Operators: slide-blank-up, slide-blank-down, slide-blank-left, slide-blank-right Path Cost: The number of steps to reach the goal state

TRANSCRIPT

Page 1: 1/16 Problem solving by Searching Problem Formulation

1/16

Problem solving by Searching

Problem Formulation

Page 2: 1/16 Problem solving by Searching Problem Formulation

2/16

8-Puzzle problem• Solve the following 8-Puzzle problem by moving tiles left,

down, up and right.

567

84

321

87

654

321

Initial State goal State

Page 3: 1/16 Problem solving by Searching Problem Formulation

3/16

8-Puzzle Problem formulation

• State Representation: matrix of tiles

• Initial state

• Goal State

• Operators: slide-blank-up, slide-blank-down, slide-blank-left, slide-blank-right

• Path Cost: The number of steps to reach the goal state

567

482

31

567

84

321

87

654

321

Page 4: 1/16 Problem solving by Searching Problem Formulation

4/16

Problem Formulation

A Problem Space consists of

• The current state of the world (initial state)

• A description of the actions we can take to transform one state of the world into another (operators).

• A description of the desired state of the world (goal state), this could be implicit or explicit.

• A solution consists of the goal state, or a path to the goal state.

Page 5: 1/16 Problem solving by Searching Problem Formulation

5/16

Problem Formulation :8-Puzzle Problem

Initial State Operators Goal State

2 1 34 7 65 8

Slide blank square left.Slide blank square right.….

1 2 34 5 67 8

Page 6: 1/16 Problem solving by Searching Problem Formulation

6/16

Problem Formulation : 8-Puzzle Problem

Representing states:

• For the 8-puzzle

• 3 by 3 array– 5, 6, 7– 8, 4, BLANK– 3, 1, 2

• A vector of length nine– 5,6,7,8,4, BLANK,3,1,2

• A list of facts– Upper_left = 5– Upper_middle = 6 – Upper_right = 7

–Middle_left = 8

5 6 78 43 1 2

Page 7: 1/16 Problem solving by Searching Problem Formulation

7/16

Problem Formulation: 8-Puzzle Problem

87

654

321

567

84

321Initial state

Goal state

Operators: slide blank up, slide blank down, slide blank left, slide blank right

Solution: ?

Path cost: ?

Page 8: 1/16 Problem solving by Searching Problem Formulation

8/16

Problem Formulation: 8-Puzzle Problem

87

654

321

567

84

321

67

584

321

67

584

321

687

54

321

87

654

321

687

54

321

567

84

321

Initial state Goal state

Operators: slide blank up, slide blank down, slide blank left, slide blank right

Solution1: sb-down, sb-left, sb-up,sb-right, sb-down

Path cost: 5 steps to reach the goal

567

84

321

67

584

321

67

584

321

687

54

321

687

54

321

87

654

321

Page 9: 1/16 Problem solving by Searching Problem Formulation

9/16

567

84

321

567

84

321

57

864

321

57

864

321

857

64

321

857

64

321

87

654

321

87

654

321

567

84

321

567

84

321

567

84

321

57

864

321

57

864

321

857

64

321

857

64

321

87

654

321

87

654

321

Solution2: sb-left, sb-down, sb-right, sb-up, sb-left, sb-down, sb-right

Path cost: 6 steps to reach the goal 87

654

321

Problem Formulation: 8-Puzzle Problem

Page 10: 1/16 Problem solving by Searching Problem Formulation

10/16

Problem Formulation: River problem

• consider the River Problem:

A farmer wishes to carry a wolf, a duck and corn across a river, from the south to the north shore. The farmer is the proud owner of a small rowing boat called Bounty which he feels is easily up to the job. Unfortunately the boat is only large enough to carry at most the farmer and one other item. Worse again, if left unattended the wolf will eat the duck and the duck will eat the corn.

• Give a Formulation for this problem.

Farmer, Wolf, Duck and Corn

Page 11: 1/16 Problem solving by Searching Problem Formulation

11/16

• Problem formulation:

– State representation: location of farmer and items in both sides of river [items in South shore / items in North shore] : (FWDC/-, FD/WC, C/FWD …)

– Initial State: farmer, wolf, duck and corn in the south shore FWDC/-

– Goal State: farmer, duck and corn in the north shore -/FWDC

– Operators: the farmer takes in the boat at most one item from one side to the other side

(F-Takes-W, F-Takes-D, F-Takes-C, F-Takes-Self [himself only])

– Path cost: the number of crossings

Problem Formulation: River problem

Page 12: 1/16 Problem solving by Searching Problem Formulation

12/16

path Cost = 7 (Problem solution)

F W D C

F W D C

F-Takes-D

Initial State

F

W

D

C

F-Takes-D

WC/FD

Goal State

F-Takes-SF

W

D

C

FD/WC

F-Takes-C

F W

D

C

D/FWCF

W

D C

F-Takes-D

FDC/W

F W D

C

F-Takes-W

C/FWD

F-Takes-S

F W

D

CFWC/D

Problem Formulation: River problem

Solution: F-Takes-D, F-Takes-Self, F-Takes-W, F-Takes-D, F-Takes-C, F-Takes-Self, F-Takes-D.

Page 13: 1/16 Problem solving by Searching Problem Formulation

13/16

F W D C

W D CF

D CF W

W CF D

W DF C

F W CD

F W D C

WF D C

F W CD

W CF D

CF W D

F CW D

F D CW

DF W C

F W DC

F WD C

F W CD

W DF C

WF D C

CF W D

D CF W

DF W C

F D CW

F W DC

F DW C

F W D CD

F W C

Problem Formulation: River problemby search Method

F W D C

W D CF

D CF W

W CF D

W DF C

F W CD

F W D C

WF D C

F W CD

W CF D

CF W D

F CW D

F D CW

DF W C

F W DC

F WD C

F W CD

W DF C

WF D C

CF W D

D CF W

DF W C

F D CW

F W DC

F DW C

F W D CD

F W C

• F-Takes-D, F-Takes-Self, F-Takes-W,

• F-Takes-D, F-Takes-C, F-Takes-Self,

• F-Takes-D.

Page 14: 1/16 Problem solving by Searching Problem Formulation

14/16

• Three missionaries and three cannibals are on the left bank of a river.

• There is one canoe which can hold one or two people.

• Find a way to get everyone to the right bank, without ever leaving a group of missionaries in one place outnumbered by cannibals in that place.

Problem Formulation: Missionaries and cannibals

Initial state: (3, 3, 1) Goal State: (0,0,0)

Page 15: 1/16 Problem solving by Searching Problem Formulation

15/16

• States Representation: three numbers (i, j, k) representing the number of missionaries, cannibals, and canoes on the left bank of the river.

• Initial state: (3, 3, 1)

• Operators: take one missionary, one cannibal, two missionaries, two cannibals, one missionary and one cannibal across the river in a given direction (I.e. ten operators).

• Goal Test: reached state (0, 0, 0) or Goal State: (0,0,0)

• Path Cost: Number of crossings.

Problem Formulation: Missionaries and cannibals

Page 16: 1/16 Problem solving by Searching Problem Formulation

16/16

Solution : [ (3,3,1)→ (2,2,0)→(3,2,1) →(3,0,0) →(3,1,1) →(1,1,0) →(2,2,1) →(0,2,0) →(0,3,1) →(0,1,0) → (0,2,1) →(0,0,0)];

Cost = 11 crossings

Problem Formulation: Missionaries and cannibals

Initial state: (3, 3, 1) Goal State: (0,0,0)

Operations (i, j, k)