Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 61

Chapter 2

Problem Solving
Lesson Objective
• Knowing what is problem and its type
• Learning how to formulate the problems
• Learning the process of solving them
Overview
2.1 Defining problems as a state space search
2.2 Problem Formulation
2.3 Problem Types, Well-defined problems, Constraint Satisfaction
Problem
2.4 Game Playing, Production Systems
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 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 are 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 Definitions:
A problem is defined by its elements and their relations. To provide a
formal description of a problem, we need to do following:
a. Define a state space that contains all the possible configurations of
the relevant objects, including some impossible ones.
b. Specify one or more states, that describe possible situations, from
which the problem solving process may start. These states are
called initial states.
c. Specify one or more states that would be acceptable solution to the
problem. These states are called goal states.
d. Specify a set of rules that describe the actions (operators) available.
Problem Definitions:
Problem space is an abstract space.
• A problem space encompasses all valid states that can be generated
by the application of any combination of operators on any
combination of objects.
• The problem space may contain one or more solutions.
• Solution is a combination of operations and objects that achieve the
goals.
Search refers to the search for a solution in a problem space.
• Search proceeds with different types of search control strategies.
Problem Solving
To build a system to solve a particular problem, we need to:
• Define the problem precisely- find input situations as well as final
situations for acceptable solution to the problem.
• Analyze the problem- find few important features that may have
impact on the appropriateness of various possible techniques for
solving the problem.
• Isolate and represent task knowledge necessary to solve the problem.
• Choose the best problem solving techniques and apply to the
particular problem.
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.
Problem solving is a process of generating solutions from observed data.
A problem is characterized by a set of goals, a set of objects, a set of
operations
Problem Solving
The problem can be solved by using the rules, in combination with an
appropriate control strategy, to move through the problem space until
a path from an initial state to a goal state is found. This process is
known as search.
Search is fundamental to the problem-solving process.
Search is a general mechanism that can be used when more direct
method is not known.
Search provides the framework into which more direct methods for
solving subparts of a problem can be embedded.
A very large number of AI problems are formulated as a search
problem.
Problem Solving
Problem Formulation
Problem Space
A problem space is represented by directed graph, where nodes
represent search state and paths represent the operators applied to
change the state.
To simplify a search algorithms, it is often convenient to logically and
programmatically represent a problem space as a tree.
A tree usually decreases the complexity of a search at a cost.
A tree is a graph in which any two vertices are connected by exactly
one path. Alternatively, any connected graph with no cycles is a tree.
Problem Space
A tree is a graph in which any two vertices are connected by exactly
one path.
Problem Space
State
A state is a representation of elements at a given moment.
A problem is defined by its elements and their relations.
At each instant of a problem, the elements have specific descriptors
and relations; the descriptors tell- how to select elements?
Among all possible states, there are two special states called:
Initial state = is the start point
Final state = is the goal state
State
State Change: Successor Function
A Successor Function is needed for state change.
The successor function moves from one state to another state.
Successor Function:
It is a description of possible actions; a set of operators.
It is a transformation function on a state representation, which
converts that state into another state.
Defines a relation of accessibility among states.
Represents the conditions of applicability of a state and
corresponding transformation function.
State Space
A state space is the set of all states reachable from the initial state.
Definitions of terms:
A state space form a graph in which the nodes are states and the arcs
between nodes are actions.
In state space, a path is a sequence of states connected by a
sequence of actions.
The solution of a problem is part of the map formed by the state
space.
Structure of State Space
The Structures of state space are trees and graphs.
Tree is a hierarchical structure in a graphical form; and Graph is a
non-hierarchical structure
Tree has only one path to a given node; i.e. a tree has one and only
one path from any point to any other point.
Graph consists of a set of nodes (vertices) and a set of edges (arcs).
Arcs establish relationships (connections) between the nodes; i.e. a
graph has several paths to a given node.
Operators are directed arcs between nodes.
Search process explores the state space.
Defining problems as a state space search
A problem consists of the description of:
Current state of the world, actions that can transform one state of
the world into another, desired state of the world.
State space is defines explicitly or implicitly. A state space should
describe everything that is needed to solve a problem and nothing
that is not needed to solve the problem.
Initial State- is start state
Goal State – is the conditions it has to fulfill. It consists of the
description of a desired state of the world; the description may be
complete or partial
Defining problems as a state space search
Operators – are to change the state.
Operators do actions that can transform one state into another.
Operators consist of : Preconditions and Instructions;
Preconditions provide partial description of the state of the world that must be true
in order to perform the action.
Instructions tell on how to create next state.
Operators should be as general as possible, to reduce their number.
Elements of the domain has relevance to the problem i.e. knowledge of the staring
point.
Problem Solving is finding a solution. Finding an ordered sequence of operators that
transform the current (start) state into a goal state.
Q. Explain problem as a state space with an
example.
Example: The 8-puzzle
The puzzle consists of an 8-square frames and an empty slot. The tiles
are numbered from 1-8. It is possible to move the tiles in the square
field by moving tile into the empty slot. The objective is to get square
in a numeric order.
8 puzzle has 9!/2 = 181440 states
Problem Types
• Single state problem = deterministic, accessible
Agent knows everything about the world (the exact state)
Can calculate optimal action sequence to reach the goal
E.g. playing chess, any action will result in an exact state.
• Multiple state problem = deterministic, inaccessible
Agent doesn’t know the exact state (could be in any of the possible
states)
Assume states while working towards the goal state.
E.g. walking in a dark room
Problem Types
• Contingency Problem = non-deterministic, inaccessible
Must use sensors during execution
Solution is a tree or policy
Often interleave search and execution
E.g. a new skater in an arena i.e. sliding problem and many skaters
around
• Exploration Problem = unknown state space
Discover and learn about environment while taking actions.
E.g. Maze
Problem Types
Well Defined Problems
Constraint Satisfaction Problem
Well Defined Problem
A problem is called as well defined if it consists of these 4 important
components:
• Initial state: The state where an agent starts in.
• Successor function: Given a state x, SUCCESSOR-FN(x)returns a set of
< action, successor> ordered pairs. The initial state and successor
function define the state space.
• Goal test : Whether the given state is a goal state?
• Path cost: Assigns numeric cost to each path. Step cost for taking
action from state x to y-denoted by c(x,a,y).
Well Defined Problem
Solutions
• A solution to a problem is a path from initial to a goal state.
• An optimal solution has the lowest path cost among all solutions i.e.
solution cost is measured by the past cost.
Example: Visiting to Romania
On holiday in Romania; currently in Arad. Flight leaves tomorrow for
Bucharest
Formulate goal:
be in Bucharest
Formulate problem:
states: various cities
actions: drive between cities
Find solution:
sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
Single-state problem formulation
 A problem is defined by four items:
