DFTSimulator¶
- class DFTSimulator(
- dft: DFT,
- *,
- seed: int = 42,
- relevant_events: Iterable[str] | None = None,
Bases:
objectHigh-level simulator for Dynamic Fault Trees.
Builds the random number generator and state-generation information automatically, and resolves failable elements to their BE/dependency names.
Create simulator.
- Parameters:
dft – DFT to simulate.
seed – Seed for the pseudo-random number generator.
relevant_events – Additional names to mark as relevant events (beyond the top-level event), or
None.
- is_done() bool¶
Whether the simulation has ended in a sink state. A sink state can either be that the DFT is failed, the state is invalid or no further failures are possible anymore.
- Returns:
True iff the simulation has ended.
- is_failed() bool¶
Whether the DFT is failed.
- Returns:
True iff if the top level event is failed.
- is_next_dependency_failure() bool¶
Returns whether the next failure is due to a dependency (or the BE failing on its own).
- Returns:
True iff the failure is triggered by a dependency.
- let_fail(
- be: str,
- *,
- dependency_successful: bool = True,
Let the given BE fail next. If the BE fails due to a probabilistic dependency, this failure forwarding can be either successful or unsuccessful.
- Parameters:
be – Name of the BE which should fail next.
dependency_successful – Whether the failure forwarding of the dependency was successful.
- Returns:
Result of the step (successful, unsuccessful, invalid).
- Raises:
ValueError – If
becannot fail, or ifdependency_successful=Falseis given for a failure that is not due to a dependency or that is due to an FDEP.
- next_failures() list[str]¶
Returns the BEs which can fail next.
- Returns:
Names of the BEs which can fail next.
- nr_next_failures() int¶
Returns the number of possible BEs which can fail next.
- Returns:
Number of possible BE failures.
- random_fail() SimulationStepResult¶
Let a random BE fail next. The next BE is chosen according their associated failure probability.
- Returns:
Result of the step (successful, unsuccessful, invalid).
- reset() None¶
Reset the simulator to the initial state.
- simulate_traces(timebound: float, nr_traces: int) int¶
Simulate a number of traces via Monte Carlo simulation and check how many led to an overall failure within the given timebound.
- Parameters:
timebound – Time bound up till which traces are simulated.
nr_traces – The number of traces to simulate.
- Returns:
The number of traces which led to an overall failure.
- status() tuple[str, dict[DFTElement, str]]¶
Get current status of DFT elements.
- Returns:
Tuple (overall status, dict element -> status).