0% found this document useful (0 votes)
6 views48 pages

Informed Search

Uploaded by

ed
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)
6 views48 pages

Informed Search

Uploaded by

ed
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/ 48

Types of search strategies

• Breadth-first search
• Uniform-cost search
• Depth-first search
Uninformed • Depth-limited search
• Iterative deepening depth-first search
search
• Bidirectional search

• Greedy best-first search


• A* search
Informed • Memory-bounded heuristic search
search

2/12/2024 1
Informed Search strategies

• Additional information about the states beyond the


problem definition.
• Uses Problem-specific knowledge to find more
efficient solutions.
• Maintains a sort of internal states via heuristics
functions which provides hints.
Types of search strategies

• Greedy best-first search


• A* search
Informed
search
• Memory-bounded heuristic search
Greedy Best-First Search ( GBFS )
• Idea: use an evaluation function f(n) for each node
– estimate of "desirability"
– Expand most desirable unexpanded node

• Implementation: use a data structure that maintains the frontier in a decreasing


order of desirability
• Is it really the best?

• Special cases: uniform-cost (Dijkstra’s algorithm), greedy search, A* search

• Heuristic function h(n) – Key Component


– h(n) = estimated cost of the cheapest path from node n to a goal node
– h(n) = 0 if n is the goal
– h(n) could be general or problem-specific
GBFS Algorithm

1. Initialize the Q with the starting state (node)


2. While Q is not empty, do
1. Assign the first element of Q to N
2. If N is the goal, return SUCCESS
3. Remove N from Q
4. Add the children of N to Q
5. Sort the entire Q by f (n)
3. Return FAILURE
Recall Romania Map Example

What’s a proper heuristic that measures cheapest path from current node to goal node?
Romania Map with Costs

Evaluation function: f(n) = h(n)


▪ estimate the cost from n to goal
h(n)=hSLD => straight line distance from n to Bucharest
Arad 🡪 Bucharest (gbfs)
Arad 🡪 Bucharest (gbfs)
Arad 🡪 Bucharest (gbfs)
Arad 🡪 Bucharest (gbfs)
Analysis of Greedy Best-First search

• Complete?
– From Iasi to Fagaras
– No – can get stuck in loops, e.g., Iasi 🡪 Neamt 🡪 Iasi 🡪Neamt 🡪 …
• Time?
– O(bm), but a good heuristic can give dramatic improvement
• Space?
– O(bm) -- keeps all nodes in memory
• Optimal?
– No
A*: Minimizing Total Est. Cost
• Name Reason

• Idea: avoid expanding paths that are already expensive.

• Evaluation function f (n) = g(n) + h(n)

– g (n) = cost so far to reach n

– h (n) = estimated cost from n to goal

– f (n) = estimated total cost of path through n to goal


Arad 🡪 Bucharest (a* search)
Arad 🡪 Bucharest (a* search)
Arad 🡪 Bucharest (a* search)
Arad 🡪 Bucharest (a* search)
Arad 🡪 Bucharest (a* search)
Arad 🡪 Bucharest (a* search)
Analysis of A* search
• Important idea:
– Appropriate h(n) function
– A* is optimal efficient (no other optimal alg. Can expand fewer nodes than A*)
– Pruning while still guaranteeing optimality
• Complete?
– Yes (unless there are infinitely many nodes with f ≤ f(G))
• Optimal?
– Yes, with finite b and positive path cost
• However, A* is not the answer for all problems
• Time?
– Exponential in the length of the solution
• Space?
– Keeps all nodes in memory & usually runs out of space long before it runs out of time
Heuristics h(n) for A*

Two commonly used functions:


▪ h1(n) = number of misplaced tiles
e.g., h1(n) = 8

▪ h2 (n) = sum of the distances of the tiles from their goal positions,
called Manhattan distance
e.g., h2 (n) = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 =
18
Memory bounded heuristic search

• Recursive Best-First Search


• Iterative Deepening A* search
Memory • Simple Memory-bound A* search
Bounded Search
Recursive Best-First Search (RBFS)

• Similar to A* algorithm developed for heuristic search


• Difference lies in their memory capability
– A* keeps in memory all the nodes that are generated.
– RBFS keeps only the current search path and the sibling nodes along the path
• Suspends the search of subtree when it no longer looks the best
• When it suspends, it forgets the subtree to save space
Recursive Best-First Search (RBFS)

• Space complexity is linear to the depth of the search tree


• Mimics Best-First Search
• Keeps track of the f-value of the best alternative path available from any
ancestor of the current node.
• If current node exceed the limit , then the alternative path is explored.
• Remembers the best f-value of the leaf in the forgotten subtree.
Arad 🡪 Bucharest (rbfs search)
Arad 🡪 Bucharest (rbfs search)
Arad 🡪 Bucharest (rbfs search)
CONSTRAINT SATISFACTION PROBLEM

