0% found this document useful (0 votes)
25 views28 pages

AI Chapter 2

Uploaded by

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

AI Chapter 2

Uploaded by

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

Artificial Intelligence-

Module 1

Prof. Salma Itagi


Asst. Professor
Dept. of CSE,SVIT
Problems , Problem Spaces, Search
• To solve the problem of building a system you should take the following
steps:
1. Define the problem accurately including detailed specifications and
what constitutes a suitable solution.
2. Scrutinize the problem carefully, for some features may have a
central affect on the chosen method of solution.
3. Segregate and represent the background knowledge needed in the
solution of the problem.
4. Choose the best solving techniques for the problem to solve a
solution.
Problem
• Problem solving is a process of generating solutions from observed data.

• a ‘problem’ is characterized by a set of goals,


• a set of objects, and
• a set of operations.

 Problem Space

• A ‘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. A solution is a combination of operations and objects that
achieve the goals.

 Search

• A ‘search’ refers to the search for a solution in a problem space.

 Search proceeds with different types of ‘search control strategies’.


 The depth-first search and breadth-first search are the two common search strategies.
AI - General Problem Solving
• General Problem Solver (GPS) was a computer program
created in 1957 by Simon and Newell to build a universal
problem solver machine.
• GPS was based on Simon and Newell’s theoretical work on
logic machines.
• GPS solved many simple problems, such as the Towers of
Hanoi, that could be sufficiently formalized, but GPS could
not solve any real-world problems.
Problem definitions
• A problem is defined by its ‘elements’ and their ‘relations’.

• To provide a formal description of a problem, we need to do the 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.
The problem can then 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’.

Thus:
 Search is fundamental to the problem-solving process.
 Search is a general mechanism that can be used when a 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 search problems.
Problem Space
• A problem space is represented by a directed graph,
where nodes represent search state and paths
represent the operators applied to change the state.
• To simplify search algorithms, it is often
convenient to logically and programmatically GRAPH
represent a problem space as a tree.
• A tree usually decreases the complexity of a search
at a cost.
• Here, the cost is due to duplicating some nodes on
the tree that were linked numerous times in the
graph, e.g. node B and node D.
• A tree is a graph in which any two vertices are
connected by exactly one path.
TREE
• Alternatively, any connected graph with no cycles
is a tree.
DEFINING PROBLEM AS A STATE
State Space Search
SPACE SEARCH
A state space represents a problem in terms of states and operators that change states.
A state space consists of:
• A representation of the states the system can be in.
• For example, in a board game, the board represents the current state of the game.
• A set of operators that can change one state into another state. In a board game, the
operators are the legal moves from any given state. Often the operators are
represented as programs that change a state representation to represent the new state.
• An initial state.
• A set of final states; some of these may be desirable, others undesirable.
This set is often represented implicitly by a program that detects terminal states.
Production System in Artificial
Intelligence
• Since the search process is the core of many artificial
intelligence (AI) processes, it is useful to structure Al
programs in a way that facilitates describing and
performing the search process.
• Production systems in artificial intelligence provide such
structures so that the search process’s performance can
be measured.
• A production system consists of:
• 1. A set of rules, “each consisting of a left side (a
pattern) that determines the applicability of the rule
and a right side that describes the operation to be
performed if the rule is applied.”
• In the Water Jug Problem, Rule (x, y) is x<4 ->(4, Y)
indicates Fill the 4-gallon jug and (x, y) if y<3 -> (x, 3)
indicates Fill the 3-gallon jug.
2. One or more knowledge/databases “that contain
whatever information is appropriate for the particular
task. Some plans of the database may be permanent,
while other plans of it may pertain only to the solution of
the current problem.”
3. A control strategy “that specifies the order in which the
rules will be compared to the database and a way of
resolving the conflicts that arise when several rules match
at once.”
3. A rule applier.
Classes / Categories of
Production systems
• The production system is mainly categorized into 4 types,
• 1. Monotonic Production System: “The application of a rule
never prevents the later application of another rule that could also
have been applied at the time the first rule was selected”.
• 2. Non-Monotonic Production system: “is one in which this is
not true”.
• 3. Partially commutative Production system: “It is the
property that if the application of a particular sequence of rules
transforms state x to state y, then permutation of those rules
allowable, also transforms state x into state y.”
• 4. Commutative Production system: “is both monotonic and
Partially commutative”.
Partially Commutative and
Monotonic:
• These production systems are useful for solving
ignorable problems.
• Example: Theorem Proving
• They can be implemented without the ability to
backtrack to previous states when it is discovered that
an incorrect path has been followed.
• This often results in a considerable increase in
efficiency, particularly because since the database will
never have to be restored, It is not necessary to keep
track of where in the search process every change was
made.
Partially Commutative and Non-
Monotonic
• These production systems are useful for solving
problems in which changes occur but can be reversed
and in which order of operations is not critical.
• Example: Robot Navigation, 8-puzzle, blocks
world
• Suppose the robot has the following ops: go North (N),
go East (E), go South (S), go West (W).
• To reach its goal, it does not matter whether the robot
executes the N-N-E or N-E-N.
Not Partially Commutative

• These production systems are useful for solving problems


in which irreversible change occurs
• Example: Chemical Synthesis
• The operations can be: Add chemical x to the pot, Change
the temperature to t degrees.
• These operations may cause irreversible changes to the
potion being brewed.
• The order in which the operations are performed can be
very important in determining the final output.
• For example (X+y)+z is not the same as (z+y)+x
Water Jug Problem
Two Jugs of different capacities are given
Note:There is no marking on the Jugs
X ltrs Y ltrs

