Changeset 145 for cpp/frams/_demos
- Timestamp:
- 02/26/14 20:21:22 (11 years ago)
- Location:
- cpp/frams/_demos
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/f0_variants_test.cpp
r121 r145 8 8 #include <frams/virtfile/stdiofile.h> 9 9 10 #include <frams/genetics/defgenoconv.h> 10 11 #include <frams/model/model.h> 11 #include <frams/genetics/defgenoconv.h>12 12 #include <frams/errmgr/stdouterr.h> 13 14 StdoutErrorHandler err; //redirect model-related errors to stdout15 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes16 13 17 14 void save_as_f0(SString &gen,Model &m,bool omit_default_values) … … 77 74 int main(int argc,char*argv[]) 78 75 { 76 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output) 77 78 //without converters the application would only handle "format 0" genotypes 79 DefaultGenoConvManager gcm; 80 gcm.addDefaultConverters(); 81 Geno::useConverters(gcm); 82 83 ModelGenoValidator model_validator; 84 Geno::addValidator(&model_validator); //This simple validator handles all cases where a converter for a particular format is available but there is no genetic operator. Converters may be less strict in detecting invalid genotypes but it is better than nothing 85 79 86 SString gen(argc>1?argv[1]:"X[|G:1.23]"); 80 87 if (!strcmp(gen,"-")) -
cpp/frams/_demos/full_props.cpp
r121 r145 9 9 10 10 #include <frams/model/model.h> 11 #include <frams/genetics/defgenoconv.h>12 11 #include <frams/errmgr/stdouterr.h> 12 #include <frams/genetics/preconfigured.h> 13 13 14 14 /** … … 47 47 */ 48 48 49 //optional:50 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes51 52 49 int main(int argc,char*argv[]) 53 50 { 54 51 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err 55 52 StdoutErrorHandler err(ErrorHandlerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout 53 54 PreconfiguredGenetics genetics; 56 55 57 56 bool reverse=false; -
cpp/frams/_demos/gdk_test.cpp
r121 r145 9 9 10 10 #include <frams/model/model.h> 11 #include <frams/genetics/ defgenoconv.h>11 #include <frams/genetics/preconfigured.h> 12 12 #include <frams/errmgr/stdouterr.h> 13 13 … … 18 18 19 19 StdoutErrorHandler err; //redirect model-related errors to stdout 20 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes 20 PreconfiguredGenetics genetics; 21 21 22 22 void printNiceBanner(const char* title) … … 258 258 void findingConverters() 259 259 { 260 GenoConverter *gc= gcm.findConverters(0,'1');260 GenoConverter *gc=Geno::getConverters().findConverters(0,'1'); 261 261 if (gc) printf("found converter accepting f1: \"%s\"\n",gc->name); 262 262 SListTempl<GenoConverter*> found; 263 gcm.findConverters(&found,-1,'0');263 Geno::getConverters().findConverters(&found,-1,'0'); 264 264 printf("found %d converter(s) producing f0\n",found.size()); 265 265 } -
cpp/frams/_demos/geno_test.cpp
r141 r145 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 5 #include <frams/genetics/geno.h>6 5 #include <frams/virtfile/stdiofile.h> 7 6 #include <frams/util/sstringutils.h> 8 #include <frams/genetics/defgenoconv.h> 9 #include <frams/genetics/genman.h> 7 #include <frams/genetics/preconfigured.h> 10 8 11 9 /** … … 16 14 */ 17 15 18 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes19 20 16 int main(int argc,char*argv[]) 21 17 { 22 GenMan gm; 23 Geno::validators.insert(0,&gm); //GenMan is available in this application so let's use the extended validity checking! 24 // Note: insert() makes it the first validator in the list, this is important for formats that rely on genetic operators to perform reasonable validation, 25 // otherwise the default validator (genotype converter) would "win" and most converters are less strict in detecting invalid genotypes. 18 PreconfiguredGenetics genetics; 19 26 20 if (argc<=1) 27 21 { -
cpp/frams/_demos/genoconv_test.cpp
r136 r145 10 10 #include "printconvmap.h" 11 11 #include <frams/errmgr/stdouterr.h> 12 13 StdoutErrorHandler err;14 12 15 13 /** … … 119 117 int main(int argc,char *argv[]) 120 118 { 119 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output) 120 121 121 DefaultGenoConvManager gcm; 122 gcm.addDefaultConverters(); 122 123 gcm.addConverter(new GenoConv_Test()); 123 124 gcm.addConverter(new GenoConv_Test2()); 124 125 gcm.addConverter(new GenoConv_Test3()); 126 Geno::useConverters(gcm); 127 128 ModelGenoValidator model_validator; 129 Geno::addValidator(&model_validator); 125 130 126 131 const char* src=(argc>1)?argv[1]:"X"; -
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; -
cpp/frams/_demos/multiline_f0_test.cpp
r124 r145 8 8 #include <frams/virtfile/stdiofile.h> 9 9 10 #include <frams/genetics/preconfigured.h> 10 11 #include <frams/model/model.h> 11 #include <frams/genetics/defgenoconv.h>12 12 #include <frams/errmgr/stdouterr.h> 13 13 #include <frams/virtfile/stringfile.h> 14 14 15 StdoutErrorHandler err; //redirect model-related errors to stdout16 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes17 18 15 int main(int argc,char*argv[]) 19 16 { 17 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output) 18 PreconfiguredGenetics genetics; 19 20 20 SString gen(argc>1?argv[1]:"X[|G:1.23]"); 21 21 if (!strcmp(gen,"-")) -
cpp/frams/_demos/neuro_layout_test.cpp
r135 r145 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 5 #include <frams/genetics/geno.h>6 5 #include <frams/virtfile/stdiofile.h> 7 6 #include <frams/util/sstringutils.h> 8 #include <frams/genetics/ defgenoconv.h>7 #include <frams/genetics/preconfigured.h> 9 8 #include <frams/model/model.h> 10 9 #include <frams/errmgr/stdouterr.h> … … 20 19 loader_test "data/walking.gen" "Walking Lizard" | neuro_layout_test - 21 20 */ 22 23 StdoutErrorHandler err; //redirect model-related errors to stdout24 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes25 21 26 22 // stl is fun? ;-) ForwardIterator implementation for element coordinates (required by min_element/max_element) … … 87 83 int main(int argc,char*argv[]) 88 84 { 85 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output) 86 PreconfiguredGenetics genetics; 87 89 88 if (argc<=1) 90 89 { -
cpp/frams/_demos/neuro_test.cpp
r121 r145 6 6 #include <frams/virtfile/stdiofile.h> 7 7 #include <frams/util/sstringutils.h> 8 #include <frams/genetics/ defgenoconv.h>8 #include <frams/genetics/preconfigured.h> 9 9 #include <frams/neuro/neuroimpl.h> 10 10 #include <frams/neuro/neurofactory.h> … … 15 15 Sample code: Neural network tester (can run your custom neurons) 16 16 */ 17 18 StdoutErrorHandler err; //redirect model-related errors to stdout19 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes20 17 21 18 #ifndef GDK_WITHOUT_FRAMS … … 63 60 int main(int argc,char*argv[]) 64 61 { 62 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output) 63 PreconfiguredGenetics genetics; 64 65 65 if (argc<=1) 66 66 {
Note: See TracChangeset
for help on using the changeset viewer.