0% found this document useful (0 votes)
11 views86 pages

2 - U1 - Aiml - Part2

The document provides an introduction to Artificial Intelligence (AI) and Machine Learning (ML), covering key concepts such as intelligent agents, problem-solving strategies, and various example problems including the Water Jug Problem and the 8-Queens Problem. It outlines the systematic approach to problem-solving in AI through search algorithms, detailing the steps of goal formulation, problem formulation, and execution. Additionally, it discusses the importance of defining well-structured problems and the role of search algorithms in achieving solutions.

Uploaded by

sujaljadhao3113
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)
11 views86 pages

2 - U1 - Aiml - Part2

The document provides an introduction to Artificial Intelligence (AI) and Machine Learning (ML), covering key concepts such as intelligent agents, problem-solving strategies, and various example problems including the Water Jug Problem and the 8-Queens Problem. It outlines the systematic approach to problem-solving in AI through search algorithms, detailing the steps of goal formulation, problem formulation, and execution. Additionally, it discusses the importance of defining well-structured problems and the role of search algorithms in achieving solutions.

Uploaded by

sujaljadhao3113
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/ 86

Unit1

Part2
Dr.Mrs.Rajani.P.K
Unit1
Introduction to Artificial Intelligence (AI) & Machine Learning (ML)
(8 hours)
• Introduction to AI:
– Intelligent Agents, Agents and environments, Good behavior

– The nature of environments, structure of agents

– Problem Solving, problem solving agents, example problems

– Searching for solutions, uninformed search strategies

• Introduction to ML:
– Why Machine learning, Types of machine learning

– Basic concepts in machine learning like

– Parametric and Non-Parametric modeling

– Linear and Non-linear Regression, over fitting


Chapter 3
Problem-Solving Agent
sensors

?
environm
ent
agent

actuators
Water Jug Problem
Definition:
Some jugs are given which should have non-calibrated properties. At least
any one of the jugs should have filled with water. Then the process through
which we can divide the whole water into different jugs according to the
question can be called as water jug problem.

Procedure:
Suppose that you are given 3 jugs A,B,C with capacities 8,5 and 3 liters
respectively but are not calibrated (i.e. no measuring mark will be there). Jug
A is filled with 8 liters of water. By a series of pouring back and forth among
the 3 jugs, divide the 8 liters into 2 equal parts i.e.
4 liters in jug A and 4 liters in jug B. How?
Water Jug Problem

This problem takes a lot of time to find the goal state.


This process of searching in this problem is very lengthy.
At each step of the problem the user have to strictly follow the production rules.
Otherwise the problem may go to infinity step.
Missionaries and Carnivals Problem
Definition:
In Missionaries and Carnivals Problem, initially there are some missionaries and
some carnivals will be at a side of a river. They want to cross the river. But there
is only one boat available to cross the river. The capacity of the boat is 2 and no
one missionary or no Carnivals can cross the river together. So for solving the
problem and to find out the solution on different states is called the Missionaries
and Carnival Problem.
Procedure: Let us take an example.
Initially a boatman, Grass, Tiger and Goat is present at the left bank of the
river and want to cross it. The only boat available is one capable of carrying 2
objects of portions at a time. The condition of safe crossing is that at no time
the tiger present with goat, the goat present with the grass at the either side
of the river. How they will cross the river?
The objective of the solution is to find the sequence of their transfer from one
bank of the river to the other using the boat sailing through the river satisfying
these constraints.
Missionaries and Carnivals Problem
Let us use different representations for each of the missionaries and Carnivals as
follows.

B: Boat T: Tiger G: Goat Gr: Grass

Step 1:
According to the question, this step will be (B, T, G, Gr) as all the Missionaries
and the Carnivals are at one side of the bank of the river. Different states from
this state can be implemented as

