0% found this document useful (0 votes)
125 views

Chapter 3-Problem Solving by Searching Part 1

Here are the steps to solve this problem: 1. States: All possible combinations of water quantities in the two jars, ranging from 0 to the maximum capacity of each jar. For a 6-gallon and 8-gallon jar, the states are (x,y) where 0≤x≤6 and 0≤y≤8. 2. Initial state: (0,0) - Both jars are empty. 3. Actions: Fill one of the jars, empty one of the jars, pour water from one jar to the other until one is full. 4. Transition model: Defines how the state changes with each action. For example, filling the 6-gall

Uploaded by

Dewanand Giri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Chapter 3-Problem Solving by Searching Part 1

Here are the steps to solve this problem: 1. States: All possible combinations of water quantities in the two jars, ranging from 0 to the maximum capacity of each jar. For a 6-gallon and 8-gallon jar, the states are (x,y) where 0≤x≤6 and 0≤y≤8. 2. Initial state: (0,0) - Both jars are empty. 3. Actions: Fill one of the jars, empty one of the jars, pour water from one jar to the other until one is full. 4. Transition model: Defines how the state changes with each action. For example, filling the 6-gall

Uploaded by

Dewanand Giri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Chapter 3

Problem Solving by Searching


Planning
Planning is the process of deciding in detail how to do

something before you actually start to do it.

It is the task of coming up with a sequence of actions that


will achieve a goal.

➢Planner is viewed as the producer or generator of the


➢ solution.

Eg: STRIPS (STandford Research Institute Problem Solver)


➢ Classical Planning
Planning for which environments that are fully observable,
deterministic, finite, static (change happens only when the agent
acts), and discrete (in time, action, objects, and effects)
➢ Non Classical Planning
Planning for which environments for partially observable and involves
a different set of algorithms and agent designs
Problems

➢A problem is a situation (difficult/easy) experienced by an


agent.
➢Problem is solved by a sequence of actions that reduce the
difference between the initial situation and the goal.
Problem Solving

➢ Problem solving, particularly in artificial intelligence, may be


characterized as a systematic search through a range of possible
actions in order to reach some predefined goal or solution.
➢ Problem-solving methods divide into special purpose and general
purpose.
➢ A special-purpose method is tailor-made for a particular problem and
often exploits very specific features of the situation in which the
problem is embedded.
➢ In contrast, a general-purpose method is applicable to a wide variety
of problems.
Planning Problem Solving

The task of coming up with a Problem Solving is the systematic


sequence of actions that will search through a range of possible
achieve a goal is called actions in order to reach some
planning predefined goal or solution
Planning is a generic term of Problem solving comprises standard
problem solving search process
Problem Solving by Agent

➢ Type of goal-based agent known as a problem-solving agent, which


uses atomic representation with no internal states visible to the problem-
solving algorithms.

➢According to computer science, a problem-solving is a part of artificial


intelligence which encompasses a number of techniques such as
algorithms, heuristics to solve a problem.
Steps in Problem Solving

➢ Several steps of Problem solving are:


➢Goal Formulation
➢Problem Formulation

➢Goal Formulation:
➢It is the first and simplest step in problem-solving.
➢It organizes the steps/sequence required to formulate one goal out of
multiple goals as well as actions to achieve that goal.
➢ Goal formulation is based on the current situation and the agent’s
performance measure
Steps in Problem Solving
➢ Problem Formulation:
➢ It is the most important step of problem-solving which decides what
actions should be taken to achieve the formulated goal.
➢ There are following five components involved in problem formulation:
➢Initial State
➢Actions
➢Transition Model
➢Goal Test
➢Path Cost
Problem Formulation Components
➢ Initial State: It is the starting state or initial step of the agent towards
its goal.
➢Actions: It is the description of the possible actions available to the
agent.
➢Transition Model: It describes what each action does.
➢Goal Test: It determines if the given state is a goal state.
➢Path cost: It assigns a numeric cost to each path that follows the goal.
The problem-solving agent selects a cost function, which reflects its
performance measure.