• initial state: e.g., "at Arad”
• actions or successor function S(x) = set of (action, successor):
e.g., from the state In(Arad), the successor function would be:
{Go(Sibiu),In(Sibiu)}, {Go(Fagaras),In(Fagaras)},
{Go(Bucharest),In(Bucharest)}
• goal test: e.g., x = "at Bucharest“,
• path cost (additive) - e.g., sum of distances, number of actions executed,
etc.
A solution is a sequence of actions leading from the initial state to a goal
state
Example: Vacuum World
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
Constraint Satisfaction Problem
• Constraint satisfaction problems (CSPs) are mathematical questions
defined as a set of objects whose state must satisfy a number of
constraints or limitations.
• 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.
• E.g. : river crossing problem, 8-queens problem, Crypto Arithmetic
Problems
Example: 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 atleast 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?
Example: 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.
Example: 8 queen’s problem

States: Any arrangement of 0 to 8 queens on the board


Initial state: No queens on the board
Successor function: Add a queen to an empty square
Goal Test: 8 queens on the board and none are attacked
64*63*…*57 = 1.8*1014 possible sequences
Example: Crypto Arithmetic Problems
• Crypt-Arithmetic Problems are substitution problems where digits
representing a mathematical operation are replaced by unique digits.
• E.g:
Example: Crypto Arithmetic Problems
Example: Crypto Arithmetic Problems
Example: Crypto Arithmetic Problems
Example: Crypto Arithmetic Problems
Example: Crypto Arithmetic Problems
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.
Example: Tic-tac-toe
Production Systems
• A Knowledge representation formalism consists of collections of condition-action
rules(Production Rules or Operators), a database which is modified in accordance
with the rules, and a Production System Interpreter which controls the operation of
the rules i.e. The 'control mechanism' of a Production System, determining the order
in which Production Rules are fired.
• A system that uses this form of knowledge representation is called a production
system.
• A production system consists of rules and factors. Knowledge is encoded in a
declarative form which comprises of a set of rules of the form:
Situation ------------ Action
SITUATION that implies ACTION.
Example: Water Jug Problem
You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has
any measuring marker 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? Solve by production rule system.
Solutions:
Given: 4 gallon jug, 3 gallon jug and 2 gallon is to be measured in
4 gallon jug.
Let 4 gallon jug represent x and 3 gallon jug represent y.
So, initial state is (x, y) and final state is (2,*)
Available solution space are:

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

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

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

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


Let the initial state (x, y) = (4,0) so the path can be:
(4,0)->(1,3)->(0,3)->(3,0)->(3,3)->(4,2)->(0,2)->(2,0)
Steps Production Rules Used

(4,0)->(1,3) From production rule 5


(1,3)->(0,3) From production rule 1
(0,3)->(3,0) From production rule 5
(3,0)->(3,3) From production rule 4
(3,3)->(4,2) From production rule 7
(4,2)->(0,2) From production rule 1
(0,2)->(2,0) From production rule 7

You might also like