The states (B, T, O, O) and (B, O, O, Gr) will not be countable because at a time the
Boatman and the Tiger or the Boatman and grass cannot go. (According to the question).
Queen Problem
Definition:
“We have 8 queens and an 8x8 Chess board having alternate black and white
squares. The queens are placed on the chessboard. Any queen can attack any
other queen placed on same row, or column or diagonal. We have to find the
proper placement of queens on the Chess board in such a way that no queen
attacks other queen”.
Queen Problem
Procedure: Figure: A possible board configuration of 8 queen problem
In figure , the possible board configuration for 8-queen problem has been shown.
The board has alternative black and white positions on it. The different positions
on the board hold the queens. The production rule for this game is you cannot
put the same queens in a same row or same column or in same diagonal. After
shifting a single queen from its position on the board, the user have to shift other
queens according to the production rule. Starting from the first row on the board
the queen of their corresponding row and column are to be moved from their
original positions to another position. Finally the player has to be ensured that
no rows or columns or diagonals of on the table is same.
Unit1
Introduction to Artificial Intelligence (AI) & Machine Learning (ML)
(8 hours)
• Introduction to AI:
– Intelligent Agents, Agents and environments, Good behavior

– The nature of environments, structure of agents

– Problem Solving, problem solving agents, example problems

– Searching for solutions, uninformed search strategies

• Introduction to ML:
– Why Machine learning, Types of machine learning

– Basic concepts in machine learning like

– Parametric and Non-Parametric modeling

– Linear and Non-linear Regression, over fitting


Problem-Solving Agent
sensors

?
environm
ent
agent

actuators
Problem-Solving Agent

sensors

?
environm
ent
agent

actuators
• Formulate Goal
• Formulate Problem
•States
•Actions
• Find Solution
Solving Problems by Searching

• Problem –Solving Agents


• is one kind of goal-based agent, where the agent decide what do by
finding sequences of actions that lead to desirable states.
• If the agent understood the definition of problem, it is relatively
straight forward to construct a search process for finding solutions,
which implies that problem solving agent should be an intelligent
agent to maximize the performance measure.

• The sequence of steps done by the intelligent agent to maximize the


performance measure: sens
1. Goal formulation ors
2. Problem formulation ? enviro
3. Search age nment
4. Solution nt actua
5. Execution phase
tors • Formulate Goal
• Formulate Problem
•States
•Actions
• Find Solution
Solving Problems by Searching
• Reflex agent is simple
– base their actions on
– a direct mapping from states to actions
– but cannot work well in environments
• which this mapping would be too large to store
• and would take too long to learn
• Hence, goal-based agent is used
Problem-Solving Agents
• agents whose task is to solve a particular problem
(steps)
– goal formulation
• what is the goal state
• what are important characteristics of the goal state
• how does the agent know that it has reached the goal
• are there several possible goal states
– are they equal or are some more preferable
– problem formulation
• what are the possible states of the world relevant for solving the
problem
• what information is accessible to the agent
• how can the agent progress from state to state
Problem-Solving Agents
• The sequence of steps done by the intelligent
agent to maximize the performance measure:
1. Goal formulation
2. Problem formulation
3. Search
4. Solution
5. Execution phase
1.Goal formulation
• The goal is formulated
– as a set of world states, in which the goal is
satisfied
• Reaching from initial state goal state
– Actions are required
• Actions are the operators
– causing transitions between world states
– Actions should be abstract enough at a certain
degree, instead of very detailed
– E.g., turn left VS turn left 30 degree, etc.
2.Problem formulation
• The process of deciding
– what actions and states to consider
• E.g., driving Pune Mumbai
– in-between states and actions defined
– States: Some places in Pune & Mumbai
– Actions: Turn left, Turn right, go straight,
accelerate & brake, etc.
3.Search
• Because there are many ways to achieve the
same goal
– Those ways are together expressed as a tree
– Multiple options of unknown value at a point,
• the agent can examine different possible sequences of
actions, and choose the best
– This process of looking for the best sequence is
called search
– The best sequence is then a list of actions, called
solution
5. Execution phase
• Search algorithm
• taking a problem as i/p
• and returns a solution in the form of action sequence.
• Once a solution is found
– the agent follows the solution
– and carries out the list of actions – execution phase
• Design of an agent
– “Formulate, search, execute”
A simple problem-solving agent
• It first formulates a goal and a problem,
• searches for a sequence of actins that would solve the problem,
• and then executes the actions one at a time.
• When this is complete, it formulates another goal and starts over.
Well-defined problems and solutions
• Together a problem is defined by
1. Initial state
2. Actions
3. Successor function
4. Goal test
5. Path cost function
• The solution of a problem is then
– a path from the initial state to a state satisfying the goal
test
• Optimal solution
– the solution with lowest path cost among all solutions
Well-defined problems and solutions
1. The initial state that the agent starts in.
2. A description of the possible actions available to the agent.
3. The most common formulation uses a successor function.
Given a particular state x, SUCCESSOR- FN(x) returns a set of <
action, successor > ordered pairs, reachable from x by any
single action.
A path in the state space is a sequence of states connected by
a sequence of actions.
4 . The goal test, which determines whether a given state is a
goal state. If more than one goal state exists, then we can
check whether any on of the goal state is reached or not.
5. A path cost function that assigns a numeric cost to each path.
The cost of a path can be described as the sum of the costs of
the individual actions along the path.
Example problems
• Toy problems
– those intended to illustrate or exercise various
problem-solving methods
– E.g., puzzle, chess, etc.
• Real-world problems
– tend to be more difficult and whose solutions
people actually care about
– E.g., Design, planning, etc.
Example problems-Toy problem
1) 8 – puzzle problem
The 8 – puzzle consists of a 3 × 3 board with eight numbered
tiles and a blank space a shown in figure.
A tile adjacent to the blank space can slide into the space.
The object is to reach a specified goal state.
8 Puzzle Problem-Toy problem
The standard formulation of Well-defined problems and solutions is
as follows:
1. States: A state description specifies the location of each of the eight tiles
and the blank in one of the nine squares.
2. Initial (Start)state: Any state can be designated as the initial state.
3. Successor function: This generates the legal states that result from
trying the four actions (blank moves Left, Right, Up and Down).
4. Goal test (Goal State) : This checks whether the state matches the goal
configuration.
5. Path cost: Each step costs 1, so the path cost is the number of steps in the
path (length of the path).
8 puzzle problem
• In this puzzle solution of 8 puzzle problem is
discussed.
• Given a 3×3 board with 8 tiles (every tile has one
number from 1 to 8) and one empty space.
• The objective is to place the numbers on tiles to
match final configuration using the empty space.
1 2 3 1 2 3