Note: an optimal solution has the lowest path cost among all the
solutions.
State Space of Problem
➢ Initial state, actions, and transition model together define the state-
space of the problem implicitly.

➢ State-space of a problem is a set of all states which can be reached from


the initial state followed by any sequence of actions.

➢The state-space forms a directed map or graph where nodes are the
states, links between the nodes are actions, and the path is a sequence of
states connected by the sequence of actions.

➢Solution of problem is the path from initial state to goal state in a state
space of problem.
Well Defined Problems

A problem when defined with its components is called well defined


problem. The actions and rules should be defined in as general way as
possible.
A well defined problem can be defined formally by four components:
❑ Initial State:
state from where an agent starts
❑ Successor Function:
description of possible actions available to an agent, given a particular
state x, a successor function returns a set of <action, successor> order
pairs, where each action is one of the legal action in state x and each
successor is a state that can be reached from x by applying the action.
❑ Goal Test:
determines whether a given state is a goal state
❑ Path Cost:
assigns numeric cost to each path
Problem Types

Different types of problems


• Toy Problems
• Real-world Problems
Toy Problems
It is a concise and exact description of the problem which
is used by the researchers to compare the performance of
algorithms.
Some Toy Problems are:
8-Puzzle
8-Queen Problem
Vacuum World Problem
Water Jug Problems
8-Puzzle Problem
Definition: Here, we have a 3×3 matrix with movable tiles numbered
from 1 to 8 with a blank space. The tile adjacent to the blank space
can slide into that space. The objective is to reach a specified goal state
as shown in the below figure.
Problem Formulation of 8-Puzzle
The problem formulation is as follows:
States of 8-Puzzle: It describes the location of each numbered tiles and
the blank tile.
Initial State: We can start from any state as the initial state.
Actions: Here, actions of the blank space is defined, i.e., either
left, right, up or down
Transition Model: It returns the resulting state as per the given state
and actions.
Goal test: It identifies whether we have reached the correct goal-state.
Path cost: The path cost is the number of steps in the path where the
cost of each step is 1.
Problem Formulation of 8-Puzzle
The 8-puzzle problem is a type of sliding-block problem which is used
for testing new search algorithms in artificial intelligence.
Initial State

State Space of 8-Puzzle Problem


8-Queen Problems
Problem Statement: The aim of this problem is to place eight queens
on a chessboard in an order where no queen may attack another. A
queen can attack other queens either diagonally or in same row and
column.

Conflict State Goal State


8-Queen Problems

For this problem, there are two main kinds of


formulation:
Incremental formulation
Complete-state formulation
Incremental formulation:
It starts from an empty state where the operator augments
a queen at each step.
Incremental formulation
Following steps are involved in this formulation:
States: Arrangement of any 0 to 8 queens on the chessboard.
Initial State: An empty chessboard
Actions: Add a queen to any empty box.
Transition model: Returns the chessboard with the queen added in a box.
Goal test: Checks whether 8-queens are placed on the chessboard without any
attack.
Path cost: There is no need for path cost because only final states are
counted.
In this formulation, there is approximately 1.8 x 1014 possible sequence to
investigate.
Complete-State formulation
It starts with all the 8-queens on the chessboard and moves them
around, saving from the attacks.
Following steps are involved in this formulation
States: Arrangement of all the 8 queens one per column with no queen
attacking the other queen.
Actions: Move the queen at the location where it is safe from the
attacks.
This formulation is better than the incremental formulation as it
reduces the state space from 1.8 x 1014 to 2057, and it is easy to find
the solutions.
Vacuum World Problem

The world has only two locations


Each location may or may not contain dirt
The agent may be in one location or the other
8 possible world states
Three possible actions: Left, Right, Suck
Goal: clean up all the dirt
State Space of Vacuum World Problem
Water Jug Problem

You are given two jugs, a 4-gallon one and a 3-gallon one.
Neither has any measuring mark on it. There is a pump
that can be used to fill the jugs with water. How can you
get exactly 2 gallons of water into the 4-gallon jug
The state space for this problem can be described as the set of ordered
pairs of integers (X, Y)
Where,
X represents the quantity of water in the 4-gallon jug X= 0,1,2,3,4
Y represents the quantity of water in 3-gallon jug Y=0,1,2,3
Start State: (0,0)
Goal State: (2,0)
Production Rule:
- Fill 4/3 gallon jug
- Empty 4/3 gallon jug
- Pour from either of the jug to another
0,0

