Vous êtes sur la page 1sur 26

Artificial Intelligence (AI)

Problem Solving: State-Space Search and Control Strategies

Objectives
Identify problem-solving methods for AI problems. Solve given problems by using the appropriate general purpose and search methods.

Types of Problem Solving Methods


General purpose Special purpose

General Problem Solving


Production system
Start (initial) state(s) Goal (final) state(s) Databases with knowledge representation schemes Production rules Control strategies

State-Space Problems: Water Jug


Problem:
Two jugs, of 5 gallons and 3 gallons, with no measuring marker Unlimited water supply through a tap Need 4 gallons of water in the 5-gallon (5-g) jug

Solution:
Describe state space as a set of ordered pairs of integers (X,Y), where X is the gallons of water in the 5-g jug and Y is the gallons in the 3-gallon (3-g) jug. Start state: (0,0) Goal state: (4,N) for any value of N 3

State-Space Problems: Water Jug


Discuss:
Possible operations that can be used in the water jug problem Production rules corresponding to these operations Possible solution paths for the problem

State-Space Problems: Missionaries and Cannibals


Problem:
Three cannibals and three missionaries want to cross a river. A boat for one or two persons exists on one side of the river. If the cannibals outnumber the missionaries on the same side, the missionaries will be eaten. How should they use the boat to cross the river without anyone being eaten? The cannibals should not outnumber the missionaries.
7

State-Space Problems: Missionaries and Cannibals


Solution:
State space can be described as a set of ordered pairs of the left and right banks (L,R) of the river. Each bank can be represented as a list [nM, mC, B], where n is the number of missionaries M, m is the number of cannibals C and B represents the boat. Start state: ([3M, 3C, 1B],[0M,0C, 0B]), 1B means that the boat is present and 0B means it is absent Any state: ([n1M, m1C, -],[n2M, m2C,-]), with constraints/conditions at any state as n1 (0) m1;n2 (0) m2;n1+n2 = 3, m1+m2 = 3; boat can be either side Goal state: ([0M, 0C, 0B],[3M, 3C, 1B])
8

State-Space Problems: Missionaries and Cannibals


Discuss:
Possible production rules that can be used for the problem. Possible solution paths.

State-Space Search
Components of state space
A set S containing the start states of the problem A set G containing goal states of the problem Set of nodes in a graph/tree representing the states in a problem-solving process Set of arcs connecting the nodes

Solution path: Path through the graph from a node in S to a node in G. Approach: Apply the appropriate operator to transfer one state of a problem to another state.
10

State-Space Search
Determine the possible search space algorithm and tree of nodes in a graph for the missionaries and cannibals problem:
Assume that:
State (L : R), where L = n1M m1C1B and R = n2Mm2C0B B represents the boat with 1 or 0 indicating its presence or absence, respectively. Start state: (3M3C1B : 0M0C0B), or (331:000) Goal state: (0M0C0B : 3M3C1B), or (000:331)

11

Exercise: Eight-Puzzle Problem


Problem:
A 3x3 grid has 8 randomly numbered (1 to 8) tiles with one empty cell. At any point, an adjacent tiles can move to this cell and create a new empty cell. Arrange the tiles to arrive at the goal state from the start state, as per the following figure, by using the state-space search method.
3 5 7 1
Start State

6 2

7 4 1
Goal State

2 8

12

Control Strategies
Systematic control strategies:
Depth-first Breadth-first

Types of search strategies:


Forward chaining Data-driven search from the start date Backward chaining Goal-driven search from the goal state
13

Characteristics of Problems
Characteristics of problems to be considered to determine the search strategy and solution path for a given problem:
Type of problem Ignorable, recoverable or irrecoverable. Decomposability of problem. Role of knowledge. Consistency of the knowledge base to be used to solve the problem. Requirement for absolute or relative solution.
14

Exhaustive Searches
Breadth-first search Depth-first search Depth-first iterative deepening Bidirectional search

15

Choosing Effective Search Methods


Measure the effectiveness of a search strategy in terms of:
Completeness of search algorithm for a solution. Time required to find a solution by using the algorithm. Space required by the algorithm to find a solution. Optimality of the algorithm.
16

Choosing Effective Search Methods (Contd)

Analyze the effectiveness of the exhaustive search methods discussed earlier.

17

Exercise: Choosing Effective Search Methods


Solve the traveling salesman problem by using the appropriate search method:
Find the shortest route that a salesman should take to visit all cities once and return to the starting point. Take hypothetical values for the number of cities and the distance between the cities.
Prepare a graph to depict the problem and determine possible solution paths.

18

Heuristic Search Techniques


General-purpose heuristics. Branch and bound search (uniform cost search). Hill climbing. Beam search. Best-first search. A* algorithm.
19

Iterative-Deepening A* (IDA*)
5 1st iteration (Threshold = 5) 6 x 8 xx 5 2nd iteration (Threshold = 6) 6 4 4 8 xx 9 xx

7 x 3rd iteration (Threshold = 7)

9 xx 5 6
5

8 xx

7 x

4
4

Goal
4 8

xx

xx

20

xx

Sample Working of IDA*

Constraint Satisfaction
Constraint satisfaction (CS) problems are aimed at satisfying a given set of constraints. Such problems have:
A set of variables {x1, x2, , xn} with each xi Di with possible values. A set of constraints between the values of the variables.

You need to find, for each i, 1 i n, a value of xi Di where all constraints are satisfied. Represent the problem as a unidirectional graph the Constraint graph in which the nodes are the variables and the edges are binary constraints.

21

Constraint Satisfaction Problems : Examples


Examples of constraint satisfaction problems:
Cryptography: A number puzzle where a group of arithmetic operations has some or all digits replaced by letters and the original digits must be found for example:

B + G B A

A A M

S L E

E L S

N-Queen: Given the condition that no two queens on the same row/column/diagonal attack each other.

Map colouring: Given a map, colour three regions in blue, red and black, such that no two neighbouring regions have the same colour.

22

Solved Example: Crypt-Arithmetic Puzzle


Solve the solution for the following crypt-arithmetic puzzle with your faculty:
B + G B A A A M S L E E L S

Assign a unique number from 0-9 to each letter that satisfies the above addition.
23

Solved Example: Crypt-Arithmetic Puzzle (Contd)


Constraints: No two letters should have the same values. Initial problem state: G = ?; A = >?; M = ?; E = ?; S = ?; B = ?; L = ? Apply constraint inference rules to generate new constraints. Apply the letter assignment rules to perform all assignments required by the current set of constraints. Then, choose another rule to generate another assignment, which will in turn generate new constraints at the next cycle. At each cycle, several choices for rules may apply. A useful heuristics can help to select the best rule to apply first.

24

Summary
Discuss your key learning from this session.

25

Exercises
Attempt the given exercises for Chapter 2 of the Artificial Intelligence book, based on your learning in this session.

26

Vous aimerez peut-être aussi