0% found this document useful (0 votes)
14 views69 pages

Unit 4-1

The document discusses Constraint Satisfaction Problems (CSPs) and their formulation, including components like variables, domains, and constraints. It covers techniques for solving CSPs such as backtracking search, forward checking, and arc consistency, using examples like map coloring. Additionally, it introduces planning as a problem-solving approach that involves reasoning about actions and their consequences to achieve specific goals.
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)
14 views69 pages

Unit 4-1

The document discusses Constraint Satisfaction Problems (CSPs) and their formulation, including components like variables, domains, and constraints. It covers techniques for solving CSPs such as backtracking search, forward checking, and arc consistency, using examples like map coloring. Additionally, it introduces planning as a problem-solving approach that involves reasoning about actions and their consequences to achieve specific goals.
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/ 69

Unit 4

Constraint Satisfaction Problem (CSP): CSP as Search Problem, Backtracking


Search for CSP, Forward Checking, Constraint Propagation, Formulating Problem
Structure. Planning: Planning components, Blocks world, Goal Stack Planning,
Planning as a State Space Search, Partial Order Planning, Multi-agent Planning,
Hierarchical Planning, Conditional Planning and Execution Monitoring
Constraint Satisfaction Problem

● We have explored the idea that problems can be solved by searching in a space of
states.
● We use a factored representation for each state: a set of variables, each of which has
a value.
● A problem is solved when each variable has a value that satisfies all the constraints on
the variable.
● A problem described this way is called a constraint satisfaction problem, or CSP.
DEFINING CONSTRAINT SATISFACTION PROBLEMS

A constraint satisfaction problem consists of three components, X, D, and C :


X is a set of variables, {X1,...,Xn}.
D is a set of domains, {D1, . . . , Dn}, one for each variable.
C is a set of constraints that specify allowable combinations of values.
Each domain Di consists of a set of allowable values, {v1,...,vk} for variable Xi.

Each constraint Ci consists of a pair ⟨scope , rel ⟩, where scope is a tuple of variables that participate in the
constraint and rel is a relation that defines the values that those variables can take on.

A relation can be represented as an explicit list of all tuples of values that satisfy the constraint, or as an
abstract relation that supports two operations: testing if a tuple is a member of the relation and enumerating the
members of the relation.

For example, if X1 and X2 both have the domain {A,B}, then the constraint saying the two variables must have
different values can be written as ⟨(X1, X2), [(A, B), (B, A)]⟩ or as ⟨(X1, X2), X1 ̸= X2⟩.
● Explicit listing is useful when the number of valid tuples is small and known in advance (e.g.,
finite domains like {A,B}).
⟨(X, Y), [(1,2), (1,3), (2,1), (2,3), (3,1), (3,2)]⟩
● Abstract relations are more efficient for complex constraints (e.g., arithmetic constraints like
X+Y<10) where enumerating all possible tuples would be impractical.
⟨(X, Y), X ≠ Y⟩
for X in {1, 2, 3}:
for Y in {1, 2, 3}:
if X != Y:
yield (X, Y)
Example problem: Map coloring

We are given the task of coloring each region either red, green, or blue in such a way that
no neighboring regions have the same color. To formulate this as a CSP, we define the
variables to be the regions

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

The domain of each variable is the set

Di = {red , green , blue }.

The constraints require neighboring regions to have


distinct colors.

Since there are nine places where regions border,


there are nine constraints:
Why formulate a problem as a CSP?
Focus on South Australia (SA) and its neighbors:
● SA is adjacent to 5 regions: WA, NT, Q, NSW, V.
● Initially, each neighbor has 3 possible colors (red, green, blue).

Without Constraint Propagation (Naive Search)


With Constraint Propagation (Forward Checking or AC-3)
Backtracking Search for CSPs (Systematic DFS with Backtracking)

Backtracking search is the foundational algorithm for solving Constraint Satisfaction Problems
(CSPs).

How Backtracking Search Works


It follows a depth-first search (DFS) approach with these key steps:
1. Select an unassigned variable (using a variable-ordering heuristic, e.g., most constrained
variable).
2. Assign a value from its domain (using a value-ordering heuristic, e.g., least constraining value).
3. Check consistency (ensure no constraints are violated with current assignments).
○ If consistent, move to the next variable.
○ If inconsistent, backtrack (undo the last assignment and try the next value).
4. Repeat until a complete valid assignment is found or all possibilities are exhausted.
1. Select an unassigned variable (using a variable-ordering heuristic, e.g., most constrained variable).

