Artificial Intelligence-Module 2 (1)
Artificial Intelligence-Module 2 (1)
Devaraj F V,CSE
ARTIFICIAL INTELLIGENCE
• We have some actions that can change the state of the world
– Change induced by an action perfectly predictable
• Try to come up with a sequence of actions that will lead us to a
goal state
– May want to minimize number of actions
– More generally, may want to minimize total cost of actions
• Do not need to execute actions in real life while searching for
solution!
Everything perfectly predictable anyway
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
Module 2 Artificial Intelligence Dr. Jalesh kumar and Mr. Devaraj F V,CSE
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.
Module 2 Artificial Intelligence Dr. Jalesh kumar and Mr. Devaraj F V,CSE
Toy problems
• States:
– a state description specifies the location
of each of the eight tiles and blank in one
of the nine squares
• Initial State:
– Any state in state space
• Successor function:
– the blank moves Left, Right, Up, or Down
• Goal test:
– current state matches the goal
configuration
• Path cost:
– each step costs 1, so the path cost is just
the length of the path
Module 2 Artificial Intelligence Dr. Jalesh kumar and Mr. Devaraj F V,CSE
Example 4:
Completeness
Optimality
Time complexity
Space complexity
Uninformed search
• Given a state, we only know whether it is a goal state or not
Module 2 Artificial Intelligence Dr. Jalesh kumar and Mr. Devaraj F V,CSE
• Cannot say one nongoal state looks better than another nongoal
state
• Can only traverse state space blindly in hope of somehow hitting
a goal state at some point
– Also called blind search
Blind does not imply unsystematic!
Breadth-first search
Algorithm:
Depth-first search
• Fringe can be maintained as a Last-In-First-Out (LIFO) queue ( a
stack)
• Also easy to implement recursively:
• DFS(node)
– If goal(node) return solution(node);
– For each successor of node
Module 2 Artificial Intelligence Dr. Jalesh kumar and Mr. Devaraj F V,CSE
–
Module 2 Artificial Intelligence Dr. Jalesh kumar and Mr. Devaraj F V,CSE
Depth-limited search
The embarrassing failure of depth-first search in infinite state spaces
can be alleviated by supplying depth-first search with a predetermined
depth limit “L”. That is, nodes at depth “L” are treated as if they have
no successors. This approach is called depth-limited search.
Sometimes, depth limits can be based on knowledge of the problem.
For example, on the map of Romania there are 20 cities. Therefore,
we know that if there is a solution, it must be of length 19 at the
longest, so = 19 is a possible choice.
Bidirectional search
• Even better: search from both the start and the goal, in parallel!