Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Module 5 (Planning and Learning)

What is planning in AI
In artificial intelligence (AI), planning refers to the process of generating a
sequence of actions to achieve a desired goal or set of goals in a complex
environment. It involves reasoning about the current state of the world,
identifying possible actions that can be taken, and selecting the most appropriate
actions to achieve the desired outcomes while considering constraints and
uncertainties.

Key Components of Planning:

1. Initial State: The starting configuration of the world, including the


current state of objects, entities, and their properties.
2. Goals: The desired outcomes or conditions that the planner aims to
achieve. Goals specify the state of the world that the planner seeks to
reach.
3. Actions: Atomic operations or activities that can be performed to modify
the state of the world. Each action has preconditions (conditions that must
be true for the action to be applicable) and effects (changes that the action
brings about in the world).
4. Constraints: Restrictions or limitations that must be adhered to during
planning. Constraints may include resource constraints, temporal
constraints, or domain-specific rules.

Planning Process:

1. State Representation: The planner represents the state of the world


using a formal language or representation scheme, typically based on
logic or mathematical models. This representation captures the properties
and relationships of objects and entities in the environment.
2. Search and Reasoning: The planner searches through the space of
possible actions and states to find a sequence of actions that leads from
the initial state to a state that satisfies the goals. This search may involve
exploring different paths, considering trade-offs, and evaluating the
suitability of actions based on various criteria.
3. Plan Generation: Based on the search and reasoning process, the planner
generates a plan a sequence of actions that, when executed, will achieve
the desired goals. The plan specifies the order in which actions should be
taken and the conditions under which they should be executed.
4. Plan Execution: The plan is executed in the real-world environment, and
actions are carried out according to the plan. During execution, the
planner may monitor the state of the environment, handle uncertainties,
and adapt the plan as needed based on new information or unexpected
events.

Applications of Planning in AI:

1. Robotics: Planning is used to generate sequences of actions for


autonomous robots to perform tasks such as navigation, manipulation,
and assembly in dynamic environments.
2. Logistics and Supply Chain Management: Planning is employed to
optimize the routing and scheduling of transportation vehicles, inventory
management, and resource allocation in logistics networks.
3. Game Playing: Planning algorithms are used in game playing AI to
search for optimal strategies and sequences of moves in games such as
chess, Go, and video games.
4. Natural Language Understanding: Planning techniques are applied to
infer intentions, goals, and plans from natural language input, facilitating
human-computer interaction and dialogue systems.

Forward state-space planning in AI


Forward state-space planning is a technique in artificial intelligence used
to generate plans byexploring possible sequences of actions starting from
the initial state of the environment and proceeding towards the goal state.
It involves systematically searching through the space of possible states
and actions to find a sequence of actions that leads from the initial state to
the goal state. Let's explore forward state-space planning in AI along with
an example to illustrate its application.
Forward State-Space Planning in AI: Explanation
Forward state-space planning involves the following steps:
1. State Representation: The planner represents the state of the
environment using a state space, where each state represents a
configuration of the environment. The initial state is the starting
configuration, and the goal state is the desired configuration.
2. Action Representation: The planner represents actions available to the
agent, along with their effects on the environment. Each action can
change the state of the environment from one configuration to another.
3. Search Algorithm: The planner uses a search algorithm to explore the
space of possible states and actions. Common search algorithms used in
forward state-space planning include depth-first search, breadth-first
search, and A* search. These algorithms systematically traverse the state
space, considering different sequences of actions until a plan leading to
the goal state is found.
4. Heuristics (Optional): In some cases, the planner may use heuristics to
guide the search process and prioritize certain states or actions over
others. Heuristics provide estimates of how close a state is to the goal
state and help to focus the search on promising regions of the state space.
Example of Forward State-Space Planning
Consider a simple scenario where a robot needs to navigate through a grid
world to reach a goal location. The robot can move in four directions: up,
down, left, and right. The grid world is represented as a 2D grid, where
each cell represents a state, and the robot's position in the grid represents
the current state.
The initial state of the environment is the robot's starting position, and the
goal state is the location of the goal. The planner can use forward state-
space planning to generate a sequence of actions that leads the robot from
the initial position to the goal position.
For example, if the robot's initial position is (0, 0) and the goal position is (3,
3), a possible plan generated by forward state-space planning might be:
1. Move right
2. Move right
3. Move down
4. Move down
In this plan, the robot moves right twice to reach the fourth column of the
grid and then moves down twice to reach the fourth row, ultimately
reaching the goal position at (3, 3).

