You are on page 1of 58

Artificial Intelligence

(5A24ARI)

Presented By
Prof. Aakansha Saxena
Assistant Professor
Rashtriya Raksha University
Artificial Intelligence
Artificial Intelligence

• Artificial intelligence is the study of how to make


computers do things which, at moment people do better.
• From the perspective of intelligence, artificial intelligence
is making machines "intelligent"
• Machines that act as we would expect people to act.
• Turing test: The inability to distinguish computer
responses from human responses
• Intelligence requires knowledge
Artificial Intelligence
• Business perspective: AI is a set of very powerful tools,
and methodologies for using to solve business problems.
• Programming perspective: AI includes the study of
symbolic programming, problem solving, and search.
• AI programs focus on symbols rather than numeric
processing
• Problem solving i.e. to achieve a specific goal.
• Search - rarely access a solution directly. Search may
include a variety of techniques.
• Science and engineering of making intelligent machines-
intelligent computer programs
Artificial Intelligence Problems

• Initially mainly used for formal tasks-game playing,


theorem proving.
• Game playing and theorem proving share the property
that people who do them well are considered to be
displaying Intelligence.
• Initially computers could perform well at those tasks
simply by being fast at exploring a large number of
solution paths and then selecting the best one.
• Humans learn ordinary tasks since their birth by
perception, speaking, using language, and training.
• Formal Tasks and Expert Tasks are learned later on..
Artificial Intelligence Problems

• AI focused on common sense reasoning,


• reasoning about physical objects and their
relationship to each other
• reasoning about actions and their consequences.
• AI research progressed, techniques for handling large
amount of world knowledge were developed
• New tasks reasonably attempted such as perception,
natural language understanding and problem solving in
specialized domains.
Task
Domains of

AI
AI technique
• Artificial intelligence problems span a very broad spectrum.
• They appear to have very little in common except that they are
hard.
• AI Research of earlier decades results into the fact that
intelligence requires knowledge.
• AI technique is a method that exploits knowledge that should
be represented in such a way that:
AI technique
• Knowledge possess following properties:
• It is voluminous.
• It is not well-organized or well-formatted.
• It is constantly changing.
• It differs from data. And it is organized in a way that
corresponds to its usage.
AI technique
• AI technique is a method to organize and use the knowledge
efficiently in such a way that −

The knowledge captures generalizations.


It can be understood by the people who provide it.
It should be easily modifiable to correct errors.
It should be useful in many situations though it is incomplete or
inaccurate.
AI technique
3 Techniques:
1. Search:
• Provides a way of solving problems for which no direct
approach is available.
• It also provides a framework into which any direct
techniques that are available can be embedded.
2. Use of knowledge:
• Provides a way of solving complex problems by exploiting
the structure of the objects that are involved.
3. Abstraction:
• Provides a way of separating important features and
variations from many unimportant ones that would
otherwise overwhelm any process.
AI Classification
There are two conceptual thoughts about AI namely
1. Weak AI and
2. Strong AI

• The strong AI is very much promising about the fact that the
machine is almost capable of solve a complex problem like an
intelligent man.
• They claim that a computer is much more efficient to solve the
problems than some of the human experts.
• According to strong AI, the computer is not merely a tool in
the study of mind, rather the appropriately programmed
computer is really a mind. Strong AI is the supposition that
some forms of artificial intelligence can truly reason and solve
problems
AI Classification
Weak AI or Narrow AI:
• Some thinking like features can be added to computers to
make them more useful tools. It says that computers cannot be
made intelligent equal to human being, unless constructed
significantly differently.
• They claim that computers may be similar to human experts
but not equal in any cases. Generally weak AI refers to the use
of software to study or accomplish specific
• problem solving that do not encompass the full range of
human cognitive abilities.
• i.e,playing chess, purchasing suggestions on e-commerce site,
self-driving cars,
• Weak AI programs cannot be called “intelligent” because they
cannot really think.
Subsets of AI
AI Applications
• Gaming
• Natural Language Processing
• Web Search Engine
• Recommendation System(Youtube, Netflix)
• Vision Systems
• Speech Recognition
• Handwriting Recognition
• Self Driving Cars
• Alexa, Siri
• Intelligent Robots and many more
Advantages

