36 #ifndef _ga_selector_h_
37 #define _ga_selector_h_
57 GADefineIdentity(
"GASelectionScheme", GAID::Selection);
81 virtual void update() {}
82 virtual GAGenome &select()
const = 0;
94 #if USE_RANK_SELECTOR == 1
98 GADefineIdentity(
"GARankSelector", GAID::RankSelection);
100 explicit GARankSelector(
int w = GASelectionScheme::SCALED)
115 ~GARankSelector()
override =
default;
118 return new GARankSelector;
128 #if USE_ROULETTE_SELECTOR == 1 || USE_TOURNAMENT_SELECTOR == 1
132 GADefineIdentity(
"GARouletteWheelSelector", GAID::RouletteWheelSelection);
134 explicit GARouletteWheelSelector(
int w = GASelectionScheme::SCALED)
140 GARouletteWheelSelector(
const GARouletteWheelSelector &orig)
154 ~GARouletteWheelSelector()
override =
default;
157 return new GARouletteWheelSelector;
161 GASelectionScheme::copy(orig);
162 const GARouletteWheelSelector &sel =
163 DYN_CAST(
const GARouletteWheelSelector &, orig);
167 void update()
override;
171 std::vector<float> psum;
180 #if USE_TOURNAMENT_SELECTOR == 1
181 class GATournamentSelector :
public GARouletteWheelSelector
184 GADefineIdentity(
"GATournamentSelector", GAID::TournamentSelection);
186 explicit GATournamentSelector(
int w = GASelectionScheme::SCALED)
187 : GARouletteWheelSelector(w)
190 GATournamentSelector(
const GATournamentSelector &orig)
191 : GARouletteWheelSelector(orig)
202 ~GATournamentSelector()
override =
default;
205 return new GATournamentSelector;
216 #if USE_UNIFORM_SELECTOR == 1
220 GADefineIdentity(
"GAUniformSelector", GAID::UniformSelection);
222 explicit GAUniformSelector(
int w = GASelectionScheme::SCALED)
237 ~GAUniformSelector()
override =
default;
240 return new GAUniformSelector;
249 #if USE_SRS_SELECTOR == 1
253 GADefineIdentity(
"GASRSSelector", GAID::SRSSelection);
255 explicit GASRSSelector(
int w = GASelectionScheme::SCALED)
272 ~GASRSSelector()
override =
default;
275 return new GASRSSelector;
279 GASelectionScheme::copy(orig);
280 const GASRSSelector &sel = DYN_CAST(
const GASRSSelector &, orig);
282 fraction = sel.fraction;
283 choices = sel.choices;
286 void update()
override;
289 std::vector<float> fraction;
290 std::vector<unsigned int> choices;
298 #if USE_DS_SELECTOR == 1
302 GADefineIdentity(
"GADSSelector", GAID::DSSelection);
304 explicit GADSSelector(
int w = GASelectionScheme::SCALED)
321 ~GADSSelector()
override =
default;
324 return new GADSSelector;
328 GASelectionScheme::copy(orig);
329 const GADSSelector &sel = DYN_CAST(
const GADSSelector &, orig);
331 fraction = sel.fraction;
332 choices = sel.choices;
336 void update()
override;
339 std::vector<float> fraction;
340 std::vector<unsigned int> choices;
341 std::vector<unsigned int> idx;
The base genome class just defines the genome interface - how to mutate, crossover,...
Definition: GAGenome.h:200
This defines the identifiers for polymorphic classes.
Definition: gaid.h:20
Definition: GAPopulation.h:66
Definition: GASelector.h:55