Variable Selection (Selecting the next variable to assign)

● Most Constrained Variable (MRV) Heuristic:


○ Chooses the variable with the fewest remaining legal values.
○ Example: If SA has 2 possible colors left, but WA has 3, pick SA first.
● Degree Heuristic:
○ Chooses the variable involved in the most constraints (breaks ties).

2. Assign a value from its domain (using a value-ordering heuristic, e.g., least constraining value).

Value Ordering (Choosing which value to try first)

● Least Constraining Value (LCV) Heuristic:


○ Picks the value that rules out the fewest choices for neighboring variables.
○ Example: Assigning red to SA may leave WA with 2 options, while blue leaves only 1 →
prefer red.
3. Check consistency (ensure no constraints are violated with current assignments).
○ If consistent, move to the next variable.
○ If inconsistent, backtrack (undo the last assignment and try the next value).

Consistency Check (Detecting dead-ends early)

● After assigning X = v, check if any neighbor Y has no remaining valid values.


● If a neighbor’s domain becomes empty → backtrack immediately.
Example: Map Coloring (Australia Problem)
Variables: {WA, NT, SA, Q, NSW, V, T}
Domains: {red, green, blue}
Constraints: Adjacent regions must have different colors.
We’ll simulate the algorithm on a simplified map with 3 regions:
● Variables: WA, NT, SA.
● Adjacency: WA borders NT and SA; NT borders SA.

Step 1: Start with an empty assignment


Assignment = {}

Step 2: Choose the first variable (WA)


● Assign WA = red (arbitrary choice).
● Update assignment: {WA: red}.

Step 3: Check consistency


● Neighbors of WA (NT and SA) can no longer be red.
● Prune domains:
○ NT ∈ {green, blue}
○ SA ∈ {green, blue}
Step 4: Choose next variable (NT)
● Assign NT = green.
● Update assignment: {WA: red, NT: green}.

Step 5: Check consistency


● Neighbor SA cannot be green (since NT = green).
● Prune domains:
○ SA ∈ {blue} (only option left).

Step 6: Assign SA = blue


● Update assignment: {WA: red, NT: green, SA: blue}.
● Check constraints:
○ WA ≠ SA (red ≠ blue) ✔
○ NT ≠ SA (green ≠ blue) ✔
● Solution found!
Forward Checking

Forward Checking is an enhancement to the basic backtracking search for solving Constraint Satisfaction Problems (CSPs).
It reduces the search space by dynamically pruning the domains of unassigned variables whenever a new assignment is
made.

Example: Map Coloring Problem

Problem Statement:
Color the regions (A, B, C, D) using Red (R), Green (G), Blue (B) such that no two adjacent regions have the same color.
Constraints:
● A≠B
● A≠C
● B≠C
● B≠D
● C≠D
Initial Domains:
● A: {R, G, B}
● B: {R, G, B}
● C: {R, G, B}
● D: {R, G, B}
Step-by-Step Forward Checking Execution

Step 1: Assign A = R
● Assign: A = R
● Prune neighboring domains:
○ B ≠ R → B: {G, B}
○ C ≠ R → C: {G, B}
○ D remains unchanged (not directly constrained by A).
Domains after pruning:
● A: {R}
● B: {G, B}
● C: {G, B}
● D: {R, G, B}
Step 2: Assign B = G
● Assign: B = G
● Prune neighboring domains:
○ A is already assigned (A ≠ B is already satisfied).
○ C ≠ G → C: {B}
○ D ≠ G → D: {R, B}
Domains after pruning:
● A: {R}
● B: {G}
● C: {B}
● D: {R, B}
Step 3: Assign C = B
● Assign: C = B
● Prune neighboring domains:
○ B is already assigned (B ≠ C is satisfied).
○ D ≠ B → D: {R}
Domains after pruning:
● A: {R}
● B: {G}
● C: {B}
● D: {R}

Step 4: Assign D = R
● Assign: D = R
● Check constraints:
○ B ≠ D (B=G, D=R) → Valid
○ C ≠ D (C=B, D=R) → Valid
● No pruning needed (all variables assigned).
Final Assignment:
● A=R
● B=G
● C=B
● D=R
What If Forward Checking Detects a Dead End?

Suppose in Step 2, we had chosen B = B instead of B = G:


