1
1
"""Module containing classes to define and run causal surrogate assisted test cases"""
2
2
3
- from abc import ABC
3
+ from abc import ABC , abstractmethod
4
4
from dataclasses import dataclass
5
5
from typing import Callable , Any
6
6
11
11
12
12
13
13
@dataclass
14
- class SimulationResult ( ABC ) :
14
+ class SimulationResult :
15
15
"""Data class holding the data and result metadata of a simulation"""
16
16
17
17
data : dict
@@ -20,39 +20,44 @@ class SimulationResult(ABC):
20
20
21
21
22
22
@dataclass
23
- class SearchFitnessFunction ( ABC ) :
23
+ class SearchFitnessFunction :
24
24
"""Data class containing the Fitness function and related model"""
25
25
26
26
fitness_function : Any
27
27
surrogate_model : CubicSplineRegressionEstimator
28
28
29
29
30
- class SearchAlgorithm :
30
+ class SearchAlgorithm ( ABC ) :
31
31
"""Class to be inherited with the search algorithm consisting of a search function and the fitness function of the
32
32
space to be searched"""
33
33
34
+ @abstractmethod
34
35
def generate_fitness_functions (self , surrogate_models : list [Estimator ]) -> list [SearchFitnessFunction ]:
35
36
"""Generates the fitness function of the search space
36
37
:param surrogate_models: A list of CubicSplineRegressionEstimator generated for each edge of the DAG
37
38
:return: A list of fitness functions mapping to each of the surrogate models in the input"""
38
39
40
+ @abstractmethod
39
41
def search (self , fitness_functions : list [SearchFitnessFunction ], specification : CausalSpecification ) -> list :
40
42
"""Function which implements a search routine which searches for the optimal fitness value for the specified
41
43
scenario
42
44
:param fitness_functions: The fitness function to be optimised
43
45
:param specification: The Causal Specification (combination of Scenario and Causal Dag)"""
44
46
45
47
46
- class Simulator :
48
+ class Simulator ( ABC ) :
47
49
"""Class to be inherited with Simulator specific functions to start, shutdown and run the simulation with the give
48
50
config file"""
49
51
52
+ @abstractmethod
50
53
def startup (self , ** kwargs ):
51
54
"""Function that when run, initialises and opens the Simulator"""
52
55
56
+ @abstractmethod
53
57
def shutdown (self , ** kwargs ):
54
58
"""Function to safely exit and shutdown the Simulator"""
55
59
60
+ @abstractmethod
56
61
def run_with_config (self , configuration : Any ) -> SimulationResult :
57
62
"""Run the simulator with the given configuration and return the results in the structure of a
58
63
SimulationResult
0 commit comments