opensbt.algorithm package
Subpackages
Submodules
opensbt.algorithm.algorithm module
opensbt.algorithm.nsga2_optimizer module
- class opensbt.algorithm.nsga2_optimizer.NsgaIIOptimizer(problem: Problem, config: SearchConfiguration)[source]
Bases:
Optimizer
This optimizer class provides the NSGA-II algorithm which is already implemented in pymoo.
- __init__(problem: Problem, config: SearchConfiguration)[source]
Initialize here the Optimization algorithm to be used for search-based testing.
- Parameters:
problem (SimulationProblem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search.
- _abc_impl = <_abc._abc_data object>
- algorithm: Algorithm
Prioritize max search time over set maximal number of generations
- algorithm_name: str = 'NSGA-II'
opensbt.algorithm.nsga2dt_optimizer module
- class opensbt.algorithm.nsga2dt_optimizer.NsgaIIDTOptimizer(problem: Problem, config: SearchConfiguration)[source]
Bases:
Optimizer
This optimizer implements the NSGA-II-DT algorithm from [1] which is based on the NSGA-II algorithm but is employing ML models, i.e. decision trees to guide the search for failures.
[1] Raja Ben Abdessalem, Shiva Nejati, Lionel C. Briand, and Thomas Stifter. 2018. Testing vision-based control systems using learnable evolutionary algorithms. In Proceedings of the 40th International Conference on Software Engineering (ICSE ‘18). Association for Computing Machinery, New York, NY, USA, 1016–1026. https://doi.org/10.1145/3180155.3180160
- __init__(problem: Problem, config: SearchConfiguration)[source]
Initializes the NSGA-II-DT Optimizer
- Parameters:
problem (Problem) – The testing problem.
config (SearchConfiguration) – The configuraiton for the search.
- _abc_impl = <_abc._abc_data object>
- algorithm_name: str = 'NSGA-II-DT'
- run() SimulationResult [source]
_summary_
- Returns:
Return a SimulationResults object which holds all information from the simulation.
- Return type:
opensbt.algorithm.optimizer module
- class opensbt.algorithm.optimizer.Optimizer(problem: SimulationProblem, config: SearchConfiguration)[source]
Bases:
ABC
Base class for all optimizers in OpenSBT. Subclasses need to implement the __init__ method. The run method has to be overriden when non pymoo implemented algorithms are used. For reference consider the implementation of the NSGA-II-DT optimizer in opensbt/algorithm/nsga2dt_optimizer.py
- abstract __init__(problem: SimulationProblem, config: SearchConfiguration)[source]
Initialize here the Optimization algorithm to be used for search-based testing.
- Parameters:
problem (SimulationProblem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search.
- _abc_impl = <_abc._abc_data object>
- algorithm: Algorithm
- algorithm_name: str
- config: SearchConfiguration
- parameters: Dict
- problem: Problem
- run() SimulationResult [source]
Runs the optimizer for a given problem and search configuration. Returns the simulation output as an instance of SimulationResult. This methods need to overriden when a non pymoo-based algorithm is used (e.g., NSGA-II-DT)
- save_history: bool
- termination: object
opensbt.algorithm.ps module
- class opensbt.algorithm.ps.PureSampling(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'pymoo.operators.sampling.rnd.FloatRandomSampling'>)[source]
Bases:
Optimizer
This class provides the parent class for all sampling based search algorithms.
- __init__(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'pymoo.operators.sampling.rnd.FloatRandomSampling'>)[source]
Initializes pure sampling approaches.
- Parameters:
problem (Problem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search.
sampling_type (_type_, optional) – Sets by default sampling type to RS.
- _abc_impl = <_abc._abc_data object>
- algorithm_name: str = 'RS'
- run() SimulationResult [source]
- Overrides the run method of Optimizer by providing custom evaluation of samples and division in “buckets” for further analysis with pymoo.
(s. n_splits variable)
- Returns:
Return a SimulationResults object which holds all information from the simulation.
- Return type:
opensbt.algorithm.ps_fps module
- class opensbt.algorithm.ps_fps.PureSamplingFPS(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'opensbt.utils.fps.FPS'>)[source]
Bases:
PureSampling
This class provides the Farthest Point Sampling algorithm (FPS) [1]. FPS generate new inputs with the largest distance from the existing inputs to achieve a uniform distribution of test inputs in the search space.
[1] Eldar Y, Lindenbaum M, Porat M, Zeevi Y (1997) The farthest point strategy for progressive image sampling. IEEE Trans Image Process 6:1305–15, DOI 10.1109/83.623193
- __init__(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'opensbt.utils.fps.FPS'>)[source]
Initializes the furthes point sampling optimizer.
- Parameters:
problem (Problem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search.
sampling_type (_type_, optional) – Sets by default sampling type to FPS.
- _abc_impl = <_abc._abc_data object>
- algorithm_name: str = 'FPS'
opensbt.algorithm.ps_grid module
- class opensbt.algorithm.ps_grid.PureSamplingGrid(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'opensbt.utils.sampling.CartesianSampling'>)[source]
Bases:
PureSampling
This class provides the Grid Sampling algorithm which generate aquidistant test inputs placed on a grid in the search space.
- __init__(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'opensbt.utils.sampling.CartesianSampling'>)[source]
Initializes the grid search sampling optimizer.
- Parameters:
problem (Problem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search. The number of samples is equaly for each axis. The axis based sampling number is defined via the population size.
sampling_type (_type_, optional) – Sets by default sampling type to Cartesian Sampling.
- _abc_impl = <_abc._abc_data object>
opensbt.algorithm.ps_rand module
- class opensbt.algorithm.ps_rand.PureSamplingRand(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'pymoo.operators.sampling.rnd.FloatRandomSampling'>)[source]
Bases:
PureSampling
This class provides the random sampling algorithm which generates random test inputs in the search space.
- __init__(problem: ~opensbt.model_ga.problem.SimulationProblem, config: ~opensbt.experiment.search_configuration.SearchConfiguration, sampling_type=<class 'pymoo.operators.sampling.rnd.FloatRandomSampling'>)[source]
Initializes the random sampling optimizer.
- Parameters:
problem (Problem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search.
sampling_type (_type_, optional) – Sets by default sampling type to RS.
- _abc_impl = <_abc._abc_data object>
opensbt.algorithm.pso_optimizer module
- class opensbt.algorithm.pso_optimizer.PSOOptimizer(problem: SimulationProblem, config: SearchConfiguration)[source]
Bases:
Optimizer
This class provides search with the Particle Swarm Optimization algorithm which is already implemented in pymoo.
- __init__(problem: SimulationProblem, config: SearchConfiguration)[source]
Initializes the particle swarm opimization approach for testing.
- Parameters:
problem (SimulationProblem) – The testing problem to be solved.
config (SearchConfiguration) – The configuration for the search.
- _abc_impl = <_abc._abc_data object>
- algorithm: Algorithm
Prioritize max search time over set maximal number of generations
- algorithm_name: str = 'PSO'