Changeset 145 for cpp/frams/_demos/genooper_test.cpp
- Timestamp:
- 02/26/14 20:21:22 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/genooper_test.cpp
r141 r145 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 5 #include <frams/genetics/genman.h>6 5 #include <frams/errmgr/stdouterr.h> 7 #include <frams/genetics/defgenoconv.h> 8 9 StdoutErrorHandler err; 10 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes 6 #include <frams/genetics/preconfigured.h> 11 7 12 8 void printGen(Geno &g) … … 25 21 int main(int argc, char *argv[]) 26 22 { 27 GenMan gm;28 Geno::validators.insert(0,&gm); //GenMan is available in this application so let's use the extended validity checking!29 // Note: insert() makes it the first validator in the list, this is important for formats that rely on genetic operators to perform reasonable validation, 30 // otherwise the default validator (genotype converter) would "win" and most converters are less strict in detecting invalid genotypes.31 g m.p_report(NULL, NULL);23 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output) 24 PreconfiguredGenetics genetics; 25 26 rndGetInstance().randomize(); 27 genetics.genman.p_report(NULL, NULL); 32 28 33 29 const char* src = (argc > 1) ? argv[1] : "/*9*/UUU"; 34 30 Geno gsrc(src, -1, "First"); 35 31 printGenAndTitle(gsrc, "source genotype (gsrc)"); 32 char format = gsrc.getFormat(); 36 33 37 Geno gmut = g m.Mutate(gsrc);34 Geno gmut = genetics.genman.Mutate(gsrc); 38 35 printGenAndTitle(gmut, "mutated (gmut)"); 39 36 40 Geno gxover = g m.CrossOver(gsrc, gmut);37 Geno gxover = genetics.genman.CrossOver(gsrc, gmut); 41 38 printGenAndTitle(gxover, "crossed over (gsrc and gmut)"); 42 39 43 Geno gsimplest = g m.GetSimplest('9');40 Geno gsimplest = genetics.genman.GetSimplest(format); 44 41 printGenAndTitle(gsimplest, "simplest"); 45 42 46 Geno ginvalid("IT'S REALLY WRONG", '9');43 Geno ginvalid("IT'S REALLY WRONG", format); 47 44 printGenAndTitle(ginvalid, "invalid"); 48 45 49 Geno gvalidated = g m.Validate(ginvalid);46 Geno gvalidated = genetics.genman.Validate(ginvalid); 50 47 printGenAndTitle(gvalidated, "validated"); 51 48 52 printf("\nHTMLized: %s\n", (const char*)g m.HTMLize((const char*)gvalidated.getGene()));49 printf("\nHTMLized: %s\n", (const char*)genetics.genman.HTMLize((const char*)gvalidated.getGene())); 53 50 54 51 return 0;
Note: See TracChangeset
for help on using the changeset viewer.