Artificial Intelligence and Machine Learning
Artificial Intelligence and Machine Learning
Introduction
● Problem solving is the major area of concern in Artificial Intelligence.
● It is the process of generating solution from given observed data.
● To solve a particular problem, we need to build a system or a method which can generate
required solution.
● Following four things are required for building such system.
1. Define the problem precisely.
⮚ This definition must precisely specify the initial situation (input).
⮚ What final situation (output) will constitute the acceptable solution to the
problem.
2. Analyze the problem.
⮚ To identify those important features which can have an immense impact
on the appropriateness of various possible techniques for solving the
problem.
3. Isolate and represent the task knowledge that is necessary to solve the problem.
4. Choose the best problem solving technique and apply it to the particular
problem.
3 (x, y) if x > 0 (x-d, y) Pour some water out of the 4 gallon jug
4 (x, y) if y > 0 (x, y-d) Pour some water out of the 3 gallon jug
7 (x, y) if x+y >= 4 (4, y-(4- Pour water from the 3 gallon jug into
and y > 0 x)) the 4 gallon jug until the 4 gallon jug is
full
8 (x, y) if x+y >= 3 (x-(3-y), Pour water from the 4 gallon jug into
and x>0 3) the 3-gallon jug until the 3 gallon jug is
full
9 (x, y) if x+y <=4 (x+y, 0) Pour all the water from the 3 gallon jug
and y>0 into the 4 gallon jug
1 (x, y) if x+y <= 3 (0, x+y) Pour all the water from the 4 gallon jug
0 and x>0 into the 3 gallon jug
● The program is to change the initial configuration into the goal configuration.
● A solution to the problem is an appropriate sequence of moves, such as “move tiles 5 to
the right, move tile 7 to the left ,move tile 6 to the down” etc…
● To solve a problem, we must specify the global database, the rules, and the control
strategy.
● For the 8 puzzle problem that correspond to three components.
● These elements are the problem states, moves and goal.
● In this problem each tile configuration is a state.
● The set of all possible configuration in the problem space, consists of 3,62,880 different
configurations of the 8 tiles and blank space.
● For the 8-puzzle, a straight forward description is a 3X3 array of matrix of numbers.
Initial global database is this description of the initial problem state. Virtually any kind of
data structure can be used to describe states.
● A move transforms one problem state into another state.
Figure 1: Solution of 8 Puzzle problem
Production System
● Search process forms the core of many intelligence processes.
● So, it is useful to structure AI programs in a way that facilitates describing and performing
the search process.
● Production system provides such structures.
● A production system consists of:
1. 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 that rule is applied.
2. One or more knowledge/databases that contain whatever information is appropriate
for the particular task. Some parts of the database may be permanent, while other parts
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.
4. A rule applier which is the computational system that implements the control strategy
and applies the rules.
● In order to solve a problem:
o We must first reduce it to the form for which a precise statement can be given. This
can be done by defining the problem’s state space (start and goal states) and a set of
operators for moving that space.
o The problem can then be solved by searching for a path through the space from an
initial state to a goal state.
o The process of solving the problem can usefully be modeled as a production system.
Production System Characteristics
1. Simplicity: Due to the use of the IF-THEN structure, each sentence is unique in the
production system. This uniqueness makes the knowledge representation simple to
enhance the readability of the production rules.
2. Modularity: The knowledge available is coded in discrete pieces by the production
system, which makes it easy to add, modify, or delete the information without any side
effects. The production rule is made of collection of information and facts.
3. Modifiability: This feature allows for the modification of the production rules. The rules
are first defined in the skeletal form and then modified to suit an application.
4. Knowledge-intensive: As the name suggests, the system only stores knowledge. All the
rules are written in the English language. This type of representation solves the
semantics problem.
Benefits of Production System
1. Production systems provide an excellent tool for structuring AI programs.
2. Production Systems are highly modular because the individual rules can be added,
removed or modified independently.
3. The production rules are expressed in a natural form, so the statements contained in the
knowledge base should be easily understandable.
Production System Characteristics
5. 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. i.e., rules are independent.
6. Non-Monotonic Production system is one in which this is not true.
7. Partially commutative Production system: a production system with the property that if
application of a particular sequence of rules transforms state x to state y, then allowable
permutation of those rules, also transforms state x into state y.
8. Commutative Production system: A Commutative production system is a production
system that is both monotonic and partially commutative.
Heuristic Function
● Heuristic function maps from problem state descriptions to measures of desirability,
usually represented as numbers.
● Which aspects of the problem state are considered, how those aspects are evaluated, and
the weights given to individual aspects are chosen in such a way that the value of the
heuristic function at a given node in the search process gives as good an estimate as
possible of whether that node is on the desired path to a solution.
● Well-designed heuristic functions can play an important part in efficiently guiding a search
process toward a solution.
● Every search process can be viewed as a traversal of a directed graph, in which the nodes
represent problem states and the arcs represent relationships between states.
● The search process must find a path through this graph, starting at an initial state and
ending in one or more final states.
● Domain-specific knowledge must be added to improve search efficiency. Information about
the problem includes the nature of states, cost of transforming from one state to another,
and characteristics of the goals.
● This information can often be expressed in the form of heuristic evaluation function.
● In general, heuristic search improve the quality of the path that are exported.
● Using good heuristics we can hope to get good solutions to hard problems such as the
traveling salesman problem in less than exponential time.
Heuristic Search Techniques
I. Generate-and-Test
● Generate-and-test search algorithm is a very simple algorithm that guarantees to find a
solution if done systematically and there exists a solution.
Algorithm:
1. Generate a possible solution. For some problems, this means generating a particular
point in the problem space. For others it means generating a path from a start stat.
2. Test to see if this is actually a solution by comparing the chosen point or the endpoint
of the chosen path to the set of acceptable goal states.
3. If a solution has been found, quit, Otherwise return to step 1.
● It is a depth first search procedure since complete solutions must be generated before
they can be tested.
● In its most systematic form, it is simply an exhaustive search of the problem space.
● It operates by generating solutions randomly.
example where we know the initial state and goal state as given below. In this problem, we need to get
the goal state by finding differences between the initial state and goal state and applying operators.
Solution:
To solve the above problem, we will first find the differences between initial states and goal states, and
for each difference, we will generate a new state and will apply the operators. The operators we have
for this problem are:
● Move
● Delete
● Expand
1. Evaluating the initial state: In the first step, we will evaluate the initial state and will compare the
initial and Goal state to find the differences between both states.
2. Applying Delete operator: As we can check the first difference is that in goal state there is no dot
symbol which is present in the initial state, so, first we will apply the Delete operator to remove this
dot.
3. Applying Move Operator: After applying the Delete operator, the new state occurs which we will
again compare with goal state. After comparing these states, there is another difference that is the
square is outside the circle, so, we will apply the Move Operator.
4. Applying Expand Operator: Now a new state is generated in the third step, and we will compare this
state with the goal state. After comparing the states there is still one difference which is the size of the
square, so, we will apply Expand operator, and finally, it will generate the goal state.