2/12/2024 20CS208 INTELLIGENT AGENT 28


CONSTRAINT SATISFACTION PROBLEM
(CSP)
• Constraint satisfaction is a technique where a problem is solved when its values satisfy
certain constraints or rules of the problem. Such type of technique leads to a deeper
understanding of the problem structure as well as its complexity.

• Constraint satisfaction depends on three components, namely:


• X: It is a set of variables.
• D: It is a set of domains where the variables reside. There is a specific domain for each
variable.
• C: It is a set of constraints which are followed by the set of variables.

• The constraint value consists of a pair of {scope, rel}.


• The scope is a tuple of variables which participate in the constraint and rel is a relation
which includes a list of values which the variables can take to satisfy the constraints of the
problem.
2/12/2024 29
SOLVING CSP PROBLEM
• The requirements to solve a constraint satisfaction problem (CSP) is:
• A state-space
• The notion of the solution.
• A state in state-space is defined by assigning values to some or all variables such as
{X1=v1, X2=v2, and so on…}.

• An assignment of values to a variable can be done in three ways:

• Consistent or Legal Assignment: An assignment which does not violate any constraint or
rule is called Consistent or legal assignment.
• Complete Assignment: An assignment where every variable is assigned with a value, and the
solution to the CSP remains consistent. Such assignment is known as Complete assignment.
• Partial Assignment: An assignment which assigns values to some of the variables only. Such
type of assignments are called Partial assignments.
2/12/2024 30
DOMAINS & CONSTRAINTS IN CSP
There are following two types of domains which are used by the variables :
• Discrete Domain: It is an infinite domain which can have one state for multiple variables. For
example, a start state can be allocated infinite times for each variable.
• Finite Domain: It is a finite domain which can have continuous states describing one domain for
one specific variable. It is also called a continuous domain.

With respect to the variables, basically there are following types of constraints:
• Unary Constraints: It is the simplest type of constraints that restricts the value of a single variable.
e.g., SA ≠ green
• Binary Constraints: It is the constraint type which relates two variables. A value x2 will contain a
value which lies between x1 and x3. e.g., SA ≠ WA
• Global Constraints: It is the constraint type which involves an arbitrary number of variables.

2/12/2024 31
MAP COLORING USING CSP

Variables: X = {WA, NT, Q, NSW, V, SA, T }


Domains: Di = {red, green, blue}

2/12/2024
Constraints: Adjacent regions must have different colors 32
MAP COLORING USING CSP

Variables: X = {WA, NT, Q, NSW, V, SA, T }


Domains: Di = {red, green, blue}
Constraints: Adjacent regions must have different colors
Solution: {WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = red}.

2/12/2024 33
CONSTRAINT GRAPH - CSP

▪ Constraint graph: nodes are variables, arcs are


constraints
▪ Binary CSP: each constraint relates two variables
▪ CSP conforms to a standard pattern
▪ a set of variables with assigned values
▪ generic successor function and goal test
▪ generic heuristics
▪ reduce complexity

2/12/2024 34
CSP AS A SEARCH PROBLEM
• Initial state:
• {} – all variables are unassigned
• Successor function:
• a value is assigned to one of the unassigned variables with no conflict
• Goal test:
• a complete assignment
• Path cost:
• a constant cost for each step
• Solution:
• Appears at depth n if there are n variables
• Depth-first or local search methods work well
2/12/2024 35
CSP SOLVERS

▪ CSP solver can quickly eliminate large part of search space


▪ If {SA = blue}
▪ Then 35 assignments can be reduced to 25
assignments, a reduction of 87%

▪ In a CSP, if a partial assignment is not a solution, we can


immediately discard further refinements of it

2/12/2024 36
GLOBAL CONSTRAINTS- CRYPTARITHMETIC

2/12/2024 37
GLOBAL CONSTRAINTS- CRYPTARITHMETIC
• SOLVE:
S E N D
+ M O R E
----------------------------------
M O N E Y

B A S E
+ B A L L
-------------------------------------
G A M E S
2/12/2024 38
REAL WORLD CSP

2/12/2024 39
BACKTRACKING - CSP

2/12/2024 40
BACKTRACKING - CSP

2/12/2024 41
BACKTRACKING - CSP

2/12/2024 42
BACKTRACKING - CSP

2/12/2024 43
BACKTRACKING - CSP

2/12/2024 44
IMPROVING BACKTRACKING EFFICIENCY

2/12/2024 45
Forward checking

2/12/2024 46
Constraint propagation

2/12/2024 47
THANK YOU

You might also like