API Reference
tempestpy.shielding.ShieldFactory(model: Any, *, property: Optional[str] = None, constants: Optional[Dict[str, Any]] = None, prism_program: Optional[Any] = None, check_result: Optional[Any] = None, engine: str = 'sparse')
Entry point for computing probabilistic shields from PRISM models.
A ShieldFactory parses or receives a PRISM MDP/SMG, runs model
checking to obtain per-action choice values, and converts those values
into ShieldResult bitmasks via build or compute_mask.
See Also
ShieldConfig : Threshold and comparison-mode settings passed to build.
ShieldResult : The bitmask container returned by build.
Initialise a ShieldFactory.
Three construction modes are supported, selected automatically based on the type of model and the keyword arguments supplied:
- Path mode — pass a PRISM file path as model. The factory parses the program, builds the model, and (if property is given) runs model checking immediately.
- Pre-built model mode — pass a stormpy model object as model
together with prism_program and property.
Model building is skipped; model checking runs on
build. - Pre-computed result mode — pass a stormpy model object,
prism_program, and check_result.
Both model building and model checking are skipped;
compute_maskcan be called directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
Either a path string to a |
required |
property
|
Optional[str]
|
A PCTL/PRCTL property string, e.g. |
None
|
constants
|
Optional[Dict[str, Any]]
|
PRISM constant definitions, e.g. |
None
|
prism_program
|
Optional[Any]
|
A parsed |
None
|
check_result
|
Optional[Any]
|
A pre-computed stormpy check result that already contains choice values. When provided, model checking is skipped entirely (mode 3). |
None
|
engine
|
str
|
Backend representation. |
'sparse'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If engine is not |
TypeError
|
If a pre-built model is passed without prism_program, or if the model type or engine/model combination is unsupported. |
Examples:
Mode 1 — build everything from a file:
>>> factory = ShieldFactory("model.prism", property="Pmax=? [G safe]",
... constants={"N": 5})
>>> result = factory.build(ShieldConfig(threshold=0.9))
Mode 3 — reuse an existing check result:
model: Any
property
The stormpy model held by this factory.
prism_program: Any
property
The parsed storm::prism::Program held by this factory.
prop: Optional[str]
property
writable
The active PCTL property string, or None if not set.
formula: Any
property
The parsed stormpy formula, or None before a property is set.
optimality_type: Any
property
The optimality direction (Minimize / Maximize) derived from
the formula, or None if no formula has been set.
choice_data: Optional[ChoiceData]
property
The stored ChoiceData, or None if no model checking has happened yet.
is_sparse: bool
property
True when the factory operates in sparse-engine mode.
state_lookup: StateValuationLookup
property
Lazy-initialised bidirectional map between state ids and PRISM valuations.
with_prop(prop: str) -> 'ShieldFactory'
Return a copy of this factory with a different property string.
build(config: ShieldConfig) -> Any
Run model checking (if needed) and compute the action mask.
If model checking has not been performed yet, it is triggered here. Subsequent calls with the same property reuse the cached result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ShieldConfig
|
Threshold, comparison mode, and optional post-selector / action lookup settings for the mask computation. |
required |
Returns:
| Type | Description |
|---|---|
ShieldResult
|
Per-state bitmasks encoding which actions are permitted. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If neither a formula nor a check result is available. |
compute_mask(config: ShieldConfig) -> Any
Compute the action mask from an already-available check result.
Unlike build, this method does not run model checking.
A check result must be present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ShieldConfig
|
Threshold, comparison mode, and optional post-selector / action lookup settings. |
required |
Returns:
| Type | Description |
|---|---|
ShieldResult
|
Per-state bitmasks encoding which actions are permitted. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no check result is available. |
get_choice_values_for_state(sid: int) -> np.ndarray
Return the model-checked choice values for all actions in state sid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sid
|
int
|
State index (0-based). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
1-D array of floats, one entry per local action, in action order. |
get_state_id(values: dict) -> int
Look up the state id for a given PRISM variable valuation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
dict
|
Mapping of PRISM variable name to value,
e.g. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The model state id corresponding to values. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the valuation does not match any state. |
unsafe_states() -> list[dict]
Return the PRISM valuations of all unsafe states.
A state is unsafe when it cannot satisfy the property at all
(risk 1): Pmax(phi) = 0 for maximising properties, Pmin = 1
for minimising ones. Unsafe takes precedence over the other classes.
This does not depend on a ShieldConfig, so no mask is needed.
The result comes from Storm's qualitative check (Pmax>0 /
Pmin>=1) without any added tolerance. Unbounded F/G are exact;
bounded F on MDPs is exact on the zero side and numeric on the one
side; bounded SMG properties are unsupported by Storm here.
engine="dd" raises NotImplementedError.
Returns:
| Type | Description |
|---|---|
list of dict
|
Each dict maps PRISM variable names to their values for one state. |
dangerous_states(*, mask: ShieldResult) -> list[dict]
Return the PRISM valuations of all dangerous states in mask.
A state is dangerous when no action meets the shield threshold and the fallback (best-value) action is used instead. Unsafe states are excluded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
Each dict maps PRISM variable names to their values for one state. |
critical_states(*, mask: ShieldResult) -> list[dict]
Return the PRISM valuations of all critical states in mask.
A state is critical when at least one action is blocked by the threshold but at least one action still passes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
Each dict maps PRISM variable names to their values for one state. |
safe_states(*, mask: ShieldResult) -> list[dict]
Return the PRISM valuations of all safe states in mask.
A state is safe when every action passes the shield threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
Each dict maps PRISM variable names to their values for one state. |
states_by_class(*, mask: ShieldResult) -> dict[str, list[dict]]
Partition all states into the four shield classes with their valuations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Keys are |
save(path: str, *, slim: bool = True) -> None
Persist this factory to a pickle file.
slim=True (default): choice values and state lookup only — smallest file. slim=False: DRN model bytes + prism file path — fully functional on load.
load(path: str) -> 'ShieldFactory'
classmethod
Load a ShieldFactory saved with save().
slim=True saves: state lookup and choice values ready for inference; Storm model not available. slim=False saves: Storm model restored from DRN; call build() to re-run model checking if fresh results are needed.
to_bitmask(mask: Any) -> dict[int, int]
Convert mask to a {state_id: bitmask} dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps each state id to its packed integer bitmask. |
to_allowed_action_indices(mask: Any) -> dict[int, list[int]]
Convert mask to a {state_id: [action_index, ...]} dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps each state id to the list of allowed local action indices. |
to_allowed_action_labels(mask: Any) -> dict[int, list]
Convert mask to a {state_id: [frozenset(labels), ...]} dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps each state id to the list of label-sets for allowed actions. |
to_allowed_state_action_pairs(mask: Any) -> list[tuple[int, int]]
Return all allowed (state_id, local_action_index) pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
list of tuple
|
Each entry is |
to_valuation_bitmask(mask: Any) -> dict
Convert mask to a {valuation_key: bitmask} dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps each state's |
to_valuation_allowed_action_labels(mask: Any) -> dict
Convert mask to a {valuation_key: [frozenset(labels), ...]} dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps each state's |
to_valuation_action_label_probability() -> dict
Map every state to all its actions and their model-checked probabilities.
Returns:
| Type | Description |
|---|---|
dict
|
|
pretty_mask(mask: Any, *, max_states: int = 25, show_valuations: bool = True, action_ref: str = 'labels') -> str
Return a human-readable summary of mask for debugging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
max_states
|
int
|
Maximum number of states to include in the output (default 25). |
25
|
show_valuations
|
bool
|
If |
True
|
action_ref
|
str
|
How to identify actions: |
'labels'
|
Returns:
| Type | Description |
|---|---|
str
|
Multi-line human-readable shield summary. |
to_storm_format(mask: Any) -> str
Render mask as a Storm-compatible shield text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
str
|
Multi-line string matching Storm's shield output format, with per-action choice values and valuation annotations. |
tempestpy.shielding.ShieldConfig(threshold: float = 1.0, comparison: ComparisonMode = 'absolute', post_selector: Optional[PostSelectorFn] = None, action_lookup: Optional[ActionLookup] = None)
dataclass
Immutable configuration for a single shield computation.
Attributes:
| Name | Type | Description |
|---|---|---|
threshold |
float
|
The probability threshold. In |
comparison |
ComparisonMode
|
How to interpret threshold: |
post_selector |
Optional[PostSelectorFn]
|
Optional callable invoked by |
action_lookup |
Optional[ActionLookup]
|
Optional |
See Also
ShieldFactory.build : Consumes a ShieldConfig to produce a ShieldResult.
ActionLookup : Maps PRISM labels to RL action indices.
tempestpy.shielding.action_lookup.ActionLookup(label_to_index: dict[str, int], index_to_labels: dict[int, list[str]], nr_actions: int)
dataclass
Canonical mapping between PRISM action labels and global RL action indices.
Multiple PRISM labels may share the same global index:
``{"move_left_fast": 0, "move_left_slow": 0, "right": 1}``
Indices must be contiguous integers starting at 0. Gaps are rejected at construction time to prevent silent bitmask misalignment with the RL action space.
Attributes:
| Name | Type | Description |
|---|---|---|
label_to_index |
dict[str, int]
|
Maps each PRISM action label to its global RL action index. |
index_to_labels |
dict[int, list[str]]
|
Inverse map: global action index → list of PRISM labels. |
nr_actions |
int
|
Number of distinct global action indices (= |
See Also
ShieldConfig : Accepts an ActionLookup to enable global-index bitmasks.
ActionLookup.from_dict : Primary constructor.
from_dict(mapping: Mapping[str, int]) -> 'ActionLookup'
classmethod
Build from a user-supplied {label: global_index} dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[str, int]
|
Maps each model action label to its global RL action index. Indices must be contiguous integers starting at 0. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mapping is empty or indices are not contiguous from 0. |
index(label: str) -> int
Return the global action index for a model action label.
Raises:
| Type | Description |
|---|---|
KeyError
|
If the label is not in the mapping. |
labels(index: int) -> list[str]
Return all model action labels that map to a given global index.
Raises:
| Type | Description |
|---|---|
KeyError
|
If the index is out of range. |
has_label(label: str) -> bool
Return True when label is present in this lookup.
has_index(index: int) -> bool
Return True when index is a valid global action index.
validate_model_labels(model: object) -> None
Check that every action label appearing in the model is present in this lookup. Raises ValueError listing any missing labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
A stormpy sparse model with state_valuations and choice_labeling. |
required |
tempestpy.shielding.ShieldResult(config: Any, bit_width: Optional[int] = None, coalition_states: Optional[frozenset] = None)
dataclass
Bases: ABC
Base class for shield results produced by explicit and symbolic backends.
Explicit shields are keyed by integer state ids. Symbolic shields are
keyed by PRISM variable valuations, for example {"x": 4, "y": 7}.
query_mask(state: Any) -> int
Return the effective pre-shielding bitmask for state.
query_post(state: Any, agent_action: int, **kwargs: Any) -> int
Return agent_action if allowed, otherwise call the post-selector.
query_action(state: Any, agent_action: int, **kwargs: Any) -> int
Alias for query_post kept for callers that use action wording.
is_coalition_state(sid: int) -> bool
True for all non-SMG states; for SMGs, true only for ego states.
is_unsafe(state: Any) -> bool
Return true when the state violates the property outright (risk 1).
is_dangerous(state: Any) -> bool
Return true when no action met the threshold and fallback is used.
is_critical(state: Any) -> bool
Return true when some but not all actions are blocked.
is_safe(state: Any) -> bool
Return true when all actions are allowed.
classify_state(state: Any) -> str
Return one of safe, critical, dangerous, or unsafe.
unsafe takes precedence, so the four classes partition the states.
tempestpy.shielding.ExplicitShieldResult(config: Any, bit_width: Optional[int] = None, coalition_states: Optional[frozenset] = None, bitmask_by_state: list[int] = list(), fallback_by_state: list[int] = list(), nr_actions_by_state: list[int] = list(), best_value_by_state: Optional[np.ndarray] = None, unsafe_state_ids: frozenset = frozenset())
dataclass
tempestpy.shielding.SymbolicShieldResult(config: Any, bit_width: Optional[int] = None, coalition_states: Optional[frozenset] = None, bitmask_add: Any = None, fallback_add: Any = None, choice_values_add: Any = None, nr_actions: int = 0)
dataclass
Bases: ShieldResult
Shield result for DD-backed symbolic model checking.
bitmask_by_state: Any
property
Compatibility alias for the ADD-backed symbolic bitmask.
fallback_by_state: Any
property
Compatibility alias for the ADD-backed symbolic fallback bitmask.
choice_values: Any
property
The ADD-backed symbolic choice values.
choice_values_by_state: Any
property
Compatibility alias for the ADD-backed symbolic choice values.
nr_actions_by_state: list[int]
property
Compatibility alias; symbolic action count is uniform when known.
Gymnasium Wrappers
tempestpy.shielding.PreShieldWrapper(env: gym.Env, factory: ShieldFactory, config: ShieldConfig, *, obs_to_values: ObsToValuesFn)
Bases: Wrapper
Gymnasium wrapper that adds pre-shield action masking.
On every reset() and step(), the wrapper queries the shield and
injects an "action_mask" boolean array into info. The mask can
be consumed directly or via the action_masks() hook for SB3
MaskablePPO.
The info dict after reset() / step() contains:
"action_mask"—np.ndarray[bool], shape(n_actions,)"shield_state_id"—int, state id used for the current mask"shield_bitmask"—int, raw packed bitmask
See Also
PostShieldWrapper : Corrects the agent's chosen action after the fact.
ShieldFactory.build : Produces the ShieldResult used internally.
Initialise a PreShieldWrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
Env
|
The Gymnasium environment to wrap. Must have a
|
required |
factory
|
ShieldFactory
|
A |
required |
config
|
ShieldConfig
|
|
required |
obs_to_values
|
ObsToValuesFn
|
Callable |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
action_masks() -> np.ndarray
Return the current boolean action mask for SB3 MaskablePPO.
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean array of shape |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If called before the first |
rebuild(config: ShieldConfig) -> None
Recompute the shield with a new ShieldConfig.
Useful for changing the threshold mid-training without re-creating the wrapper. Resets the cached action mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ShieldConfig
|
New shield configuration. |
required |
tempestpy.shielding.PostShieldWrapper(env: gym.Env, factory: ShieldFactory, config: ShieldConfig, *, obs_to_values: ObsToValuesFn)
Bases: Wrapper
Gymnasium wrapper that enforces shield safety via post-shielding.
The agent selects any action from the unmasked observation. Before the
action reaches env.step, the wrapper checks the shield: if the action
is allowed it passes through unchanged; if blocked, ShieldConfig.post_selector
is called to supply a safe replacement.
The info dict after reset() / step() contains:
"shield_state_id"—int, state id used for the next step"shield_safe_action"—int, the action actually passed toenv.step"shield_corrected"—bool,Truewhen the agent's action was replaced
See Also
PreShieldWrapper : Injects an action mask before the agent acts. make_best_value_selector : A ready-made post-selector for this wrapper.
Initialise a PostShieldWrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
Env
|
The Gymnasium environment to wrap. Must have a
|
required |
factory
|
ShieldFactory
|
A |
required |
config
|
ShieldConfig
|
|
required |
obs_to_values
|
ObsToValuesFn
|
Callable |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
rebuild(config: ShieldConfig) -> None
Recompute the shield with a new ShieldConfig.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ShieldConfig
|
New configuration. Must have a non- |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
tempestpy.shielding.make_best_value_selector(factory: ShieldFactory, result: ShieldResult, *, is_minimize: bool = False) -> Callable[[int, int], int]
Create a post-selector that replaces a blocked action with the best-value action.
The returned callable closes over factory to retrieve per-state choice values at call time. Works in both normal and dangerous states; in dangerous states it falls back to the argmax/argmin action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factory
|
ShieldFactory
|
The |
required |
result
|
ShieldResult
|
The |
required |
is_minimize
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Callable[[int, int], int]
|
|
Examples:
>>> selector = make_best_value_selector(factory, result, is_minimize=False)
>>> config = ShieldConfig(threshold=0.9, post_selector=selector)
tempestpy.shielding.make_random_safe_selector(result: ShieldResult, *, rng: Optional[np.random.Generator] = None) -> Callable[[int, int], int]
Create a post-selector that replaces a blocked action with a random allowed action.
In dangerous states (no action meets the threshold) the fallback action
from ShieldResult.fallback_by_state is used instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ShieldResult
|
The |
required |
rng
|
Optional[Generator]
|
Optional NumPy random generator. If |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[int, int], int]
|
|
Examples:
>>> selector = make_random_safe_selector(result, rng=np.random.default_rng(42))
>>> config = ShieldConfig(threshold=0.9, post_selector=selector)
tempestpy.shielding.make_nearest_action_selector(result: ShieldResult) -> Callable[[int, int], int]
Create a post-selector that replaces a blocked action with the nearest allowed action.
Nearest is measured by absolute index distance, making this useful when
action indices have a natural ordering (e.g. discretised velocity).
Falls back to ShieldResult.fallback_by_state in dangerous states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ShieldResult
|
The |
required |
Returns:
| Type | Description |
|---|---|
Callable[[int, int], int]
|
|
Examples:
>>> selector = make_nearest_action_selector(result)
>>> config = ShieldConfig(threshold=0.9, post_selector=selector)
Export Helpers
tempestpy.shielding.state_id_to_bitmask(mask: ShieldResult) -> dict[int, int]
Convert a shield result to a {state_id: bitmask} dictionary.
Bit i in each bitmask corresponds to local action index i in
model.states[state_id].actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps each state id to its packed integer bitmask. |
tempestpy.shielding.state_id_to_allowed_action_indices(model: Any, mask: ShieldResult) -> dict[int, list[int]]
Map each state id to the list of allowed local action indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
|
tempestpy.shielding.state_id_to_allowed_action_labels(model: Any, mask: ShieldResult) -> dict[int, list[FrozenSet[str]]]
Map each state id to the label-sets of allowed actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
|
tempestpy.shielding.valuation_to_bitmask(model: Any, mask: ShieldResult, state_lookup: Any) -> dict[StateValuationKey, int]
Map each state's valuation key to its packed bitmask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
state_lookup
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
|
tempestpy.shielding.valuation_to_allowed_action_labels(model: Any, mask: ShieldResult, state_lookup: Any) -> dict[StateValuationKey, list[FrozenSet[str]]]
Map each state's valuation key to the label-sets of allowed actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
state_lookup
|
Any
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict
|
|
tempestpy.shielding.valuation_to_allowed_action_labels_with_values(model: Any, mask: ShieldResult, state_lookup: Any, state_action_values: StateActionValueLookup) -> dict[StateValuationKey, dict[FrozenSet[str], float]]
Map each state's valuation key to a {action_labels: value} dict for allowed actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
state_lookup
|
Any
|
A |
required |
state_action_values
|
StateActionValueLookup
|
Either a mapping |
required |
Returns:
| Type | Description |
|---|---|
dict
|
|
Notes
If multiple allowed actions in the same state share the same label set, later entries overwrite earlier ones (dict keys must be unique).
tempestpy.shielding.allowed_state_action_pairs(model: Any, mask: ShieldResult) -> list[tuple[int, int]]
Return all allowed (state_id, local_action_index) pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
list of tuple
|
Each entry is |
tempestpy.shielding.pretty(model: Any, mask: ShieldResult, state_lookup: Any, *, max_states: int = 25, show_valuations: bool = True, action_ref: str = 'labels') -> str
Return a human-readable summary of a shield mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
The stormpy model associated with mask. |
required |
mask
|
ShieldResult
|
A |
required |
state_lookup
|
Any
|
A |
required |
max_states
|
int
|
Maximum number of states to include (default 25). |
25
|
show_valuations
|
bool
|
If |
True
|
action_ref
|
str
|
|
'labels'
|
Returns:
| Type | Description |
|---|---|
str
|
Multi-line human-readable shield summary. |
tempestpy.shielding.storm_format(factory: Any, mask: ShieldResult) -> str
Render a shield mask as a Storm-compatible shield text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factory
|
Any
|
The |
required |
mask
|
ShieldResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
str
|
Multi-line string matching Storm's shield output format.
Each line shows |