-
Notifications
You must be signed in to change notification settings - Fork 1
/
config_reader.py
66 lines (59 loc) · 2.4 KB
/
config_reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import json
# Import mutation operator classes here
from MutationClasses import (
MinMaxMutationIterator,
DoubleInputRelationalOperatorMutationIterator,
SumMutationIterator,
LogicalOperatorMutationIterator,
IfMutationIterator,
TrigonometryMutationIterator,
SingleInputMathMutationIterator,
DoubleInputMathMutationIterator,
ProductMutationIterator,
OneSpaceSumMutationIterator,
ForIteratorMutationIterator,
UnitDelayMutationIterator,
SwitchMutationIterator,
ForIteratorLamdaMutationIterator,
UnitDelayLamdaMutationIterator,
SwitchLamdaMutationIterator,
ConstantLamdaMutationIterator,
ProductInputsIterator
)
def get_available_mutant_operators(config):
"""Load list of available mutation operators from a configuration file.
Args:
config (dict): configuration object containing a list of short names for mutation operators.
Returns:
List[Type]: List of mutation operator classes corresponding to the short names in the configuration file.
"""
# Define mapping of short names to mutation operators
mutation_operator_map = {
"ROR": DoubleInputRelationalOperatorMutationIterator,
"LOR": LogicalOperatorMutationIterator,
"ASR": (SumMutationIterator, OneSpaceSumMutationIterator),
"MMR": MinMaxMutationIterator,
"ICR": IfMutationIterator,
"TOR": TrigonometryMutationIterator,
"MOR": (SingleInputMathMutationIterator, DoubleInputMathMutationIterator),
"PMR": ProductMutationIterator,
"POR": ProductInputsIterator,
"FIR": ForIteratorMutationIterator,
"FLR": ForIteratorLamdaMutationIterator,
"UDO": (UnitDelayMutationIterator, UnitDelayLamdaMutationIterator),
"SCR": SwitchMutationIterator,
"STR": SwitchLamdaMutationIterator,
"CR": ConstantLamdaMutationIterator
}
short_names = config["mutant_operators"]
available_mutant_operators = []
short_list = []
for short_name in short_names:
if short_name in mutation_operator_map:
short_list.append(short_name)
mutation_operator = mutation_operator_map[short_name]
if isinstance(mutation_operator, tuple):
available_mutant_operators.extend(mutation_operator)
else:
available_mutant_operators.append(mutation_operator)
return available_mutant_operators,short_list