1. Assign B = B
2. Prune:
○ C ≠ B → C: {G}
○ D ≠ B → D: {R, G}
3. Assign C = G
4. Prune:
○ D ≠ G → D: {R}
5. Assign D = R
6. Check constraints:
○ B ≠ D (B=B, D=R) → Valid
○ C ≠ D (C=G, D=R) → Valid
✅ Alternative Solution: A=R, B=B, C=G, D=R
But if at any step a domain becomes empty, Forward Checking forces backtracking immediately.
Arc Consistency (AC-3 Algorithm) with Map Coloring Example

AC-3 Algorithm Steps


1. Initialize a queue with all arcs (constraints between variables)
2. While the queue is not empty:
○ Remove an arc (X, Y) from the queue
○ Revise(X, Y): Remove values from X's domain that conflict with all values in Y's domain
○ If X's domain was revised:
■ Add all arcs (Z, X) where Z is a neighbor of X (except Y) back into the queue
3. Terminate when the queue is empty
Consider a map with 4 regions: WA (Western Australia), NT (Northern Territory), SA (South Australia), and Q
(Queensland) with these borders:
● WA borders NT and SA
● NT borders WA, SA, and Q
● SA borders WA, NT, and Q
● Q borders NT and SA
Available colors: Red, Green, Blue

Initial Setup

Variables and Domains:


● WA: {R, G, B}
● NT: {R, G, B}
● SA: {R, G, B}
● Q: {R, G, B}
Arcs (constraints) to process:
(WA,NT), (WA,SA),
(NT,WA), (NT,SA), (NT,Q),
(SA,WA), (SA,NT), (SA,Q),
(Q,NT), (Q,SA)
AC-3 Execution

Let's process arcs until we achieve arc consistency:


1. Process (WA, NT):
○ For each value in WA, check if NT has at least one different value
○ R in WA: NT can be G or B → OK
○ G in WA: NT can be R or B → OK Process (NT, SA):
○ B in WA: NT can be R or G → OK
○ No changes to NT's domain
○ No changes to WA's domain
2. Process (NT, WA): Process (SA, NT):
○ Similarly, no changes to NT's domain ○ No changes to SA's domain
3. Process (WA, SA): Process (NT, Q):
○ No changes to WA's domain
4. Process (SA, WA): ○ No changes to NT's domain
○ No changes to SA's domain Process (Q, NT):
○ No changes to Q's domain
Process (SA, Q):
○ No changes to SA's domain
Process (Q, SA):
○ No changes to Q's domain
After Initial Pass

No domains were reduced in this simple case because all regions still have all colors available. Now let's make an
assignment and see how AC-3 propagates constraints.
Assign WA = Red:
● Remove R from neighbors NT and SA
● New domains:
○ WA: {R}
○ NT: {G, B}
○ SA: {G, B}
○ Q: {R, G, B}
Now add affected arcs back to queue:
(NT,WA), (NT,SA), (NT,Q),
(SA,WA), (SA,NT), (SA,Q),
(Q,NT), (Q,SA)
Process with WA assigned:

1. Process (NT, WA):


○ NT cannot be R (already removed)
○ No further changes
2. Process (NT, SA):
○ NT's domain: {G,B}
○ SA's domain: {G,B}
○ Check if each NT value has support in SA:
■ G in NT: SA can be B → OK
■ B in NT: SA can be G → OK
○ No changes
3. Process (NT, Q):
○ No changes
4. Process (SA, WA):
○ No changes
5. Process (SA, NT):
○ Check SA values against NT:
■ G in SA: NT can be B → OK
■ B in SA: NT can be G → OK
○ No changes
Process (SA, Q):
○ No changes
Process (Q, NT):
○ No changes
Process (Q, SA):
○ No changes

Final Domains After AC-3:

● WA: {R}
● NT: {G, B}
● SA: {G, B}
● Q: {R, G, B}
Planning
We saw that an agent can consider the consequence of a sequence of actions even before acting to arrive at
the best first move.

Planning in it is most abstract form can be seen as problem solving, planning is problem solving with the
agent using belief about it is action and consequences of the actions to get to a solution by searching through
a abstract space of plans.

So planning is one of the most useful ways that an intelligent agent can take advantage of the knowledge it
has and it is ability to reason about action and consequences. Here we have shown an agent which has both
sensors and actuators, so the sensors sense the environment and through the actuators it acts.
What is Planning?
Planning is reasoning about future events in order to establish a series of actions
to accomplish a goal.