4 8 - 4 5 6

7 6 5 7 8 -

Start State Goal State


Vacuum World -Toy problems
• Example: vacuum world
• Number of states: 8
• Initial state: Any
• Number of actions: 4
● left, right, suck,
noOp
• Goal: clean up all dirt
● Goal states: {7, 8}
● Path Cost:
● Each step costs 1
Vacuum World -Toy problems
The 8-queens -Toy problems
• The goal of the 8 – queen‘s problem is to place eight queens on a
chessboard such that no queen attacks any other in the same row, column
or diagonal .
• There are two main kinds of formulation.
1. An incremental formulation involves operators that augment the state
description, starting with an empty state; for the 8 – queen‘s problem,
this means that each action adds a queen to the state.
2. A complete state formulation starts with all 8 queens on the board and
moves them around.
The 8-queens -Toy problems
1) The incremental formulation is as follows:
– States: Any arrangement of 0 to 8 queens on the
board is a state.
– Initial state: No queens on the board.
– Successor function: Add a queen to any empty
square.
– Goal test: 8 queens are on the board, none
attacked.
• In this formulation is having 1.8 ×10 14 possible
sequences to investigate.
The 8-queens -Toy problems
2) Complete state formulation
– starts with all 8 queens on the board
– move the queens individually around

• States: Arrangements of n queens (0 ≤ n ≤ 8), one per column in


the leftmost n columns, with no queen attacking another are
states.
• Successor function: Add a queen to any square in the leftmost
empty column such that it is not attacked by any other queen.
• This formulation reduces the 8 queens‘ state space from
1.8 × 1014 to just 2,057, and solutions are easy to find.
The 8-queens
• Conclusion:
– the right formulation makes a big difference to the
size of the search space
• Few Solutions:
– 3,6,2,7,1,4,8,5
– 1,5,2,6,3,7,4,8
Example problems
• Toy problems
– those intended to illustrate or exercise various
problem-solving methods
– E.g., puzzle, chess, etc.
• Real-world problems
– tend to be more difficult and whose solutions
people actually care about
– E.g., Design, planning, etc.
Real-world problems
Unit1
Introduction to Artificial Intelligence (AI) & Machine Learning (ML)
(8 hours)
• Introduction to AI:
– Intelligent Agents, Agents and environments, Good behavior