• Reduction in Human Error


• Takes risks instead of Humans
• Available 24x7
• Helping in Repetitive Jobs
• Digital Assistance
• Faster Decisions
• Daily Applications
• New Inventions
Disadvantages

• High Costs of Creation


• Making Humans Lazy
• Unemployment
• No Emotions
• Lacking Out of Box Thinking
Problem solving
• 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.
• For building such system Following four things are
required:

1. Define the problem precisely.


2. Analyze 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
19
it to the particular problem
Defining Problem & Search

• A problem is described formally as:

1. Define a state space that contains all the possible configurations of relevant
objects.
2. Specify one or more states within that space that describe possible situations
from which the problem solving process may start. These states are called
initial states.
3. Specify one or more states that would be acceptable as solutions to the
problem. These states are called goal states.
4. Specify a set of rules that describe the actions available

• 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.

• Search is fundamental to the problem-solving process


State Space Search

Problem solving = Searching for a goal state


• State: Representation of problem elements at a given
moment.
• State space:Set of all states reachable from the initial state.
• A state space forms 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.
• solution of a problem:Part of the graph formed by the state
space.

21
State Space Search: Playing Chess
• Each position can be described by an 8-by-8 array.
• Initial position is the game opening position.
• Goal position is any position in which the opponent
does not have a legal move and his or her king is
under attack.
• Legal moves can be described by a set of rules:
− Left sides are matched against the current state.
− Right sides describe the new resulting state.

22
State Space Search: Playing Chess

• State space is a set of legal positions.


• Starting at the initial state.
• Using the set of rules to move from one state to
another.
• Attempting to end up in a goal state.

23
State Space Search: Water Jug Problem

“You are given two jugs, a 4-litre one and a 3-litre one.
Neither has any measuring markers on it. There is a
pump that can be used to fill the jugs with water. How
can you get exactly 2 litres of water into 4-litre jug.”

24
State Space Search: Water Jug Problem
• State Space Representation: State of the problem
will be represented as a tuple (x, y) ,where
x = Amount of water in the 4-gallon jug ,0 ≤ x ≤ 4,
y= Amount of water in the 3-gallon jug, 0 ≤ y ≤ 3
• Start state: (0, 0).
• Goal state: (2, n) for any n.
• Attempting to end up in a goal state.

25
State Space Search: Water Jug Problem
To solve this problem,we make some assumptions and
also use some information available,

• We can fill a jug from the pump.


• We can pour water out of a jug to the ground.
• We can pour water from one jug to another.
• There is no measuring device available.
• Operators – we define a set of operators that can
take us from one state to another.
26
Production rules for solving the water jug
problem

27
Solution of water jug problem according to the
production rules

28
State Space Search: Water Jug Problem
1. current state = (0, 0)
2. Loop until reaching the goal state (2, 0)
− Apply a rule whose left side matches the current state
− Set the new current state to be the resulting state

(0, 0)
(0, 3)
(3, 0)
(3, 3)
(4, 2)
(0, 2)
(2, 0)
29
State Space Search: Summary

1. Define a state space that contains all the possible


configurations of the relevant objects.
2. Specify the initial states.
3. Specify the goal states.
4. Specify a set of rules:
− What are unstated assumptions?
− How general should the rules be?
− How much knowledge for solutions should be in the
rules?

30
Search Strategies

Requirements of a good search strategy:


1. It causes motion
Otherwise, it will never lead to a solution.

2. It is systematic
Otherwise, it may use more steps than necessary.

3. It is efficient
Find a good, but not necessarily the best, answer.

31
Production System
• AI programs structure should describe and perform search
Process in efficient way.
• Production system provides such structure which have,

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.
Production System

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.
Production System
Characteristics
• Monotonic Production System: the use of one rule never
prevents the involvement of another rule when both the rules
are selected at the same time. Hence, it enables the system to
apply rules simultaneously.

• Non-Monotonic Production system: Increases the problem-