A common approach to planning is representing a current state and determining


the series of actions necessary to reach the goal state (or vice versa) ,therefore it
could be thought of as a problem solving technique.

Plans are created by searching through a space of possible actions until the
sequence necessary to accomplish the task is discovered.
Planning Components
The key components of planning include:

State Representation
● Defines the current state of the world and how actions modify it.
● Can be represented using:
○ Logical representations (e.g., propositional logic, first-order logic)
○ Structured representations (e.g., STRIPS, PDDL – Planning Domain Definition
Language)
○ Numerical/Probabilistic representations (for uncertain environments)
Actions

● Describes possible operations that an agent can perform.


● Each action has:
○ Preconditions (conditions that must be true before execution)
○ Effects (changes to the state after execution)
● Example (in STRIPS notation- Stanford Research Institute Problem Solver):

Action: Move(A, B) The agent (e.g., a robot) moves from location A to location B.
Preconditions: At(A) ∧ Connected(A, B) The agent must currently be at location A. There must be a
direct path (e.g., a door, road) between A and B.
Effects: ¬At(A) ∧ At(B) The agent is no longer at A. The agent is now at B
Example 1: Propositional Logic (Boolean variables)
● Problem: A robot needs to pick up a package in Room A and deliver it to
Room B.
● State Representation:
○ In(RoomA) → Robot is in Room A (True/False)
○ Holding(Package) → Robot is holding the package (True/False)
● Action: Pick(Package)
○ Precondition: In(RoomA) ∧ ¬Holding(Package)
○ Effect: Holding(Package)
Example 2: First-Order Logic (Variables, quantifiers)
● Problem: A blocks world where a robot stacks blocks.
● State Representation:
○ On(BlockA, BlockB) → BlockA is on BlockB.
○ Clear(BlockX) → Nothing is on top of BlockX.
● Action: Move(x, y, z) (Move block x from y to z)
○ Precondition: On(x, y) ∧ Clear(x) ∧ Clear(z)
○ Effect: ¬On(x, y) ∧ On(x, z) ∧ Clear(y)
Goal
the goal is the desired state (or set of conditions) that the planner must achieve by executing a sequence of
actions. It defines what the world should look like after the plan is successfully carried out.

Fully Specified Goal:


● All required conditions are explicitly stated.
At(Home) ∧ Have(Key)
Partially Specified Goal:
● Only some conditions are given; others are left open.
● Example: Have(Key)
Goals are typically expressed in logical formulas (e.g., propositional logic, first-order logic).
● Common operators:
○ ∧ (AND) → All conditions must be true.
○ ∨ (OR) → At least one condition must be true.
○ ¬ (NOT) → A condition must be false.
Search Space

● The set of possible states and transitions between them.


● Planning algorithms explore this space to find a valid sequence of actions (a plan).
How Planning Algorithms Explore the Search Space

(a) Formal Representation as a Graph


● Nodes: Possible states.
● Edges: Actions that transition between states.
● Goal: A path from the initial state to a goal state.
Example: Robot Navigation (Carry the key from Room A to Room B)
Initial State: {At(RoomA), ¬Holding(Key)}
Goal State: {At(RoomB), Holding(Key)}

Possible Path:
1. State 1 → [PickUp(Key)] → State 2
2. State 2 → [Move(RoomA, RoomB)] → State 3 (Goal)
Planner (Planning Algorithm)
● The computational method used to find a valid plan.
● Common approaches:
○ Forward (Progression) Planning – Starts from the initial state and applies actions
forward.
○ Backward (Regression) Planning – Works backward from the goal state.
○ Heuristic-Based Planning – Uses estimates (heuristics) to guide search (e.g., A*, greedy
search).
○ Hierarchical Planning – Breaks problems into subgoals (e.g., HTN – Hierarchical Task
Networks).
○ Partial-Order Planning – Allows flexible ordering of actions (e.g., least commitment
planning).
○ Probabilistic Planning – For uncertain environments (e.g., MDPs, POMDPs).
Example of Forward (Progression) Planning

Scenario: A robot must pick up a key in RoomA and deliver it to RoomB

World State Representation:


● At(Robot, RoomA): Robot is in RoomA
● KeyIn(RoomA): Key is in RoomA
● DoorOpen(RoomA, RoomB): RoomA connects to RoomB

