Changeset 520 for cpp/frams/_demos/saver_test_geno.cpp
- Timestamp:
- 06/22/16 16:41:58 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/saver_test_geno.cpp
r517 r520 11 11 12 12 \include saver_test_geno.cpp 13 */13 */ 14 14 15 int main(int argc, char*argv[])15 int main(int argc, char*argv[]) 16 16 { 17 if (argc<3)17 if (argc < 3) 18 18 { 19 fprintf(stderr,"Arguments: filename number_of_genotypes\n"20 21 );22 return 1;19 fprintf(stderr, "Arguments: filename number_of_genotypes\n" 20 "Example: saver_test_geno file.gen 3\n" 21 ); 22 return 1; 23 23 } 24 24 25 StdioFileSystem_autoselect stdiofilesys;26 VirtFILE *f=Vfopen(argv[1],"w");27 if (f)25 StdioFileSystem_autoselect stdiofilesys; 26 VirtFILE *f = Vfopen(argv[1], "w"); 27 if (f) 28 28 { 29 int N=atoi(argv[2]);30 MiniGenotype g;31 Param p(minigenotype_paramtab,&g);32 g.clear();33 printf("Saving %d genotypes to %s\n",N,argv[1]);34 for(int i=1;i<=N;i++)29 int N = atoi(argv[2]); 30 MiniGenotype g; 31 Param p(minigenotype_paramtab, &g); 32 g.clear(); 33 printf("Saving %d genotypes to %s\n", N, argv[1]); 34 for (int i = 1; i <= N; i++) 35 35 { 36 g.name=SString::sprintf("Genotype#%d",i);37 g.genotype=""; for(int x=0;x<i;x++) g.genotype+="X";38 g.velocity=0.1*i;39 g.energy0=1;40 g.info="Saved by saver_test_geno.cpp";41 g.is_valid=1;42 p.save(f,"org");36 g.name = SString::sprintf("Genotype#%d", i); 37 g.genotype = ""; for (int x = 0; x < i; x++) g.genotype += "X"; 38 g.velocity = 0.1*i; 39 g.energy0 = 1; 40 g.info = "Saved by saver_test_geno.cpp"; 41 g.is_valid = 1; 42 p.save(f, "org"); 43 43 } 44 delete f;45 return 0;44 delete f; 45 return 0; 46 46 } 47 else47 else 48 48 { 49 printf("Could not write to %s\n",argv[1]);50 return 1;49 printf("Could not write to %s\n", argv[1]); 50 return 1; 51 51 } 52 52 }
Note: See TracChangeset
for help on using the changeset viewer.