solving efficiency of the machine by not keeping a record of
the changes made in the previous search process.
• These types of production systems are useful from an
implementation point of view as they do not backtrack to the
previous state when it is found that an incorrect path was
followed.
Production System
Characteristics

• Partially commutative Production system: In this


production system if a set of rules is used to change state A to
state B then any allowable combination of these rules will also
produce the same results (convert state A to state B)..

• Commutative Production system: This type of production


systems is used when the order of operation is not important,
and the changes are reversible.
Problem Characteristics

1. Problem is decomposable to smaller or easier problems.


2. Solution steps can be ignored or undone.
3. The problem universe is predictable.
4. There are obvious good solutions without comparisons to
all other possible solutions.
5. Desired solution is a state of the universe or a path to a
state.
6. Requires lots of knowledge; or, uses knowledge to
constrain solutions.
7. Problem requires periodic interaction between humans
and computer.
Issues in the design of search programs

1. The direction in which to conduct search (forward versus


backward reasoning). If the search proceeds from start
state towards a goal state, it is a forward search or we can
also search from the goal.
2. How to select applicable rules (Matching). Production
systems typically spend most of their time looking for rules
to apply. So, it is critical to have efficient procedures for
matching rules against states.
3. How to represent each node of the search process
(knowledge representation problem).
Heuristic Search Algorithm

• A heuristic is a technique that is used to solve a problem faster than


the classic methods. These techniques are used to find the
approximate solution of a problem when classical methods do not.

Heuristics are said to be the problem-solving techniques that result in


practical and quick solutions.

Heuristics are strategies that are derived from past experience with
similar problems.

Heuristics use practical methods and shortcuts used to produce the


solutions that may or may not be optimal, but those solutions are
sufficient in a given limited timeframe.
Why do we need heuristics?

Heuristics are used in situations in which there is the


requirement of a short-term solution. On facing complex
situations with limited resources and time.

Heuristics can help the companies to make quick decisions


by shortcuts and approximated calculations. Most of the
heuristic methods involve mental shortcuts to make
decisions on past experiences.
Heuristic Search Technique

Hill Climbing,
A*,
Simulated Annealing,
Branch and Bound,
Nearest Neighbour,
Blind Search Techniques: DFS, BFS,
Best First Search
Generate and Test
Hill Climbing

It is a technique for optimizing the mathematical problems.


Hill Climbing is widely used when a good heuristic is
available.

It is a local search algorithm that continuously moves in the


direction of increasing elevation/value to find the mountain's
peak or the best solution to the problem. It terminates when
it reaches a peak value where no neighbour has a higher
value.

Traveling-salesman Problem is one of the widely discussed


examples of the Hill climbing algorithm, in which we need to
minimize the distance traveled by the salesman.
Hill Climbing

• Searching for a goal state = Climbing to the top of a hill


• Generate-and-test + direction to move.
• It is a variant of generate and test.
• In this, feedback from test procedure is used to help the
generator decide which direction to move in the search space.
• Pure generate and test: responds with a yes or no.
• But if test function is augmented with a heuristic function
that estimates of how close a given state is to a goal state.
Features of Hill Climbing:

Generate and Test variant: Hill Climbing is the variant of Generate and


Test method. The Generate and Test method produce feedback which
helps to decide which direction to move in the search space.

Greedy approach: Hill-climbing algorithm search moves in the direction


which optimizes the cost.

No backtracking: It does not backtrack the search space, as it does not


remember the previous states.
State-space Diagram for Hill Climbing:

The state-space landscape is a graphical representation of the hill-


climbing algorithm which is showing a graph between various states of
algorithm and Objective function/Cost.
Different regions in the state space landscape:

Local Maximum: Local maximum is a state which is better than its


neighbour states, but there is also another state which is higher than it.

Global Maximum: Global maximum is the best possible state of state


space landscape. It has the highest value of objective function.

Current state: It is a state in a landscape diagram where an agent is


currently present.

Flat local maximum: It is a flat space in the landscape where all the
neighbor states of current states have the same value.

Shoulder: It is a plateau region which has an uphill edge.