Goal Conditions:
1. At(Robot, RoomB)
2. Holding(Key)
Step 0: Initial State Possible Actions:
1. PickUp(Key)
State: ○ Preconditions:
{ ■ At(Robot, RoomA) ✔
At(Robot, RoomA), # Robot is in RoomA ■ KeyIn(RoomA) ✔
KeyIn(RoomA), # Key is in RoomA ■ ¬Holding(Key) ✔
¬Holding(Key), # Robot isn't holding the key ○ Valid Action ✅
DoorOpen(RoomA, RoomB) # Door between 2. Move(RoomA, RoomB)
rooms is open ○ Preconditions:
} ■ At(Robot, RoomA) ✔
Decision Point: ■ DoorOpen(RoomA, RoomB) ✔
The planner must choose which action to apply first. ○ Valid Action ✅
● Option 1: Pick up the key → Leads to holding the key.
● Option 2: Move to RoomB → Leaves the key behind
(invalid for goal).
Choice: PickUp(Key) (Only this leads to the goal).
Possible Actions Now:
Step 1: After PickUp(Key)
1. Move(RoomA, RoomB)
Action Applied: PickUp(Key) ○ Preconditions:
Effects: ■ At(Robot, RoomA) ✔
● Adds: Holding(Key) ■ DoorOpen(RoomA, RoomB) ✔
● Removes: KeyIn(RoomA)
○ Valid Action ✅
2. Drop(Key)
○ (Hypothetical action; not useful here)
New State:
Choice: Move(RoomA, RoomB) (Only productive
{
At(Robot, RoomA),
action).
Holding(Key), # Robot now has the key
DoorOpen(RoomA, RoomB),
¬KeyIn(RoomA) # Key no longer in RoomA
}
Step 2: After Move(RoomA, RoomB)

Action Applied: Move(RoomA, RoomB)


Effects: Goal Check:
● Adds: At(Robot, RoomB) ● At(Robot, RoomB) ✔
● Removes: At(Robot, RoomA)
● Holding(Key) ✔
Final State:
Plan Successful!
{
At(Robot, RoomB), # Robot reached RoomB
Holding(Key), # Still has the key
DoorOpen(RoomA, RoomB),
¬KeyIn(RoomA)
}
Why This Sequence Works

1. Order Matters:
○ If the robot moved first (Move → PickUp), it would be in RoomB without the key
→ goal fails.
○ Correct order: PickUp → Move ensures the key is carried to the destination.
2. Dead Ends Avoided:
○ Moving first leads to an unrecoverable state (key left behind).
○ Forward planning explores all paths, eventually discarding dead ends.
Backward (Regression) Planning

Same Problem: A robot must bring a key from RoomA to RoomB.

Key Difference:
● Forward Planning: Starts at the initial state and simulates actions forward.
● Backward Planning: Starts at the goal state and works backward to find required
preconditions.

Goal State:
{
At(Robot, RoomB),
Holding(Key)
}
Step 1: Regress the Goal

The planner asks: "What action could achieve At(Robot, RoomB)?"


Possible Actions:
1. Move(RoomX, RoomB)
○ Effect: At(Robot, RoomB)
○ Precondition: At(Robot, RoomX) ∧ DoorOpen(RoomX, RoomB)
Chosen Action: Move(RoomA, RoomB) (assuming RoomA connects to RoomB).

New Subgoal
{
Goal State:
At(Robot, RoomA),
DoorOpen(RoomA, RoomB) {
} At(Robot, RoomB),
Holding(Key)
}
Step 2: Regress Further

Now, the planner needs At(Robot, RoomA) and Holding(Key).


Question: "What action achieves Holding(Key)?"
Possible Action:
● PickUp(Key)
○ Effect: Holding(Key)
○ Precondition: At(Robot, RoomA) ∧ KeyIn(RoomA) ∧ ¬Holding(Key)
New Subgoals:
{
At(Robot, RoomA),
KeyIn(RoomA), Goal State:
¬Holding(Key) {
} At(Robot, RoomB),
Holding(Key)
}
Step 3: Verify Initial State

Check if the initial state satisfies all subgoals:


● Initial State:
{
At(Robot, RoomA), ✔
KeyIn(RoomA), ✔
¬Holding(Key), ✔
DoorOpen(RoomA, RoomB) ✔
}

Final Plan (Reverse Order)

1. PickUp(Key) (to achieve Holding(Key)).


