-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiment.py
129 lines (122 loc) · 4.71 KB
/
experiment.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import MultiNEAT as NEAT
import pickle
import sys
class experiment:
# MESA params
nb_gens=2
depth = 4
max_fitness= 98
energy = 50 # default was 70
step_count = 100
# fitness = 0 # see model class for the definitions of the variable
nb_gap_junctions = 1 # one unique GJ_opening for both molecs and stress
nb_stress_GJ = 1
nb_output_stress = 1
nb_output_anxio = 1
apoptosis_on = 1 # Set to 0 if off
cell_division_on = 1 # Set to 0 if off
history_length = 5
ANN_inputs = None
ANN_outputs = None
e_penalty = None
random_start = False
preset = None
multiple = 5
start_molecs = None
sbatch = False
ef_mode = 1 # "electric_face_mode" for electric face experiments circa February 2023
# Interface
interface = False
# Parameters for es-hyperneat
params = NEAT.Parameters()
params.PopulationSize = 350
params.DynamicCompatibility = True
params.CompatTreshold = 3.0
params.YoungAgeTreshold = 15
params.SpeciesMaxStagnation = 10
params.OldAgeTreshold = 35
params.StagnationDelta = 5
params.MinSpecies = 5
params.MaxSpecies = 15
params.RouletteWheelSelection = False
params.MutateRemLinkProb = 0.02
params.RecurrentProb = 0.2
params.OverallMutationRate = 0.15
params.MutateAddLinkProb = 0.03
params.MutateAddNeuronProb = 0.03
params.MutateWeightsProb = 0.90
params.MaxWeight = 8.0
params.MinWeight = -8.0
params.WeightMutationMaxPower = 0.2
params.WeightReplacementMaxPower = 1.0
params.MutateActivationAProb = 0.0
params.ActivationAMutationMaxPower = 0.5
params.MinActivationA = 0.05
params.MaxActivationA = 6.9
params.MinNeuronBias = -params.MaxWeight
params.MaxNeuronBias = params.MaxWeight
params.MutateNeuronActivationTypeProb = 0.3
params.ActivationFunction_SignedGauss_Prob = 1.0
params.ActivationFunction_SignedStep_Prob = 1.0
params.ActivationFunction_Linear_Prob = 1.0
params.ActivationFunction_SignedSine_Prob = 1.0
params.ActivationFunction_SignedSigmoid_Prob = 1.0
params.ActivationFunction_SignedSigmoid_Prob = 0.0
params.ActivationFunction_UnsignedSigmoid_Prob = 0.0
params.ActivationFunction_TanhCubic_Prob = 0.0
params.ActivationFunction_UnsignedStep_Prob = 0.0
params.ActivationFunction_UnsignedGauss_Prob = 0.0
params.ActivationFunction_Abs_Prob = 0.0
params.ActivationFunction_UnsignedSine_Prob = 0.0
params.AllowLoops = True
params.AllowClones = True
params.MutateNeuronTraitsProb = 0
params.MutateLinkTraitsProb = 0
params.DivisionThreshold = 0.03
params.VarianceThreshold = 0.03
params.BandThreshold = 0.3
# depth of the quadtree
params.InitialDepth = 3
params.MaxDepth = 3
# corresponds to the number of hidden layers = iterationlevel+1
params.IterationLevel = depth -1
params.Leo = False
params.GeometrySeed = True
params.LeoSeed = True
params.LeoThreshold = 0.2
params.CPPN_Bias = -1.0
params.Qtree_X = 0.0
params.Qtree_Y = 0.0
params.Width = 1.
params.Height = 1.
params.Elitism = 0.1
rng = NEAT.RNG()
rng.TimeSeed()
nb_ANN_inputs = 0
nb_ANN_outputs = 0
def __init__(self, ANN_inputs, ANN_outputs):
self.ANN_inputs = ANN_inputs
self.ANN_outputs = ANN_outputs
self.nb_ANN_inputs = sum(ANN_inputs.values())
self.nb_ANN_outputs = len(self.ANN_outputs)
# Substrate for MultiNEAT
self.input_coordinates = [(-1. +(2.*i/(self.nb_ANN_inputs - 1)), -1.) for i in range(0, self.nb_ANN_inputs)]
self.output_coordinates = [(-1. +(2.*i/(self.nb_ANN_outputs - 1)),1.) for i in range(0, self.nb_ANN_outputs)]
self.substrate = NEAT.Substrate(self.input_coordinates, [], self.output_coordinates)
self.substrate.m_allow_input_hidden_links = True
self.substrate.m_allow_hidden_output_links = True
self.substrate.m_allow_hidden_hidden_links = False
self.substrate.m_allow_looped_hidden_links = True
self.substrate.m_allow_input_output_links = False
self.substrate.m_allow_output_hidden_links = True
self.substrate.m_allow_output_output_links = False
self.substrate.m_allow_looped_output_links = False
self.substrate.m_hidden_nodes_activation = NEAT.ActivationFunction.SIGNED_SIGMOID
self.substrate.m_output_nodes_activation = NEAT.ActivationFunction.UNSIGNED_SIGMOID
self.substrate.m_with_distance = True
self.substrate.m_max_weight_and_bias = 8.0
try:
x = pickle.dumps(self.substrate)
except:
print('You have mistyped a substrate member name upon setup. Please fix it.')
sys.exit(1)