Goal is to fill exactly L ltrs of water into Y ltrs Jug. >


X ltrs Y ltrs

State is represented as < X, Y>

Integer amount of water in ‘X’ ltr Jug integer amount of water in ‘Y’ ltrs of Jug

For example:<1,2>
Example of water Jug Problem
Suppose capacity of 2 Jugs 2 Ltrs X

3 Ltrs Y

Goal :To get exactly 1 Ltr water in 2 Ltrs Jug


i.e <1,0>

<0,0> {initial state}

<2,0>
<0,3>

<2,3>
<2,1>

<2,0>
<0,1>

<1,0> {Goal State}


Production Systems
• Production systems provide appropriate structures for
performing and describing search processes.
• A production system has four basic components :
• A set of rules each consisting of a left side that determines the
applicability of the rule and a right side that describes the
operation to be performed if the rule is applied.
Application of the rule changes
• A database of current facts established during the process of the knowledge database.
inference. The control system chooses
• A control strategy that specifies the order in which the rules will be which applicable rule should be
compared with facts in the database and also specifies how to applied and ceases computation
resolve conflicts in selection of several rules or selection of more when a termination condition o
facts. the knowledge database is
satisfied.
• A rule firing module.
• The production rules operate on the knowledge database.
• Each rule has a precondition—that is, either satisfied or not by the
knowledge database. If the precondition is satisfied, the rule can be
applied.
Problem:
• There are two jugs
of volume A litre and B litre. 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 x litre of water into the A
litre jug.
• Assuming that we have unlimited supply of water.
• Note:Let's assume we have A=4 litre and B= 3 litre
jugs. And we want exactly 2 Litre water into jug A
(i.e 4 litre jug) how we will do this.
Solution:
• 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)
• Generate production rules for the water jug problem
• We basically perform three operations to achieve the goal.
1.Fill water jug.
2.Empty water jug
3.and Transfer water jug
PRODUCTION RULES
Initialization:
Now the state is (3,3)
• Start State: (0,0) Iteration 3:
• Apply Rule 2: Current State:(3,3)
Apply Rule 5:
• Fill 3-gallon jug Pour water from 3-gallon jug into 4-gallon jug
Now the state is (x,3) until 4-gallon jug is full
• Iteration 1: Now the state is (4,2)
Iteration 4:
• Current State: (x,3) Current State : (4,2)
• Apply Rule 7: Apply Rule 3:
Empty 4-gallon jug
• Pour all water from 3-gallon jug
Now state is (0,2)
into 4-gallon jug Iteration 5:
• Now the state is (3,0) Current State : (0,2)
• Iteration 2: Apply Rule 9:
Pour 2 gallon water from 3 gallon jug into 4
• Current State : (3,0) gallon jug
• Apply Rule 2:
Now the state is (2,0)-- Goal Achieved.
• Fill 3-gallon jug
Eight Puzzle Problem
• The 8-puzzle is a 3 × 3 array containing eight square pieces, numbered 1
through 8, and one empty space.
• A piece can be moved horizontally or vertically into the empty space, in
effect exchanging the positions of the piece and the empty space.
• There are four possible moves, UP (move the blank space up), DOWN,
LEFT and RIGHT.
• The aim of the game is to make a sequence of moves that will convert
the board from the start state into the goal state
Example: Missionaries and
Cannibals
The Missionaries and Cannibals problem illustrates the use of state space
search for planning under constraints:

Three missionaries and three cannibals wish to


cross a river using a two person boat. If at any
time the cannibals outnumber the missionaries on
either side of the river, they will eat the
missionaries.

How can a sequence of boat trips be performed that will get everyone to
the other side of the river without any missionaries being eaten?
State representation: Missionaries/Cannibals Search Graph
1. BOAT position: original (T) or final (NIL) side
of the river.
2. Number of Missionaries and Cannibals on the original
side of the river.
3. Start is (T 3 3); Goal is (NIL 0 0).

(MM 2 0) 2 Missionaries cross


the river

(MC 1 1) 1 Missionary and 1


Cannibal

(CC 0 2) 2 Cannibals

(M 1 0) 1 Missionary

(C 0 1) 1 Cannibal
Control Strategies
• The word ‘search’ refers to the search for a solution in a problem
space.
• Search proceeds with different types of ‘search control strategies’.
• A strategy is defined by picking the order in which the nodes expand.
• The Search strategies are evaluated along the following dimensions:
Completeness,
Time complexity,
Space complexity
Algorithm’s performance and complexity

• Ideally we want a common measure so that we can compare approaches in


order to select the most appropriate algorithm for a given situation.

• Performance of an algorithm depends on internal and external factors.

• Internal factors/ External factors


Time required to run
Size of input to the algorithm
Space (memory) required to run
Speed of the computer
 Quality of the compiler
Complexity is a measure of the performance of an algorithm.
Complexity measures the internal factors, usually in time than space.
Computational complexity
It is the measure of resources in terms of Time and Space.
• If A is an algorithm that solves a decision problem f, then run-time of
A is the number of steps taken on the input of length n.
• Time Complexity T(n) of a decision problem f is the run-time of the
‘best’ algorithm A for f.
• Space Complexity S(n) of a decision problem f is the amount of
memory used by the ‘best’ algorithm A for f.

You might also like