State-Space Planning in AI
Backward state-space planning

Backward state-space planning is a technique in artificial intelligence used to


generate plans by starting from the goal state and working backward to
determine the sequence of actions needed to reach the goal from the initial state.
It involves reasoning about the effects of actions in reverse, from the goal state
to the initial state. Let's explore backward state-space planning in AI along with
an example to illustrate its application.

Backward State-Space Planning in AI: Explanation

Backward state-space planning involves the following steps:

1. Goal Specification: The planner starts with a description of the goal


state, representing the desired configuration of the environment. This goal
state serves as the starting point for planning.
2. Action Representation: The planner represents actions available to the
agent, along with their effects on the environment. Each action is defined
in terms of its preconditions (conditions that must be true for the action to
be applicable) and effects (changes that the action brings about in the
environment).
3. Search Algorithm: The planner uses a search algorithm to work
backward from the goal state to the initial state, considering different
sequences of actions that lead to the goal state. Common search
algorithms used in backward state-space planning include backward
search, goal regression, and means-ends analysis.
4. Heuristics (Optional): In some cases, the planner may use heuristics to
guide the search process and prioritize certain actions over others.
Heuristics provide estimates of how close a state is to the goal state and
help to focus the search on promising regions of the state space.

Example of Backward State-Space Planning

Consider a simple scenario where a robot needs to reach a goal location in a


grid world. The robot can move in four directions: up, down, left, and right. The
goal state is the desired location of the robot, and the initial state is the robot's
current position in the grid.

To generate a plan using backward state-space planning, the planner starts with
the goal state and works backward to determine the sequence of actions needed
to reach the goal from the initial state.
For example, if the goal state is (3, 3) and the robot's initial position is (0, 0), a
possible plan generated by backward state-space planning might be:

1. Move down
2. Move down
3. Move right
4. Move right

In this plan, the robot starts at the initial position (0, 0) and moves down twice
to reach the fourth row of the grid, then moves right twice to reach the fourth
column of the grid, ultimately reaching the goal position at (3, 3).

(1) Example (Air cargo problem)


The Air Cargo problem is a classic example used in AI planning and logistics. It
involves determining the optimal plan for loading and delivering cargo using a
fleet of airplanes and a set of airports. The goal is to transport cargo from an
initial location to a destination location while adhering to various constraints.

Problem Description:

1. Cargo: There are multiple pieces of cargo that need to be transported


from their initial location to their destination location.
2. Airplanes: There is a fleet of airplanes available for transporting cargo.
Each airplane has a limited capacity.
3. Airports: There are multiple airports where cargo can be loaded and
unloaded. Each airport has a limited capacity for cargo and airplanes.
4. Constraints: There are various constraints such as cargo requirements,
airplane capacities, and airport capacities that must be satisfied during
transportation.

Example:

Consider the following scenario:

 Cargo: C1, C2, C3


 Airplanes: P1, P2
 Airports: SFO (San Francisco), JFK (New York), ATL (Atlanta)
 Constraints:
 Cargo C1 needs to be transported from SFO to JFK.
 Cargo C2 needs to be transported from SFO to ATL.
 Cargo C3 needs to be transported from JFK to ATL.
 Each airplane can carry only one piece of cargo.
 Each airport can accommodate only one airplane at a time.
Solution Using AI Planning:

1. State Representation: Define the initial state, goal state, and possible
actions. For example, the initial state might represent the cargo, airplanes,
and airports at their starting locations. The goal state represents the cargo
at their destination locations. Actions include loading cargo onto
airplanes, flying airplanes between airports, and unloading cargo at
airports.
2. Search Algorithm: Use a planning algorithm such as forward state-space
search or backward state-space search to generate a plan that satisfies the
goal state. The planner explores possible sequences of actions,
considering constraints and dependencies between actions.
3. Plan Execution: Execute the plan by carrying out the actions in the
specified sequence. Monitor the state of the environment and adapt the
plan as needed based on changes or unexpected events.