2. Move(RoomA, RoomB) (to achieve At(Robot, RoomB)).
Result: Same plan as forward planning, but derived backward!
Goal Stack Planning

Goal Stack Planning is a partial-order planning technique that uses a stack to manage goals and subgoals. It
works by decomposing the main goal into smaller subgoals, solving them sequentially, and maintaining a stack to
track pending actions and preconditions.

Example: Blocks World Problem


Initial State:
● Block A is on B.
● Block B is on the Table.
● Block C is on the Table.
📦 State Representation:
On(A, B), On(B, Table), On(C, Table)
Goal State:
● Block C is on A.
● Block A is on B.
● Block B is on the Table.
📦 Goal Representation:
On(C, A), On(A, B), On(B, Table)
Step-by-Step Goal Stack Planning

Step 1: Push All Goal Conditions onto the Stack


The stack initially contains all goal predicates:

Stack: [On(C, A), On(A, B), On(B, Table)]

Step 2: Process the Stack (LIFO Order)


We resolve goals one by one, checking if they are already true in the current state.
1. Check On(B, Table):
○ Current State: On(B, Table) is already true.
○ Action: Remove from stack (no action needed).
Stack: [On(C, A), On(A, B)]

2. Check On(A, B):


○ Current State: On(A, B) is already true.
○ Action: Remove from stack (no action needed).

Stack: [On(C, A)]


Step 4: Achieve Holding(C)
Resolve On(C, A) (Not True in Current State): ● Current State: C is on the table (On(C,
● Subgoal: To achieve On(C, A), we need: Table)).
○ Clear(A) (top of A must be free) ● Action: To hold C, we must perform PICK(C,
○ Holding(C) (robot arm must hold C) Table).
● Push Subgoals: ○ Preconditions for PICK(C, Table):
Stack: [ On(C, A),Holding(C),Clear(A) ] ■ On(C, Table) ✔ (true)
■ Clear(C) ✔ (true, since nothing is
Step 3: Achieve Clear(A) on C)
● Current State: On(A, B) → A is not clear (since ■ ArmEmpty ✔ (true, assuming the
something is on it). robot arm is initially free)
● Subgoal: To make A clear, we must remove what’s on ● Apply PICK(C, Table):
it (C is not on A yet, but we must ensure nothing is on ○ Effects:
A). ■ Add: Holding(C)
● Since nothing is on A in reality, this is already ■ Delete: On(C, Table)
satisfied. ○ New State:
● Action: Pop Clear(A) (no action needed). ■ Holding(C)
■ On(A, B), On(B, Table)
Stack: [ On(C, A),Holding(C)] ● Update Stack:
Stack: [On(C, A)]
Step 5: Achieve On(C, A) Final Plan (Sequence of Actions):
● Current State: Holding(C) and Clear(A)
1. PICK(C, Table) (Pick up C from the table)
(since A has nothing on it).
● Action: Perform STACK(C, A). 2. STACK(C, A) (Place C on A)
○ Preconditions for STACK(C, A):
■ Holding(C) ✔
■ Clear(A) ✔
● Apply STACK(C, A):
○ Effects:
■ Add: On(C, A), ArmEmpty
■ Delete: Holding(C), Clear(A)
● Final State:
○ On(C, A)
○ On(A, B)
○ On(B, Table)
● Stack is now empty → Goal Achieved!
Planning as a State Space Search

Planning in Artificial Intelligence (AI) can be viewed as a state space search problem, where:
● The initial state represents the starting conditions.
● The goal state represents the desired outcome.
● Actions (operators) transform one state into another.
● The solution is a sequence of actions (a path) from the initial state to the goal state.
● Search Tree: To visualize the search issue, a search tree is used, which is a tree-like structure that
represents the problem. The initial state is represented by the root node of the search tree, which is the
starting point of the tree.

Key Components:
1. State – A representation of the world at a given time.
2. Actions – Possible moves or operations that change the state.
3. Transition Model – Defines how actions affect states.
4. Goal Test – Checks if the current state is the goal.
5. Path Cost – Measures the cost of a solution (optional).
Example of State Space Search

The 8-puzzle problem is a commonly used example of a


state space search. It is a sliding puzzle game consisting of
8 numbered tiles arranged in a 3x3 grid and one blank
space. The game aims to rearrange the tiles from their initial
state to a final goal state by sliding them into the blank
space.

