causal_testing.minimisation.causal_cut

This module implements the Causal Cut tool to minimise test sequences for cyberphysical systems. See https://doi.org/10.1145/3816435 for further details.

Module Contents

Classes

CausalCut

Main class for minimising intervention sequences.

class causal_testing.minimisation.causal_cut.CausalCut(dag: causal_testing.specification.causal_dag.CausalDAG, df: pandas.DataFrame, safe_ranges: pandas.DataFrame, reproduce_fault: collections.abc.Callable, ci_alpha=0.05)

Main class for minimising intervention sequences.

estimate_intervention_causality(interventions: list[tuple[int, str, int]], outcome_variable: str, total_time: int, start_time: int = 0, background_confounders: list[str] = None, timesteps_per_intervention: int = 1) → list[causal_testing.testing.causal_test_case.CausalTestCase]

For each intervention, generate a causal test case to compare the original treatment strategy against the one with that intervention negated. This gives the causal contribution of each intervention to the observed failure.

Parameters:
  • interventions – The list of interventions to prune, of the form [(time, variable, value)].

  • outcome_variable – The name of the outcome variable.

  • total_time – The maximum number of time steps that a test case can run for.

  • start_time – The time at which the test case begins. (Defaults to 0)

  • background_confounders – The names of the non-time-varying confounders. These variables remain constant throughout the whole test execution.

  • timesteps_per_intervention – The number of time steps each intervention takes. (Defaults to 1)

prune_interventions(causal_tests: list[causal_testing.testing.causal_test_case.CausalTestCase], greedy_minimise: bool = False, **kwargs)

Remove interventions not estimated as having a significant causal effect on the observed failure. Run the attack and check if the interventions estimated significant lead to a fault. Add back interventions until the failure manifests.

Parameters:
  • causal_tests – The causal tests (with results) from the estimation phase.

  • greedy_minimise – Whether to apply additional greedy minimisation. (Defaults to False)

  • kwargs – Keyword arguments for self.reproduce_fault.

minimise_test(interventions: list[tuple[int, str, int]], outcome_variable: str, total_time: int, start_time: int = 0, background_confounders: list[str] = None, timesteps_per_intervention: int = 1, greedy_minimise: bool = False, **kwargs) → list[tuple[int, str, int]]

Search for a subset of the supplied interventions that still yields the originally observed failure.

Parameters:
  • interventions – The list of interventions to prune, of the form [(time, variable, value)].

  • outcome_variable – The name of the outcome variable.

  • total_time – The maximum number of time steps that a test case can run for.

  • start_time – The time at which the test case begins. (Defaults to 0)

  • background_confounders – The names of the non-time-varying confounders. These variables remain constant throughout the whole test execution.

  • timesteps_per_intervention – The number of time steps each intervention takes. (Defaults to 1)

  • greedy_minimise – Whether to apply additional greedy minimisation. (Defaults to False)

  • kwargs – Keyword arguments for self.reproduce_fault.