Simple Hill Climbing (algorithm)
• Step 1: Evaluate the initial state. If it is also a goal state,
then return it and quit. Otherwise, continue with the initial
state as current state.
• Step 2: loop until a solution is found or until there are no
new operators left to be applied in the current state:
(a). Select an operator that has not yet been applied to the
current state and apply it to produce a new state.
(b). Evaluate the new state.
(i). If it is a goal state, then return it and quit.
(ii). If it is not a goal state but it is better then current
state, then make it the current state.
(iii). It it is not better than the current state, then
continue in the loop.
Problems in Hill Climbing Algorithm:

1. Local Maximum: A local maximum is a peak state in the landscape which is


better than each of its neighbouring states, but there is another state also
present which is higher than the local maximum.

Solution: Backtracking technique can be a solution of the local maximum


in state space landscape. Create a list of the promising path so that the
algorithm can backtrack the search space and explore other paths as well.

2. Plateau: A plateau is the flat area of the search space in which all the neighbour
states of the current state contains the same value, because of this algorithm does
not find any best direction to move. A hill-climbing search might be lost in the
plateau area.

Solution: The solution for the plateau is to take big steps while searching, to
solve the problem. Randomly select a state which is far away from the current
state so it is possible that the algorithm could find non-plateau region.
Problems in Hill Climbing Algorithm:

3. Ridges: A ridge is a special form of the local maximum. It has an area which is
higher than its surrounding areas, but itself has a slope, and cannot be reached
in a single move.

Solution: With the use of bidirectional search, or by moving in different


directions, we can improve this problem.
Simulated Annealing

• A variation of hill climbing in which, at the beginning of the


process, some downhill moves may be made.

• Lowering the chances of getting caught at a local


maximum, or plateau, or a ridge.

Metallurgy:- Annealing is the process used to temper or


harden metals and glass by heating them to a high
temperature and then gradually cooling them, thus allowing
the material to reach a low-energy crystalline state
Simulated Annealing

1.Choose a random initial state, high initial temperature, and


cooling rate.
2. Choose random neighbour of current state
3. If it's better than the current state, pick it
4. If not, randomly decide to take it anyway based on
temperature
5. Reduce temperature
6. Repeat steps 2-5 until cooled
Best first search (BFS)

This algorithm always chooses the path which appears best at that
moment. It is the combination of depth-first search and breadth-first
search algorithms. It lets us to take the benefit of both algorithms. It uses
the heuristic function and search. With the help of the best-first search,
at each step, we can choose the most promising node.

Step 1: Place the starting node into the OPEN list.

Step 2: If the OPEN list is empty, Stop and return failure.

Step 3: Remove the node n from the OPEN list, which has the lowest
value of h(n), and places it in the CLOSED list.
Step 4: Expand the node n, and generate the successors of node n.

Step 5: Check each successor of node n, and find whether any node is a
goal node or not. If any successor node is the goal node, then return
success and stop the search, else continue to next step.

Step 6: For each successor node, the algorithm checks for evaluation
function f(n) and then check if the node has been in either OPEN or
CLOSED list. If the node has not been in both lists, then add it to the
OPEN list.

Step 7: Return to Step 2


A* Search Algorithm

A* search is the most commonly known form of best-first search. It uses


the heuristic function h(n) and cost to reach the node n from the start
state g(n). It has combined features of UCS and greedy best-first search,
by which it solve the problem efficiently.

It finds the shortest path through the search space using the heuristic
function. This search algorithm expands fewer search tree and gives
optimal results faster
.
Algorithm of A* search:

Step 1: Place the starting node in the OPEN list.

Step 2: Check if the OPEN list is empty or not. If the list is empty, then
return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest
value of the evaluation function (g+h). If node n is the goal node,
then return success and stop, otherwise.

Step 4: Expand node n and generate all of its successors, and put n
into the closed list. For each successor n', check whether n' is
already in the OPEN or CLOSED list. If not, then compute the
evaluation function for n' and place it into the Open list.

Step 5: Else, if node n' is already in OPEN and CLOSED, then it


should be attached to the back pointer which reflects the lowest g(n')
value.

Step 6: Return to Step 2.

You might also like