1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
3 | // See LICENSE.txt for details. |
---|
4 | |
---|
5 | #ifndef _PRECONFIGURED_GENETICS_H_ |
---|
6 | #define _PRECONFIGURED_GENETICS_H_ |
---|
7 | |
---|
8 | #include "genman.h" |
---|
9 | #include "defgenoconv.h" |
---|
10 | |
---|
11 | /** This class handles a typical initialization procedure and configuration of genetics: |
---|
12 | - adds converters between genetic formats as configured by gen-config.h, |
---|
13 | - validation of genotypes by dedicated genetic operators, or by conversion to f0 if no genetic operator is found that can validate a genotype. |
---|
14 | */ |
---|
15 | class PreconfiguredGenetics |
---|
16 | { |
---|
17 | public: |
---|
18 | DefaultGenoConvManager gcm; |
---|
19 | GenMan genman; |
---|
20 | ModelGenoValidator model_validator; //validation through conversion |
---|
21 | |
---|
22 | PreconfiguredGenetics() |
---|
23 | { |
---|
24 | gcm.addDefaultConverters(); //without converters, the application would only handle "format 0" genotypes |
---|
25 | Geno::useConverters(gcm); |
---|
26 | |
---|
27 | Geno::addValidator(&genman); //primary validation: use the extended validity checking (through dedicated genetic operators) |
---|
28 | Geno::addValidator(&model_validator); //secondary validation: this simple validator handles all cases when there is no dedicated genetic validation operator, but a converter for a particular format is available. Converters may be less strict in detecting invalid genotypes but using them and checking whether they produced a valid f0 genotype is also some way to tell whether the initial genotype was valid. Otherwise, without dedicated genetic validation operator, we would have no validity check at all. |
---|
29 | } |
---|
30 | }; |
---|
31 | |
---|
32 | /** Initialization procedure for applications adding their own validators */ |
---|
33 | class PreconfiguredGenetics_NoValidators |
---|
34 | { |
---|
35 | public: |
---|
36 | DefaultGenoConvManager gcm; |
---|
37 | |
---|
38 | PreconfiguredGenetics_NoValidators() |
---|
39 | { |
---|
40 | gcm.addDefaultConverters(); //without converters, the application would only handle "format 0" genotypes |
---|
41 | Geno::useConverters(gcm); |
---|
42 | } |
---|
43 | }; |
---|
44 | |
---|
45 | #endif |
---|
46 | |
---|