– The nature of environments, structure of agents

– Problem Solving, problem solving agents, example problems

– Searching for solutions, uninformed search strategies

• Introduction to ML:
– Why Machine learning, Types of machine learning

– Basic concepts in machine learning like

– Parametric and Non-Parametric modeling

– Linear and Non-linear Regression, over fitting



Searching
Problem solving 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.
• In AI problem solving by search algorithms is quite common technique.
• EG:
– technologies of the robotics and path finding.
– It is also widely used in travel planning.
• A search algorithm takes a problem as input and returns the solution in the
form of an action sequence.
• Once the solution is found, the actions it recommends can be carried out.
This phase is called as the execution phase.
• After formulating a goal and problem to solve the agent cells a search
procedure to solve it.
• A problem can be defined by 5 components.
– The initial state: The state from which agent will start.
– The goal state: The state to be finally reached.
– The current state: The state at which the agent is present after starting
from the initial state.
– Successor function: It is the description of possible actions and their
outcomes.
– Path cost: It is a function that assigns a numeric cost to each path.
Different Types of Searching
Searching for solutions
• Finding out a solution is done by
– searching through the state space
• All problems are transformed
– as a search tree
– generated by the initial state and successor
function
Search tree
• Initial state
– The root of the search tree is a search node
• Expanding
– applying successor function to the current state
– thereby generating a new set of states
• leaf nodes
– the states having no successors
Fringe : Set of search nodes that have not been
expanded yet.
• Refer to next figure
Tree search example
Tree search example
Search tree
• The essence of searching
– in case the first choice is not correct
– choosing one option and keep others for later
inspection
• Hence we have the search strategy
– which determines the choice of which state to
expand
– good choice fewer work faster
• Important:
– state space ≠ search tree
Search tree
• State space
– has unique states {A, B}
– while a search tree may have cyclic paths:
A-B-A-B-A-B- …
• A good search strategy should avoid such
paths
Search tree
• A node is having five components:
– STATE: which state it is in the state space
– PARENT-NODE: from which node it is generated
– ACTION: which action applied to its parent-node to
generate it
– PATH-COST: the cost, g(n), from initial state to the
node n itself
– DEPTH: number of steps along the path from the
initial state
Measuring problem-solving performance
• The evaluation of a search strategy
– Completeness:
• is the strategy guaranteed to find a solution when there is
one?
– Optimality:
• does the strategy find the highest-quality solution when
there are several different solutions?
– Time complexity:
• how long does it take to find a solution?
– Space complexity:
• how much memory is needed to perform the search?
Measuring problem-solving performance
• In AI, complexity is expressed in
– b, branching factor, maximum number of
successors of any node
– d, the depth of the shallowest goal node.
(depth of the least-cost solution)
– m, the maximum length of any path in the state
space
• Time and Space is measured in
– number of nodes generated during the search
– maximum number of nodes stored in memory
Measuring problem-solving performance

• For effectiveness of a search algorithm


we can just consider the total cost:
Total cost = path cost (g) of the solution found + search cost
• search cost = time necessary to find the solution

• Tradeoff:
– (long time, optimal solution with least g)
– vs. (shorter time, solution with slightly larger path cost g)
Unit1
Introduction to Artificial Intelligence (AI) & Machine Learning (ML)
(8 hours)
• Introduction to AI:
– Intelligent Agents, Agents and environments, Good behavior

– The nature of environments, structure of agents

– Problem Solving, problem solving agents, example problems

– Searching for solutions, uninformed search strategies

• Introduction to ML:
– Why Machine learning, Types of machine learning

– Basic concepts in machine learning like

– Parametric and Non-Parametric modeling

– Linear and Non-linear Regression, over fitting


Search strategies
• Types of search
– Uninformed search (or) Blind search
– Informed search (or) Heuristic search
• Uninformed search (or) Blind search
– It does not use any information about a problem to guide the search. It
is not an effective search.
– no information about the number of steps or the path cost from the
current state to the goal.
– It search the state space blindly .So the name Blind search.
– EG: BFS, DFS, Uniform Cost Search, Depth Limited Search, Iterative
Deepening Search

