UPI Study › Courses › Introduction to Artificial Intelligence › Free lessons › Lesson 2.7 Free with a free account
Agents That Plan Toward Objectives
Introduction to Artificial Intelligence · Chapter 2: Intelligence, Cognition, and Agent DesignSection 2.7 · lesson 15 of 6915 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Artificial Intelligence.
Lesson complete
Earn the 3 college credits for Introduction to Artificial Intelligence
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Maximizing Outcomes: Utility-Driven Agent Behavior →← How Model-Based Agents Track Their WorldNext lesson: Maximizing Outcomes: Utility-Driven Agent Behavior →
In this lesson
How goal-based agents formulate goals, search for plans, and replan.
- Distinguish reflex agents from goal-based agents
- Formulate a testable goal and write a task as a five-part problem
- Explain how search and planning find action sequences and why their cost grows as b to the power d
- Describe how monitoring and replanning handle surprises during execution
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (2,216 words). Read along, or search it.
Opening Question
A Navigation App Versus a Thermostat
Ask a navigation app for directions to a place you've never been. Nobody wrote a rule saying: at junction 14, when heading for the airport, turn left. It takes your destination and its map, and works out a route by thinking about where each road leads. Now take a household thermostat. It has no destination. It just switches the heat on when the room is too cold. The thermostat reacts. The app plans toward a goal. So how does an agent choose a goal, find the actions that reach it, and decide when planning is worth its cost?
Reflex Agents
Acting Without Asking Where It Leads
An agent senses its surroundings and acts on them. Agents differ in how they choose the next action, and two ways stand out. A reflex agent chooses using only what it senses right now. Its knowledge is a list of condition-action rules: if this is happening, then do that. Pulling your hand back from a hot stove is a reflex. So is an automatic door that opens when it detects a person. Reflexes are fast and simple, but they never ask: where will this action lead? Even with a memory, an agent with no goal is still a reflex agent.
Goal-Based Agents
A Goal Plus a World Model
A goal-based agent chooses actions by asking whether they help it reach a goal: a description of the situation it wants to bring about. Planning a trip works this way: you consider a sequence of steps, and where it ends. For that, an agent needs two ingredients. A goal: what it's trying to achieve. And a world model: how actions change the situation, like: this road reaches the next junction in four minutes.
Goal Formulation
Deciding What Counts as Success
Before planning, an agent must decide what it's trying to achieve. That's goal formulation: deciding which states of the world count as success. Goals matter for three reasons. They narrow the choices. If the goal is reach the airport, ordering a pizza isn't worth considering. They define success. Without a target, no action is better than any other. And they allow progress checks. Am I there yet? That check is called a goal test.
Well-Formed Goals
Specific, Testable, Achievable, Relevant
A usable goal has four qualities. It's specific, testable, achievable with the actions available, and relevant to what the agent is for. Most wishes fail. Get healthy can't be checked. A testable version: walk at least 8,000 steps before 9 p.m. today. Deliver the parcel soon fails too, because soon can't be checked. Better: parcel handed to the person in Room 305 within 15 minutes. And get to a good restaurant depends on opinion. Better: be seated at the Corner Bistro at 7 p.m.
Sub-Goals
Splitting Large Goals and Their Sources
Large goals split into sub-goals. Deliver a parcel across town becomes: collect it, reach the main road, reach the right building, and hand it over. Each one is easier to plan for, and reaching them in order achieves the whole. Goals come from three places. A designer gives them: keep the warehouse tidy. A user requests them: take me to the station. Or the agent's own situation produces them. A robot with a low battery sets the goal: reach the charger. And goals can change as the situation changes.
Problem Formulation
Five Parts of a Planning Problem
Once the goal is set, the agent writes the task as a problem with five parts. Take the goal: get from home to the airport. The initial state: where does it start? At home. The actions: what can it do? Drive along a road to the next junction. The transition model: what results from an action? Driving from junction 4 to junction 5 leaves it at junction 5. The goal test: is it at the airport? And the path cost: how is a whole sequence scored? Here, by total driving time. All the states it could reach make up the state space. Planning means finding a path through it, to a state that passes the goal test.
Search
Exploring Possible Futures in the Model
How does it find that path? Picture yourself at a station, heading to a friend's house. You don't just start walking. You think: if I take the bus, I reach the market. If I walk, I reach the park. From the market, I could take a tram. You're exploring possible futures in your head. An agent does the same with its world model. This is called search: looking through possible action sequences for one that ends in a goal state. The answer isn't just the final state. It's the whole sequence of actions that gets there. And searching in the model is cheap. A dead end is far cheaper to find in imagination than on the road, where mistakes can be slow, costly, or impossible to undo.
Search Versus Planning
Single Labels Versus Sets of Facts
Two names are used for finding action sequences. They differ in how the world is described. Search treats each state as a single label, like junction C, and each action as a move with a cost. That's ideal for maps and routes. Planning describes a state as a set of facts, like: I'm at the door, and the door is locked. Each action has preconditions, what must be true first, and effects, what it changes. So a planner can reason about why an action is needed. It suits assembling, unlocking and scheduling: tasks with many steps and conditions.
Worked Example
Working Backward From a Locked Door
Here's planning at work. You're in a hall, and your goal is to be in the study room. The door is locked, and the key is on a table. A planner can work backward from the goal. To be in the study room, the door must be unlocked. To unlock it, I need the key, and I must be at the door. The key is on the table, so I must get it first. Read that chain from the start, and you have the plan. Walk to the table. Pick up the key. Walk to the door. Unlock it. Open it, and go in. Each step's preconditions come from the effects of earlier steps.
Execution
Execute, Monitor, and Replan
Finding a plan is only part of the job. The agent must carry it out, in a world that may not behave as predicted. So the full cycle runs like this. Formulate the goal. Formulate the problem. Search for a plan. Then execute it, while monitoring what happens. Plans work best when three things hold. The agent knows what its actions do, outcomes are predictable, and the world stays still while it thinks. When one fails, say a road is closed, monitoring notices the surprise, and the agent replans from where it is now. Some agents also keep contingency plans: if the door is already unlocked, skip that step. Without monitoring, one surprise can ruin every later step.
Two Costs
Cost of the Plan and of Planning
Cost means two things here. First, the cost of the plan: some plans that reach the goal take less time, distance, money, or energy. The path cost lets the agent prefer the cheapest one. Second, the cost of planning. Searching takes computing time and memory, and the number of possible sequences grows very fast.
Branching Factor
b to the Power d Sequences
How fast? If an agent has b possible actions at each step, a plan of d steps has b times b times b, d times over. That's b to the power d sequences. The number b is called the branching factor. With two choices per step, five steps give 32 sequences. Ten steps give 1,024. Twenty steps give over a million. With ten choices per step, twenty steps give a one followed by twenty zeros. That explosion is why real agents can't list every possibility. They search cleverly, or settle for a plan that's good enough in the time available.
Quick Check
Looking Four More Steps Ahead
Quick check. A warehouse robot has 4 possible actions at every step. Its planner used to look 8 steps ahead. Now it looks 12 steps ahead. How many times more action sequences must it consider? Pause, and decide. C: two hundred fifty-six times as many. There are four extra steps, and each multiplies the count by four: four to the power four is two hundred fifty-six. In full: 4 to the 8th is 65,536 sequences, and 4 to the 12th is 16,777,216. One and a half times is the tempting answer, because twelve is one and a half times eight. But steps multiply the choices. They don't add to them.
Strengths
Why Goal-Based Agents Are Flexible
Now weigh the two designs. Goal-based agents win on flexibility. Change the goal, not the program: a navigation app handles any destination with the same planner. They handle new situations. If a road is closed, the planner uses its map to find another way. They look ahead, so they avoid dead ends. A reflex cleaning robot can bounce back and forth between two walls forever. And they can explain their choices: I turned left, because this route is the fastest.
Reflex Cost
A Rule for Every Destination Pair
A reflex version pays for every destination. To serve every start-and-destination pair, it needs a separate rule for each pair: N times one less than N rules, for N places. Six places need 30 rules. A hundred places need 9,900. Ten thousand places need 99,990,000 rules. The goal-based agent needs only a map, and a goal. But flexibility isn't free. A planner is slower, it needs an accurate model, and a wrong model gives a wrong plan. A reflex acts almost instantly.
Combining Designs
Planners With a Reflex Safety Layer
So most practical systems use both. In a self-driving car, a planner chooses the route, and when to change lanes. But if a child steps into the road, there's no time to search. A fast, reflex-like safety layer brakes at once, and overrides the plan. In general, prefer reflexes when the right action is clear from what's sensed now, speed matters most, and there are few situations. Prefer planning when the right action depends on where it leads, several steps are needed, or goals change.
Worked Example
A Parcel Robot Sets Its Goal
Now run the whole cycle on one example. A robot must carry a parcel from the mailroom, M, to Room 305, G. Between them are four junctions: A, B, C, and D. Each corridor is labeled with its travel time, in minutes. Step one, the goal: parcel in Room 305 within 15 minutes of leaving the mailroom. It's specific, testable with the robot's position and clock, and achievable. Step two, the problem. It starts at M, at minute zero. Its actions are moves along corridors. The goal test: at G, within 15 minutes. The path cost: total minutes.
Searching Routes
Thirteen Routes, One Best Plan
Step three, search. With only six places, we can list every route that never revisits a junction. There are 13. Nine of the 13 meet the 15-minute goal, and four miss it. The goal splits plans into success and failure. Among the nine, the path cost picks the best: M, B, A, D, C, G, at 10 minutes. Notice that it takes five steps. The three-step routes cost 12, 13 and 15 minutes. Counting steps isn't the same as counting cost. Real maps have millions of junctions, so listing every route is impossible. Smarter search methods, later in the course, find the best one without checking them all.
Monitoring
A Corridor Closed for Cleaning
Step four: execute and monitor. The robot sets off along M, B, A. After 3 minutes, 2 for M to B and 1 for B to A, it reaches A. There, its sensors report that the A-D corridor is closed for cleaning. The plan no longer works, so the robot doesn't carry on blindly.
Quick Check
Replanning From Junction A
Quick check. The robot is at A, at minute 3, the A-D corridor is closed, and the deadline is still minute 15. Which route should it take now? Route one: A, C, G. Route two: A, C, D, G. Route three: A, B, D, G. Pause, and decide. Route one: A, C, G. That's 6 plus 3, so 9 more minutes, and the robot arrives at minute 12, three minutes inside the deadline. Route two also makes it, at minute 15, but it costs three minutes more. It's tempting, because it still passes through D, like the old plan. Route three arrives at minute 17: too late. And nobody rewrote a rule. The same map and the same goal produced a new plan.
Comparison
A Reflex Robot Stuck on Old Rules
Compare a reflex robot. It carries a table of what to do at each junction, for each destination: 30 rules here, and 9,900 for a hundred junctions. A rule like: at A, heading for G, take A-D, sends it into the closed corridor again and again, until someone edits the table by hand.
Remaining Limit
Goals Cannot Rank Good Outcomes
One limit remains, for planners too. A goal is a yes-or-no target: reached, or not. It can't say that arriving calm beats arriving with seconds to spare, or how to choose when two goals pull different ways. That takes preferences, measured as numbers.
Key Takeaways
Goals, Problems, Search, and Replanning
To sum up. A reflex agent reacts to what it senses. A goal-based agent looks ahead, using a goal and a world model. Goal formulation turns a wish into a testable target, and the task becomes a five-part problem. Search and planning find an action sequence in the model first. Monitoring catches surprises, and the agent replans. Planning is flexible but costly, because sequences grow as b to the power d. So real systems combine reflexes and planning.
Reflection
A Hospital Robot and a Broken Lift
Here's something to think about. A hospital delivery robot plans its routes. At 3 a.m., the lift is out of service, and nobody has told the robot. How should a good design discover this, and what should the robot do next? And for which of its tasks would you not want it to stop and plan?
About Introduction to Artificial Intelligence at UPI Study
Introduction to Artificial Intelligence (Computer Science 373) is a self-paced online course of 69 video lessons in 9 chapters, from intelligent agents and search to game strategy, neural networks, logic and reasoning, machine learning, language, robotics and AI ethics. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: AI vs Current Trends in CS and IT
Why take it here
Why students take Introduction to Artificial Intelligence with UPI Study
Where the credit goes
Universities that work with NCCRS
Introduction to Artificial Intelligence carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Agents That Plan Toward Objectives
What is a goal-based agent in AI?
What are the five parts of a problem formulation in AI?
Why does planning get expensive as plans get longer?
What is the difference between search and planning in AI?
About the Introduction to Artificial Intelligence course
How many college credits is Introduction to Artificial Intelligence?
How much does Introduction to Artificial Intelligence cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Artificial Intelligence take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Introduction to Artificial Intelligence.
69 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
3 credits · NCCRSEnroll →