Library/Interface
This section details the interface and functions provided by POMDPStressTesting.jl.
Contents
Index
POMDPStressTesting.AST
POMDPStressTesting.AST.BlackBox
POMDPStressTesting.AST.GrayBox
POMDPStressTesting.POMDPStressTesting
POMDPStressTesting.AST.ASTAction
POMDPStressTesting.AST.ASTMDP
POMDPStressTesting.AST.ASTMetrics
POMDPStressTesting.AST.ASTParams
POMDPStressTesting.AST.ASTSampleAction
POMDPStressTesting.AST.ASTSeedAction
POMDPStressTesting.AST.ASTState
POMDPStressTesting.AST.GrayBox.Environment
POMDPStressTesting.AST.GrayBox.EnvironmentSample
POMDPStressTesting.AST.GrayBox.Sample
POMDPStressTesting.AST.GrayBox.Simulation
POMDPStressTesting.AST.BlackBox.distance
POMDPStressTesting.AST.BlackBox.evaluate!
POMDPStressTesting.AST.BlackBox.initialize!
POMDPStressTesting.AST.BlackBox.isevent
POMDPStressTesting.AST.BlackBox.isterminal
POMDPStressTesting.AST.GrayBox.environment
POMDPStressTesting.AST.GrayBox.transition!
POMDPStressTesting.AST.action_q_trace
POMDPStressTesting.AST.action_trace
POMDPStressTesting.AST.get_top_path
POMDPStressTesting.AST.go_to_state
POMDPStressTesting.AST.online_path
POMDPStressTesting.AST.playback
POMDPStressTesting.AST.q_trace
POMDPStressTesting.AST.random_action
POMDPStressTesting.AST.record
POMDPStressTesting.AST.record_trace
POMDPStressTesting.AST.reset_metrics!
POMDPStressTesting.AST.rollout
POMDPStressTesting.AST.rollout_end
POMDPStressTesting.AST.search!
POMDPStressTesting.AST.state_trace
POMDPStressTesting.distribution_figures
POMDPStressTesting.episodic_figures
POMDPStressTesting.print_metrics
POMDPStressTesting.visualize
POMDPs.action
POMDPs.convert_s
POMDPs.discount
POMDPs.gen
POMDPs.initialstate
POMDPs.isterminal
POMDPs.reward
Modules
POMDPStressTesting.POMDPStressTesting
— ModuleAdaptive Stress Testing for the POMDPs.jl ecosystem.
POMDPStressTesting.AST
— ModuleProvides implementation of Adaptive Stress Testing (AST) formulation of MDPs/POMDPs.
POMDPStressTesting.AST.GrayBox
— ModuleProvides virtual interface for the gray-box environment and simulator.
POMDPStressTesting.AST.BlackBox
— ModuleProvides virtual interface for the black-box system under test (SUT).
GrayBox
POMDPStressTesting.AST.GrayBox.Simulation
— TypeGrayBox.Simulation
Abstract base type for a gray-box simulation.
POMDPStressTesting.AST.GrayBox.Sample
— TypeGrayBox.Sample
Holds sampled value and log-probability.
POMDPStressTesting.AST.GrayBox.Environment
— TypeGrayBox.Environment
Alias type for a dictionary of gray-box environment distributions.
e.g., `Environment(:variable_name => Sampleable)`
POMDPStressTesting.AST.GrayBox.EnvironmentSample
— TypeGrayBox.EnvironmentSample
Alias type for a single environment sample.
e.g., `EnvironmentSample(:variable_name => Sample(value, logprob))`
POMDPStressTesting.AST.GrayBox.environment
— Functionenvironment(sim::GrayBox.Simulation)
Return all distributions used in the simulation environment.
POMDPStressTesting.AST.GrayBox.transition!
— Functiontransition!(sim::Union{GrayBox.Simulation, GrayBox.Simulation})::Real
Given an input sample::EnvironmentSample
, apply transition and return the transition log-probability.
transition!(sim::GrayBox.Simulation)::Real
Apply a transition step, and return the transition log-probability (used with ASTSeedAction
).
BlackBox
POMDPStressTesting.AST.BlackBox.initialize!
— Functioninitialize!(sim::GrayBox.Simulation)
Reset state to its initial state.
POMDPStressTesting.AST.BlackBox.evaluate!
— Functionevaluate!(sim::GrayBox.Simulation)::Tuple{logprob::Real, miss_distance::Real, isevent::Bool}
evaluate!(sim::GrayBox.Simulation, sample::GrayBox.EnvironmentSample)::Tuple{logprob::Real, miss_distance::Real, isevent::Bool}
Evaluate the SUT given some input seed and current state, returns logprob
, miss_distance
, and isevent
indication. If the sample
version is implemented, then ASTSampleAction
will be used instead of ASTSeedAction
.
POMDPStressTesting.AST.BlackBox.distance
— Functiondistance(sim::GrayBox.Simulation)::Real
Return how close to an event a terminal state was (i.e. some measure of "miss distance" to the event of interest).
POMDPStressTesting.AST.BlackBox.isevent
— Functionisevent(sim::GrayBox.Simulation)::Bool
Return a boolean indicating if the SUT reached a failure event of interest.
POMDPStressTesting.AST.BlackBox.isterminal
— Functionisterminal(sim::GrayBox.Simulation)::Bool
Return an indication that the simulation is in a terminal state.
AST
POMDPStressTesting.AST.search!
— Functionsearch!(planner)
Search for failures given a planner
. Implemented by each solver.
POMDPs.initialstate
— FunctionInitialize AST MDP state. Overridden from POMDPs.initialstate
interface.
POMDPs.reward
— Functionreward(mdp::ASTMDP, logprob::Real, isevent::Bool, isterminal::Bool, miss_distance::Real)::Float64
Reward function for the AST formulation. Defaults to:
R_E if isterminal and isevent (1)
-d if isterminal and !isevent (2)
log(p) otherwise (3)
1) Terminates with event, collect reward_bonus (defaults to 0)
2) Terminates without event, collect negative miss distance
3) Each non-terminal step, accumulate reward correlated with the transition probability
For epsidic reward problems (i.e. rewards only at the end of an episode), set mdp.params.episodic_rewards
to get:
(log(p) - d)*R_E if isterminal and isevent (1)
log(p) - d if isterminal and !isevent (2)
0 otherwise (3)
1) Terminates with event, collect transition probability and miss distance with multiplicative reward bonus
2) Terminates without event, collect transitions probability and miss distance
3) Each non-terminal step, no intermediate reward (set `mdp.params.give_intermediate_reward` to use log transition probability)
POMDPs.gen
— FunctionGenerate next state and reward for AST MDP (handles episodic reward problems). Overridden from POMDPs.gen
interface.
POMDPs.isterminal
— FunctionDetermine if AST MDP is in a terminal state. Overridden from POMDPs.isterminal
interface.
POMDPs.discount
— FunctionAST problems are (generally) undiscounted to treat future reward equally. Overridden from POMDPs.discount
interface.
POMDPStressTesting.AST.random_action
— FunctionRandomly select next action, independent of the state.
POMDPs.action
— FunctionRandomly select next action, independent of the state. Overridden from POMDPs.action
interface.
Missing docstring for actions
. Check Documenter's build log for details.
POMDPs.convert_s
— FunctionUsed by the CommonRLInterface to interact with deep RL solvers.
POMDPStressTesting.AST.go_to_state
— FunctionReset AST simulation to a given state; used by the MCTS DPWSolver as the reset_callback
function.
POMDPStressTesting.AST.record
— FunctionAST.record(::ASTMDP, sym::Symbol, val)
Recard an ASTMetric specified by sym
.
POMDPStressTesting.AST.record_trace
— FunctionRecord the best paths from termination leaf node.
POMDPStressTesting.AST.get_top_path
— FunctionGet k-th top path from the recorded top_paths
.
POMDPStressTesting.AST.rollout
— FunctionRollout simulation for MCTS; used by the MCTS DPWSolver as the estimate_value
function. Custom rollout records action trace once the depth has been reached.
POMDPStressTesting.AST.rollout_end
— FunctionRollout to only execute SUT at end (p
accounts for probabilities generated outside the rollout)
User defined:
feed_gen
Function to feed best action, replaces call to gen
when feeding
feed_type
Indicate when to feed best action. Either at the start of the rollout :start
, or mid-rollout :mid
best_callback
Callback function to record best miss distance or reward for later feeding during rollout
POMDPStressTesting.AST.playback
— FunctionPlay back a given action trace from the initialstate
of the MDP.
POMDPStressTesting.AST.online_path
— FunctionFollow MCTS optimal path online calling action
after each selected state.
POMDPStressTesting.AST.state_trace
— FunctionTrace up the tree to get all ancestor states.
POMDPStressTesting.AST.action_trace
— FunctionTrace up the tree to get all ancestor actions.
POMDPStressTesting.AST.q_trace
— FunctionTrace up the tree and accumulate Q-values.
POMDPStressTesting.AST.action_q_trace
— FunctionTrace up the tree to get all ancestor actions and summed Q-values.
POMDPStressTesting.AST.reset_metrics!
— FunctionClear data stored in mdp.metrics
.
AST Types
POMDPStressTesting.AST.ASTParams
— TypeAST.ASTParams
Adaptive Stress Testing specific simulation parameters.
POMDPStressTesting.AST.ASTAction
— TypeAbstract type for the AST action variants.
POMDPStressTesting.AST.ASTSeedAction
— TypeAST.ASTSeedAction
Random seed AST action.
POMDPStressTesting.AST.ASTSampleAction
— TypeAST.ASTSampleAction
Random environment sample as the AST action.
POMDPStressTesting.AST.ASTState
— TypeAST.ASTState
State of the AST MDP.
POMDPStressTesting.AST.ASTMetrics
— TypeAST.ASTMetrics
Debugging metrics.
POMDPStressTesting.AST.ASTMDP
— TypeAST.ASTMDP
Adaptive Stress Testing MDP problem formulation object.
Metrics
POMDPStressTesting.print_metrics
— Functionprint_metrics(planner)
print_metrics(mdp::ASTMDP)
print_metrics(metrics::ASTMetrics)
Print failure metrics including:
- iteration of first failure
- number of failures
- failure rate
- highest log-likelihood of failure
Visualizations/Figures
POMDPStressTesting.visualize
— FunctionVisualize MCTS tree structure for AST MDP.
POMDPStressTesting.episodic_figures
— FunctionStacked figure with metrics over episodes:
- Running miss distance mean
- Minimum miss distance
- Cumulative number of failure events
POMDPStressTesting.distribution_figures
— FunctionStacked figure with distributions:
- Miss distance distribution
- Log-likelihood distribution