• Informed search, or heuristic search


– It uses information about the problem to guide the search.
– a cleverer strategy that searches toward the goal, based on the
information from the current state so far .
– It is uses heuristics. So the name Heuristic search
EG: Best First Search, A* Search,CSP Search,Memory Bounded Search
Uninformed & Informed Search
Uninformed search strategies
• Breadth-first search
– Uniform cost search
• Depth-first search
– Depth-limited search
– Iterative Deepening Search
Breadth First Search(BFS)
• The root node is expanded first (FIFO)
• All the nodes generated by the root node
are then expanded
• And then their successors and so on
Breadth First Search
S

A D

B D A E

C E E B B F
11

D F B F C E A C G
14 17 15 15 13

G C G F
19 19 17
G 25
Breadth-First Strategy
New nodes are inserted at the end of FRINGE
Fringe : Set of search nodes that have not been
expanded yet.
1

2 3 FRINGE = (1)

4 5 6 7
Breadth-First Strategy
New nodes are inserted at the end of FRINGE

2 3 FRINGE = (2, 3)

4 5 6 7
Breadth-First Strategy
New nodes are inserted at the end of FRINGE

2 3 FRINGE = (3, 4, 5)

4 5 6 7
Breadth-First Strategy
New nodes are inserted at the end of FRINGE

2 3 FRINGE = (4, 5, 6, 7)

4 5 6 7
Breadth First Search (Analysis)
• Breadth First Search
– Complete – find the solution eventually
– Optimal, if step cost is 1
The disadvantage
– if the branching factor of a node is large,
– for even small instances (e.g., chess)
• the space complexity and the time complexity are
enormous
Properties of breadth-first search
• Complete? Yes (if b is finite)

• Time? 1+b+b2+b3+… +bd = b(bd-1) = O(bd+1)

• Space? O(bd+1) (keeps every node in memory)

• Optimal? Yes (if cost = 1 per step)

• Space is the bigger problem (more than time)


Breadth-first search (Analysis)
• assuming 10000 nodes can be processed per second, each with 1000
bytes of storage
BFS
Adv:
• Guaranteed to find the single solution at the
shallowest depth level.

Disadv:
• I) The memory requirements are a bigger problem for
breadth-first search than is the execution time.
• II) Exponential-complexity search problems cannot be
solved by uninformed methods for any but only
suitable for smallest instances problem (i.e.) (number
of levels to be minimum (or) branching factor to be
minimum)
Depth-First Search (DFS)
• Always expands one of the nodes at the deepest
level of the tree
• Only when the search hits a dead end
– goes back and expands nodes at shallower levels
– Dead end leaf nodes but not the goal
• Backtracking search
– only one successor is generated on expansion
– rather than all successors
– fewer memory
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO (Stack), i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue(Stack), i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
• Expand deepest unexpanded node
• Implementation:
– fringe = LIFO queue, i.e., put successors at front
Depth-first search
S

A D

B D A E

C E E B B F
11

D F B F C E A C G
14 17 15 15 13

G C G F
19 19 17
G 25
Depth-First Search (Analysis)
• Not complete
– because a path may be infinite or looping
– then the path will never fail and go back try another option
• Not optimal
– it doesn't guarantee the best solution
• It overcomes
– the time and space complexities
• Adv:
– If more than one solution exists (or) number of levels is
high then DFS is best because exploration is done only in a
small portion of the whole space.
• Disadv:
– Not guaranteed to find a solution.
Properties of Depth First Search
• Complete? No: fails in infinite-depth spaces, spaces
with loops
– Modify to avoid repeated states along path
complete in finite spaces

• Time? O(bm): terrible if m is much larger than d


– but if solutions are dense, may be much faster than
breadth-first
• Space? O(bm), i.e., linear space!
• Optimal? No
Comparing Search Strategies
Stay Happy &Healthy!
Enjoy Learning!!
Dr.Mrs.Rajani.P.K
Associate Professor, E&TC
PCCoE

rajani.pk@pccoepune.org
Mobile:9975266997

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