Example Plan:

A possible plan generated by the planning algorithm might look like this:

1. Load C1 onto P1 at SFO.


2. Fly P1 from SFO to JFK.
3. Unload C1 from P1 at JFK.
4. Load C2 onto P2 at SFO.
5. Fly P2 from SFO to ATL.
6. Unload C2 from P2 at ATL.
7. Load C3 onto P2 at JFK.
8. Fly P2 from JFK to ATL.
9. Unload C3 from P2 at ATL.

(2) Example (Water Jug problem)


The water jug problem can also be approached using planning techniques,
where the goal is to generate a sequence of actions to achieve the desired
outcome. Let's outline how the water jug problem can be solved using planning
in AI:

Problem Description:

 Jugs: There are two jugs of known capacities, Jug A and Jug B.
 Initial State: Both jugs are initially empty.
 Goal: Achieve a specific target amount of water in one of the jugs.
 Actions: The following actions are allowed:
1. Fill Jug A
2. Fill Jug B
3. Empty Jug A
4. Empty Jug B
5. Pour from Jug A to Jug B
6. Pour from Jug B to Jug A

Planning Approach:

1. State Representation: Represent the state of the world as a tuple


indicating the amount of water in each jug (e.g., (0, 0) represents both
jugs empty, (3, 0) represents Jug A with 3 units of water and Jug B
empty).
2. Goal Specification: Define the goal state as the desired amount of water
in one of the jugs.
3. Action Representation: Define the actions as operators that change the
state of the world (e.g., filling a jug, emptying a jug, pouring water
between jugs).
4. Search for Plan: Use a planning algorithm to search for a sequence of
actions that transform the initial state into the goal state. This could
involve using techniques such as forward state-space search, backward
state-space search, or heuristic search.

Example:

Let's consider a scenario where Jug A has a capacity of 4 units and Jug B has a
capacity of 3 units. The goal is to measure exactly 2 units of water using these
two jugs.

Plan Generation:

1. Fill Jug A (State: (4, 0))


2. Pour from Jug A to Jug B (State: (1, 3))
3. Empty Jug B (State: (1, 0))
4. Pour from Jug A to Jug B (State: (0, 1))
5. Fill Jug A (State: (4, 1))
6. Pour from Jug A to Jug B (State: (2, 3))

(1) Partial Order Planning


Partial order planning is a technique in artificial intelligence (AI) used for
generating plans to achieve goals in dynamic environments. It allows actions to
be executed in any order, as long as certain constraints are satisfied, offering
flexibility and efficiency in planning.
Partial order planning involves representing plans as directed acyclic graphs
(DAGs), where nodes represent actions, and edges represent relationships
between actions such as causal links, ordering constraints, and resource
constraints.

 Causal Links: Dependencies between actions where the effect of


one action is a precondition for another action.
 Ordering Constraints: Temporal order in which actions must be
executed.
 Resource Constraints: Limitations on resources needed to execute
actions.

Partial order planning typically comprises the following steps:

1. Action Representation: Actions are defined with preconditions


and effects. Preconditions are conditions that must be true for an
action to be executed, while effects describe the changes brought
about by the action.
2. Goal Specification: Goals are specified as conditions representing
the desired state. The planner aims to achieve these conditions.
3. Plan Generation: The planner generates a partial order plan by
selecting actions and arranging them in a DAG based on
dependencies and constraints. Various search techniques like
forward state-space search or heuristic search may be employed.
4. Plan Execution: Once a plan is generated, actions are scheduled
according to the constraints. Conflicts and resource constraints may
need to be resolved during execution.

Partial order planning offers advantages such as flexibility, robustness, and


adaptability to changing environments.

Example of Partial Order Planning

Consider a scenario where a robot needs to prepare a meal. The actions


available to the robot are:

1. Chop Vegetables: Cut vegetables for the dish.


2. Boil Water: Heat water to boiling point.
3. Cook Pasta: Cook pasta in boiling water.
4. Saute Vegetables: Cook chopped vegetables in a pan.
5. Mix Sauce: Prepare the sauce for the dish.