To represent the state space in this problem, we use the nine


tiles in the puzzle and their respective positions in the grid.
Each state in the state space is represented by a 3x3 array
with values ranging from 1 to 8, and the blank space is
represented as an empty tile.
The initial state of the puzzle represents
the starting configuration of the tiles, while
the goal state represents the desired
configuration.

Search algorithms utilize the state space to


find a sequence of moves that will
transform the initial state into the goal
state.
Step 3: Add Actions to Achieve Subgoals
Partial Order Planning 1. Action 1: Move(B, C)
○ Effect: On(B, C)
○ Precondition: Clear(B) ∧ Clear(C)
Partial Order Planning is a flexible planning technique 2. Action 2: Move(A, B)
where actions are arranged in a partially ordered ○ Effect: On(A, B)
sequence rather than a strict linear order. ○ Precondition: Clear(A) ∧ Clear(B)
Goal: Stack blocks such that A is on B, and B is on C. Step 4: Establish Causal Links
Initial State: All blocks (A, B, C) are on the table.
● Move(B, C) achieves On(B, C) (part of the goal).
Step 1: Define the Goal ● Move(A, B) achieves On(A, B) (part of the goal).
● Goal Conditions:
Step 5: Check for Threats
○ On(A, B)
● Threat: If Move(A, B) is executed before Move(B,
○ On(B, C)
C), it may make B not clear (since A is on B).
Step 2: Start with an Empty Plan ● Resolution:
● Initial Plan: ○ Order Constraint: Move(B, C) must come
○ Start: { } before Move(A, B).
○ Finish: {On(A,B), On(B,C)}
Step 6: Final Partial Order Plan
● Actions:
○ Move(B, C)
○ Move(A, B)
● Ordering Constraints:
○ Move(B, C) ≺ Move(A, B)
● Causal Links:
○ Move(B, C) → On(B, C)
○ Move(A, B) → On(A, B)

Possible Execution Orders:


1. Move(B, C) → Move(A, B) (Sequential)
2. If no conflicts, some steps could be parallel (but not in this case).
Multi-agent Planning

Multi-Agent Planning involves coordinating multiple autonomous agents to achieve a shared or individual
goal while handling:
● Dependencies between agents' actions.
● Resource conflicts (e.g., two robots needing the same tool).
● Communication constraints (limited/uncertain information sharing).

Key Challenges in MAP:

1. Coordination: Agents must avoid conflicts (e.g., collisions, resource contention).


2. Partial Observability: Agents may not know others' plans fully.
3. Decentralized Control: No single agent has full authority.
4. Scalability: Planning complexity grows exponentially with more agents.
Warehouse Robots (Multi-Agent Pathfinding)

Possible Plans:
Scenario: 1. Naive Plan (No Coordination):
● Two robots (R1 and R2) in a warehouse ○ R1 moves right to (3,1), then up to (3,3).
○ R2 moves down to (3,3), then left to (3,1).
must deliver packages to targets (T1 and
○ Conflict: Both robots try to occupy (3,3) at the same
T2). time → Collision!
● Obstacles (shelves) limit movement. 2. Coordinated Plan (MAP Solution):
● Goal: Minimize delivery time without ○ R1’s Path: (1,1) → (1,2) → (1,3) → (2,3) → (3,3).
collisions. ○ R2’s Path: (1,3) → (2,3) → (3,3) → (3,2) → (3,1).
○ Conflict Avoidance:
Initial State: ■ Agents communicate to reserve space-time
[R1] → Starts at (1,1), needs to reach T1 at (3,3). slots.
■ R1 waits at (1,3) until R2 passes (2,3).
[R2] → Starts at (1,3), needs to reach T2 at (3,1).
Shelves at (2,2) and (2,1).
Hierarchical Planning
Hierarchical Planning is an AI planning technique where complex problems are broken down into smaller,
manageable sub-problems organized in a hierarchy.

Key Concepts