4,0 0,3

3,0 4,3 0,0

3,3 0,3 0,0

4,2 0,3 3,0 4,3

0,2 4,0 3,3

2,0 4,2 0,0

State Space for Water Jug Problem


Q. You are given two jars of a six gallons and eight gallons capacity. There is no
marking on the jars. There is a water tap, which can be used to fill jar. Your goal
is to have exactly four gallons of water in eight gallons jar without taking any
other jar or measuring device.
Q. River Crossing Problem
In a distinct land, bigamy is common. There are six people who
want to cross a river in this land. This group consists of two men,
each two wives. No man can tolerate any of his wives being in the
company of another man unless yet least he or his next wife is
present in the boat or in next land. There is a boat that holds two
people to be used for crossing the river. How is the trip possible?
Q. Tic-Tac-Toe problem
Two players, X and O, who take turns marking the
spaces in a 3×3 grid. The player who succeeds in
placing three respective marks in a horizontal, vertical,
or diagonal row wins the game
Q. Pegs and Disks problem
Q. 8 queen’s problem
The problem is to place 8 queens on a chessboard so that no two
queens are in the same row, column or diagonal.
Constraint Satisfaction Problems

A constraint satisfaction problem (CSP) consists of


➢ a set of variables,
➢ a domain for each variable, and
➢ a set of constraints.

The aim is to choose a value for each variable so that the resulting possible world satisfies
the constraints; we want a model of the constraints.
Constraint Satisfaction Problems

✓ The process of finding a solution to set of variables Vi (V1, V2, …, Vn )


and a set of constraint Ci (C1, C2, …, Cm)
✓ There is no any specified rule to define the procedure to solve the CSP.
Eg : 8-queens problem
✓ The CSP is a two-step process
1. Constraints are discovered and propagated as far as possible
2. There is still not found solution, then search begins
Constraint Satisfaction Problems
Problem: map of Australia showing each of its states and territories, and that
we are given the task of coloring each region either red, green, or blue in
such a way that no neighboring regions have the same color.
Constraint Satisfaction Problems
CSP Formulation:
➢ define the variables to be the regions: X={WA,
NT, Q, NSW, V , SA,T}
➢ domain of each variable is D={red, green, blue}
➢ The constraints require neighboring regions to
have distinct colors, for example, the allowable
combinations for WA and NT are the pairs
{(red, green), (red, blue), (green, red), (green,
blue), (blue, red), (blue, green)}
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Constraint Satisfaction Problems

There are many possible solutions, such as:


{WA=red, NT=green, Q=red, NSW=green, V =red, SA=blue, T =green}
Crypto Arithmetic Problems
➢ Crypt-Arithmetic Problems are substitution problems where digits
representing a mathematical operation are replaced by unique digits.
➢ Eg:

A B C
+ D E F
G H I
Solution:

1. A ≠ B ≠ C ≠ D ≠ E ≠ F ≠ G ≠ H ≠ I
2. C + F = I
C + F = 10 + I (I as carry)
3. B + E = H
B + E = 10 + H
B+E+1=H
B + E + 1 =10 + H (H as carry)
4. A + D = G
A+D+1=G
Step 1:
Domain of C = {1, 2, 3, 4, 5, 6, 7, 8, 9}
Domain of F = {1, 2, 3, 4, 5, 6, 7, 8, 9}
So,
Domain of I = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

Select C = 4 & F = 9 Then I = 3 (Carry = 1)


So,