The goal is to prepare a pasta dish. Using partial order planning, the following
plan could be generated:

 Chop Vegetables
 Boil Water
 Cook Pasta
 Saute Vegetables
 Mix Sauce

In this plan, actions can be executed in any order as long as dependencies are
satisfied:

 Chop Vegetables and Boil Water can be performed concurrently.


 Cook Pasta depends on Boil Water being completed.
 Saute Vegetables depends on Chop Vegetables being completed.
 Mix Sauce can be performed independently.

Partial order planning is a powerful technique in AI, offering flexibility and


efficiency in generating plans for achieving goals in dynamic environments.
The example provided demonstrates how partial order planning can be applied
to real-world scenarios.

(2) Hierarchical Planning


Hierarchical planning is a methodology in artificial intelligence that breaks
down complex planning problems into a hierarchy of subproblems, allowing for
more efficient planning and execution. It involves organizing tasks into levels of
abstraction, where higher-level goals are decomposed into smaller, more
manageable subgoals.

Example of Hierarchical Planning

Consider a scenario where a robot needs to clean a room. The high-level goal is
to achieve a clean room, which can be decomposed into several intermediate
goals:

1. High-Level Goal: Clean Room


 Intermediate Goal 1: Vacuum Floor
 Primitive Action: Move Vacuum Cleaner
 Primitive Action: Turn On Vacuum Cleaner
 Primitive Action: Vacuum Floor
 Intermediate Goal 2: Dust Furniture
 Primitive Action: Move Dusting Cloth
 Primitive Action: Dust Furniture
 Intermediate Goal 3: Organize Items
 Primitive Action: Pick Up Items
 Primitive Action: Arrange Items

In this example, the high-level goal of cleaning the room is decomposed into
three intermediate goals: vacuuming the floor, dusting furniture, and organizing
items. Each intermediate goal is further decomposed into primitive actions that
can be directly executed by the robot.

Hierarchical planning is a powerful technique in AI for organizing and solving


complex planning problems. By breaking down tasks into smaller subproblems,
hierarchical planning enables more efficient planning and execution. The
example provided demonstrates how hierarchical planning can be applied to
real-world scenarios to achieve complex goal

(3) Conditional Planning in AI


Conditional planning is a method used in artificial intelligence to generate plans
that can adapt to changes in the environment or to different initial conditions. It
involves considering various possible scenarios and selecting actions based on
the conditions observed during plan execution.

Conditional Planning in AI: Explanation

Conditional planning involves incorporating conditional statements or branches


into the planning process. These conditional statements allow the planner to
consider different possible states of the environment and select appropriate
actions based on those states.

The steps involved in conditional planning typically include:

1. State Representation: The planner represents the state of the


environment, including both the current state and possible future states
based on different scenarios or conditions.
2. Action Selection: The planner selects actions based on the observed state
of the environment and the desired goals. These actions may be chosen
from a set of available actions or dynamically generated based on the
current conditions.
3. Branching: Conditional statements or branches are introduced into the
plan to handle different scenarios or conditions. These branches allow the
planner to adapt the plan based on changes in the environment or
unexpected events.
4. Plan Execution: The plan is executed, and actions are selected
dynamically based on the observed state of the environment. If the
environment changes or new information becomes available during plan
execution, the planner may branch to a different part of the plan to adapt
to the new conditions.

Example of Conditional Planning

Consider a scenario where a robot needs to navigate through a maze to reach a


goal location. The robot's sensors provide information about the walls and
obstacles in the maze. The robot's plan may involve the following conditional
branches:

1. If there is a wall in front of the robot:


 If the left path is clear, turn left.
 If the right path is clear, turn right.
 If both left and right paths are blocked, turn around.
2. If the goal location is within reach:
 Move towards the goal location.

In this example, the robot's plan includes conditional branches to handle


different scenarios encountered while navigating the maze. The robot
dynamically selects actions based on the observed state of the environment,
allowing it to adapt its plan to changes in the maze layout or obstacles
encountered along the way.

Conditional planning is a versatile technique in AI that allows planners to


generate adaptive plans capable of handling changes in the environment or
unexpected events.

You might also like