1. Abstraction Levels:
○ High-level (Abstract): Broad goals (e.g., "Build a house").
○ Mid-level: Sub-goals (e.g., "Lay foundation", "Construct walls").
○ Low-level (Concrete): Executable actions (e.g., "Pour concrete", "Install bricks").
2. Advantages:
○ Reduces search space by ignoring irrelevant details early.
○ Enables reusability of sub-plans (e.g., "Construct walls" can be reused in different buildings).
○ Improves scalability for complex problems.
3. Disadvantages:
○ May miss optimal solutions due to abstraction.
○ Requires careful design of hierarchy levels
Planning a Trip from Delhi to Goa Level 3: Low-Level Actions
1. Book Flight:
Level 1: High-Level Goal ○ Search for flights.
○ Compare prices.
"Travel from Delhi to Goa"
○ Make payment.
Level 2: Mid-Level Decomposition 2. Go to Airport:
Choose a travel mode: ○ Pack luggage.
1. By Air → Book flight, go to airport, board ○ Take a taxi to IGI Airport.
plane. ○ Check in at counter.
2. By Train → Book train, go to station, board 3. Board Plane:
train. ○ Pass security.
3. By Road → Rent car, drive via highway. ○ Wait at gate.
Assume we pick "By Air". ○ Enter flight.
Hierarchy Visualization:

"Travel Delhi → Goa"


├── "By Air"
│ ├── "Book Flight" → [Search flights, Pay, Get
ticket]
│ ├── "Go to Airport" → [Pack, Taxi, Check-in]
│ └── "Board Plane" → [Security, Boarding]
├── "By Train"
│ └── ...
└── "By Road"
└── ...
Conditional Plan
Conditional Planning
1. Start at location A with package
Conditional planning is an approach where plans are 2. Navigate along pre-mapped primary route
created with built-in decision points that allow for ○ Condition: If obstacle detected (e.g.,
dynamic adaptation based on changing conditions or construction)
new information. ■ Attempt to navigate around
obstacle
Scenario: A robot needs to deliver a package from point ■ If unsuccessful after 2 attempts:
A to point B in a dynamic urban environment. ■ Switch to secondary route
3. Approach destination building
○ Condition: If main entrance blocked
■ Proceed to secondary delivery
entrance
4. Attempt package delivery
○ Condition: If recipient not available
■ Follow protocol (leave
package/return to base/etc.)
5. Return to home base
During execution, the robot would:
Execution Monitoring 1. Continuously check:
○ Localization accuracy
○ Obstacle sensors
○ Traffic conditions
Execution monitoring is the process of tracking plan
○ Battery level
execution to ensure it's proceeding as expected and
○ Package status
making adjustments when needed. ○ Recipient availability signals
2. Trigger replanning when:
Scenario: A robot needs to deliver a package from point
○ Unexpected blockage on both primary and
A to point B in a dynamic urban environment. secondary routes
○ Sudden weather changes affecting mobility
○ Receiving updated recipient availability information
○ Critical battery level detected
3. Maintain logs of:
○ Plan deviations
○ Decision points activated
○ Environmental conditions
○ Success/failure states
Plan Execution & Monitoring

After a planner generates a sequence of actions (the plan), the agent must execute it in the real world. However, real-world environments are
often dynamic—unexpected changes can occur, requiring monitoring and replanning to ensure success.

Plan Execution
The agent carries out the planned actions step-by-step.

Example: Robot Delivery Task


Plan Generated:
1. PickUp(Package, RoomA)
2. Move(RoomA, RoomB)
3. Drop(Package, RoomB)
Execution:
● The robot picks up the package in RoomA.
● Moves toward RoomB.
● Drops the package in RoomB.
Monitoring (Sensing the Environment)
While executing, the agent continuously checks if the world matches its expectations.

Why Monitoring Matters?


● Unexpected changes may invalidate the plan:
○ A door slams shut (DoorOpen(RoomA, RoomB) becomes false).
○ The package is stolen (Holding(Package) becomes false).
○ A new obstacle appears (e.g., a human blocks the path).

Example of Failure
● During Move(RoomA, RoomB), the robot senses:
○ ¬DoorOpen(RoomA, RoomB) (Door is now closed!).
● Plan is now invalid because the action’s precondition (DoorOpen) is false.
Replanning
If monitoring detects a mismatch, the agent must:
1. Stop execution.
2. Update its world state (e.g., mark the door as closed).
3. Generate a new plan from the current state.

Revised Plan (After Door Closes)

1. Move(RoomA, RoomC) (Take a detour through RoomC).


2. Move(RoomC, RoomB)
3. Drop(Package, RoomB)
Constraints & Optimization Criteria

● Some planning problems involve:


○ Temporal constraints (e.g., actions with durations, deadlines).
○ Resource constraints (e.g., limited fuel, battery).
○ Optimality criteria (e.g., shortest path, least cost).

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