A B 4
+ D E 9
G H 3
Step 2:
Domain of B = {1, 2, 5, 6, 7, 8}
Domain of E = {1, 2, 5, 6, 7, 8}
So,
Domain of H = {0, 1, 2, 5, 6, 7, 8}
Select B = 2 & E = 8
Then H = 10+1 {previous carry = 1 + (Carry = 1)}
So,
A 2 4
+ D 8 9
G 1 3
Step 3:
Domain of A = {0, 5, 6, 7}
Domain of D = {0, 5, 6, 7}
So, Domain of G = {5, 6}
Select A = 0 & D = 5 Then G = 6 (with addition of Carry)
So,
Hence, the required solutions are:
A = 0, B = 2, C = 4, D = 5, E = 8, F = 9, G = 6, H = 1, I = 3.
0 2 4
+ 5 8 9
6 1 3
Class Work
Class Work
W R O N G
+ W R O N G
R I G H T
Class Work
B A S E
+ B A L L
G A M E S
Game Playing
A game can be formally defined as a kind of search problem as
below:
➢ Initial state:

It includes the board position and identifies the player’s


to move.
➢ Successor function:

It gives a list of (move, state) pairs each indicating a legal


move and resulting state.
➢ Terminal test:

This determines when the game is over. States where the


game is ended are called terminal states.
➢ Utility function:

It gives numerical value of terminal states. E.g. win (+1),


loose (-1) and draw (0).
Game Trees
➢ We can represent all possible games(of a given type) by a directed graph often
called a game tree.

➢ The nodes of the graph represent the states of the game.

➢ The arcs of the graph represent possible moves by the players (+ and -)
Example: Tic-tac-toe

➢ There are two players denoted by X and O. They are alternatively writing
their letter in one of the 9 cells of a 3 by 3 board. The winner is the one who
succeeds in writing three letters in line.
➢ The game begins with an empty board. It ends in a win for one player and a
loss for the other, or possibly in a draw.
➢ A complete tree is a representation of all the possible plays of the game. The
root node is the initial state, in which it is the first player's turn to move (the
player X).
➢ The successors of the initial state are the states the player can reach in one
move, their successors are the states resulting from the other player's possible
replies, and so on.
Q. Explain the production system for Water Jug
Problem.
Statement :- We are given 2 jugs, a 4 liter one and a 3- liter one.
Neither has any measuring markers on it. There is a pump that
can be used to fill the jugs with water. How can we get exactly 2
liters of water in to the 4-liter jugs?
Solution:-
The state space for this problem can be defined as

{ ( i ,j ) i = 0,1,2,3,4 and j = 0,1,2,3}

‘i’ represents the number of liters of water in the 4-liter jug.


‘j’ represents the number of liters of water in the 3-liter jug.
The initial state is ( 0,0) that is no water on each jug.
The goal state is to get ( 2,n) for any value of ‘n’.
To solve this we have to make some assumptions not mentioned in the
problem.

1. We can fill a jug from the pump.


2. we can pour water out of a jug to the ground.
3. We can pour water from one jug to another.
4. There is no measuring device available.
The various operators (Production Rules) that are available to solve this
problem may be stated as
Q. Explain the production system for Missionaries
and Cannibals problem.
Three missionaries and three cannibals find themselves on one side of a
river. They have would like to get to the other side. But the missionaries
are not sure what else the cannibals agreed to. So the missionaries
managed the trip across the river in such a way that the number of
missionaries on either side of the river is never less than the number of
cannibals who are on the same side. The only boar available holds only
two at a time. How can everyone get across the river without the
missionaries risking being eaten?
Solution

The state for this problem can be defined as


{(i, j)/ i=0, 1, 2, 3, : j=0, 1, 2, 3}

where,
i represents the number missionaries in one side of a river .
j represents the number of cannibals in the same side of river.
The initial state is (3,3), that is three missionaries and three cannibals
one side of a river (Bank 1) and ( 0,0) on another side of the river
(bank 2) .
The goal state is to get (3,3) at bank 2 and (0,0) at bank 1.
To solve this problem we will make the following assumptions:

1. Number of cannibals should lesser than the missionaries on either side.


2. Only one boat is available to travel.
3. Only one or maximum of two people can go in the boat at a time.
4. All the six have to cross the river from bank.
5. There is no restriction on the number of trips that can be made to reach of
the goal.
6. Both the missionaries and cannibals can row the boat.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy