AA228V/CS238V
Validation of Safety-Critical Systems
Lecture 06/07: Falsification Through Planning
Sydney Katz (smkatz@stanford.edu)
Why do we save our work periodically?
SAVE
Sometimes, it is easier to iteratively build something up than to do it all at once.
From last lecture:
minimize
subject to
minimize
This optimization problem typically involves searching over a very high-dimensional space.
e.g.  inverted pendulum:  
For depth , the search space is -dimensional!
Planning algorithms allow us to iteratively build up a trajectory instead.
Plan for Today
1
Tree Search
2
Heuristic Search
3
Monte Carlo Tree Search
4
Reinforcement Learning
5
Simulator Requirements
Tree Search
Tree Search
The type of tree we are actually talking about in this lecture…
The type of tree we are actually talking about in this lecture…
Continuum World
A typical iteration of a tree search algorithm:
A typical iteration of a tree search algorithm:
A typical iteration of a tree search algorithm:
A typical iteration of a tree search algorithm:
Current Tree
Select
Extend
A typical iteration of a tree search algorithm:
Select
Extend
A typical iteration of a tree search algorithm:
Select
Extend
Tree search algorithms
differ from one another in
how they implement the
select and extend steps.
Plan for Today
1
Tree Search
2
Heuristic Search
3
Monte Carlo Tree Search
4
Reinforcement Learning
5
Simulator Requirements
Heuristic Searchalgorithms use heuristics to explore the space of possible trajectories.
Rapidly Exploring Random Trees (RRT)
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
(e.g. distance to goal)
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
We didn’t find any failures!
Rapidly Exploring Random Trees (RRT)
1
Select
2
Extend
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
A.Select disturbance
B.Take a step from the selected node
using the selected disturbance
C.Add result to the tree
We didn’t find any failures!
We could run for longer…
Or we could make some improvements to our algorithm!
Rapidly Exploring Random Trees (RRT)
Or we could make some improvements to our algorithm!
1
Select
2
Extend
Instead of sampling a goal state from anywhere in the state
space, we sample a goal state from the failure region.
Note: not all systems have an easily
identifiable failure region.
Instead of sampling a random disturbance, select the
disturbance that will move us closest to the goal state.
Rapidly Exploring Random Trees (RRT)
Or we could make some improvements to our algorithm!
1
Select
2
Extend
Instead of sampling a goal state from anywhere in the state
space, we sample a goal state from the failure region.
Note: not all systems have an easily
identifiable failure region.
Instead of sampling a random disturbance, select the
disturbance that will move us closest to the goal state.
Rapidly Exploring Random Trees (RRT)
Or we could make some improvements to our algorithm!
We found a failure!
Rapidly Exploring Random Trees (RRT)
Other Common Heuristics
Coverage Metrics
Alternative Objectives
Rapidly Exploring Random Trees (RRT)
Other Common Heuristics
Coverage Metrics
Alternative Objectives
Advanced Topic 🫤
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
1
Select
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
1
Select
A.Sample goal state
B.Compute objective for each node in
the current tree based on the goal
state
C.Select the node with the lowest
objective
From Before
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
We don’t know this! If we did, our
problem would already be solved.
We instead must estimate it using a
heuristic function .
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Shortest Path to Failure
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Shortest Path to Failure
current costdistance to current node in tree
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Shortest Path to Failure
current costdistance to current node in tree
cost to godistance to goal “as the crow flies”
🤔Which node would we extend next?
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Shortest Path to Failure
current costdistance to current node in tree
cost to godistance to goal “as the crow flies”
🤔Which node would we extend next?
Most Likely Failure
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Most Likely Failure
current costnegative log likelihood of trajectory so far
Note: costs must be positive to
ensure that the search will terminate.
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Most Likely Failure
current costnegative log likelihood of trajectory so far
cost to goestimate of negative log-likelihood to go
e.g. could use distance to goal as a
proxy since shorter paths tend to
have higher likelihood
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
Shortest Path to Failure
current costdistance to current node in tree
cost to godistance to goal “as the crow flies”
Most Likely Failure
current costnegative log likelihood of trajectory so far
cost to goestimate of negative log-likelihood to go
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
If the heuristic is admissible and the state and disturbances are
discrete, this algorithm turns into A* search!
A heuristic is admissible if it is guaranteed to never overestimate the cost of reaching the goal state.
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
If the heuristic is admissible and the state and disturbances are
discrete, this algorithm turns into A* search!
A heuristic is admissible if it is guaranteed to never overestimate the cost of reaching the goal state.
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
If the heuristic is admissible and the state and disturbances are
discrete, this algorithm turns into A* search!
A heuristic is admissible if it is guaranteed to never overestimate the cost of reaching the goal state.
Rapidly Exploring Random Trees (RRT)
We can incorporateAlternative Objectivesinto RRT by modifying how we compute the objectives in the select step.
Cost Function
current costcost to go
If the heuristic is admissible and the state and disturbances are
discrete, this algorithm turns into A* search!
A heuristic is admissible if it is guaranteed to never overestimate the cost of reaching the goal state.
Shortest Path
Most Likely Failure
Plan for Today
1
Tree Search
2
Heuristic Search
3
Monte Carlo Tree Search
4
Reinforcement Learning
5
Simulator Requirements
Monte Carlo Tree Search
Balances between exploration and exploitation
We will determine promising paths by maintaining a value estimate for each node in the tree.
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
yes
select it and go to
extend step
no
move to child node
that minimizes
hyperparameters
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
yes
select it and go to
extend step
no
move to child node
that minimizes
Lower Confidence Bound (LCB)
This is the part that balances
between exploration and
exploitation!
Monte Carlo Tree Search
Lower Confidence Bound (LCB)
This is the part that balances
between exploration and
exploitation!
exploitation
exploration
exploration bonus
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
yes
select it and go to
extend step
no
move to child node
that minimizes
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
yes
select it and go to
extend step
no
move to child node
that minimizes
e.g.
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
yes
select it and go to
extend step
no
move to child node
that minimizes
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
yes
select it and go to
extend step
no
move to child node
that minimizes
e.g.
Monte Carlo Tree Search
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
yes
select it and go to
extend step
no
move to child node
that minimizes
e.g.
Monte Carlo Tree Search
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
When we add a new node to the
tree, we need to estimate its value .
e.g. perform a bunch of rollouts and
take the average of their robustness.
Monte Carlo Tree Search
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
When we add a new node to the
tree, we need to estimate its value .
e.g. perform a bunch of rollouts and
take the average of their robustness.
Monte Carlo Tree Search
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
When we add a new node to the
tree, we need to estimate its value .
e.g. perform a bunch of rollouts and
take the average of their robustness.
Monte Carlo Tree Search
2
Extend
Sample a disturbance, add it to the
tree, and propagate the results
back up the tree.
1
Select
Select a node to extend based on
a heuristic that balances between
exploration and exploitation.
When we add a new node to the
tree, we need to estimate its value .
e.g. perform a bunch of rollouts and
take the average of their robustness.
Repeat!
Monte Carlo Tree Search
Plan for Today
1
Tree Search
2
Heuristic Search
3
Monte Carlo Tree Search
4
Reinforcement Learning
5
Simulator Requirements
Reinforcement Learning
System
Adversary
Reinforcement Learning
System
Adversary
🤔Does this set up remind you of anything?
We can use reinforcement learning
algorithms to train an adversary to
cause a system to fail!
Reinforcement learning!
Why?Many reinforcement learning algorithms are designed to be sample efficient.
It can also generalize to different initial states.
Reinforcement Learning
Reinforcement Learning
2,500 Training Steps
35,000 Training Steps
50,000 Training Steps
65,000 Training Steps
Reinforcement Learning
Using MCTS or reinforcement learning to search for the most likely failure of a
system is often referred to as adaptive stress testing.
Reinforcement Learning
Using MCTS or reinforcement learning to search for the most likely failure of a
system is often referred to as adaptive stress testing.
Plan for Today
1
Tree Search
2
Heuristic Search
3
Monte Carlo Tree Search
4
Reinforcement Learning
5
Simulator Requirements
Simulator Requirements
How do I pick a falsification method?
Plan for Today
1
Tree Search
2
Heuristic Search
3
Monte Carlo Tree Search
4
Reinforcement Learning
5
Simulator Requirements