17 #include <core/ann_activation_functions.h> 18 #include <core/utils.h> 19 #include <core/darwin.h> 20 #include <core/properties.h> 21 #include <core/stringify.h> 22 #include <core/roulette_selection.h> 23 #include <core/cgp_islands_selection.h> 24 #include <core/truncation_selection.h> 34 enum class CrossoverOp {
50 inline auto customStringify(core::TypeTag<CrossoverOp>) {
52 { CrossoverOp::Mix,
"mix" },
53 { CrossoverOp::Split,
"split" },
54 { CrossoverOp::RowSplit,
"row_split" },
55 { CrossoverOp::ColSplit,
"col_split" },
56 { CrossoverOp::RowOrColSplit,
"row_or_col_split" },
57 { CrossoverOp::PrefRowSplit,
"pref_row_split" },
58 { CrossoverOp::PrefAverage,
"pref_average" },
59 { CrossoverOp::RowMix,
"row_mix" },
60 { CrossoverOp::ColMix,
"col_mix" },
61 { CrossoverOp::RowOrColMix,
"row_or_col_mix" },
62 { CrossoverOp::Quadrants,
"quadrants" },
63 { CrossoverOp::BestParent,
"best_parent" },
64 { CrossoverOp::Randomize,
"randomize" },
69 enum class MutationOp {
79 inline auto customStringify(core::TypeTag<MutationOp>) {
81 { MutationOp::IndividualCells,
"individual_cells" },
82 { MutationOp::AllCells,
"all_cells" },
83 { MutationOp::RowOrCol,
"row_or_col" },
84 { MutationOp::Row,
"row" },
85 { MutationOp::Col,
"col" },
86 { MutationOp::RowAndCol,
"row_and_col" },
87 { MutationOp::SubRect,
"sub_rect" },
92 enum class SelectionAlgorithmType {
98 inline auto customStringify(core::TypeTag<SelectionAlgorithmType>) {
100 { SelectionAlgorithmType::RouletteWheel,
"roulette_wheel" },
101 { SelectionAlgorithmType::CgpIslands,
"cgp_islands" },
102 { SelectionAlgorithmType::Truncation,
"truncation" },
107 struct SelectionAlgorithmVariant
109 CASE(SelectionAlgorithmType::RouletteWheel,
112 CASE(SelectionAlgorithmType::CgpIslands,
115 CASE(SelectionAlgorithmType::Truncation,
121 PROPERTY(activation_function,
124 "Main activation function");
126 PROPERTY(gate_activation_function,
129 "Activation function used for cell gates (ex. LSTM)");
132 PROPERTY(mutation_chance,
float, 0.01f,
"Mutation chance");
135 PROPERTY(hidden_layers, vector<size_t>, {},
"Hidden layers (size of each layer)");
138 PROPERTY(crossover_operator, CrossoverOp, CrossoverOp::Quadrants,
"Crossover operator");
139 PROPERTY(mutation_operator,
141 MutationOp::IndividualCells,
142 "Mutation operator");
144 PROPERTY(normalize_input,
bool,
false,
"Normalize input values");
145 PROPERTY(normalize_output,
bool,
false,
"Normalize output values");
147 VARIANT(selection_algorithm,
148 SelectionAlgorithmVariant,
149 SelectionAlgorithmType::Truncation,
150 "Selection algorithm");
153 extern Config g_config;
156 extern size_t g_inputs;
157 extern size_t g_outputs;
165 void mutationOperator(
ann::Matrix& w,
float mutation_std_dev);
169 vector<float> values;
171 AnnLayer(
size_t size) : values(size) {}
172 virtual ~AnnLayer() =
default;
174 virtual void evaluate(
const vector<float>& inputs) = 0;
175 virtual void resetState() = 0;
ActivationFunction
The types of supported activation functions.
Definition: ann_activation_functions.h:28
Conventional Neuroevolution (CNE) populations.
Definition: brain.h:26
Roulette wheel selection configuration.
Definition: roulette_selection.h:23
Hyperbolic tangent (tanh)
The foundation for data structures supporting runtime reflection.
Definition: properties.h:388
Configuration for CgpIslandsSelection.
Definition: cgp_islands_selection.h:26
A variant type (tagged-union) with PropertySet fields.
Definition: properties.h:194
Handles types with a fixed, known set of values (enumerations for example)
Definition: stringify.h:85
Truncation selection configuration.
Definition: truncation_selection.h:26
const Stringify< T > * stringify()
Returns the stringifier for type T.
Definition: stringify.h:166