Next: Module: Individual
Up: Source Code
Previous: Module: Parallel
  Contents
Subsections
1 /* Declarations of simulation features (backpropagation) */
2
3 #ifndef SIM_H
4 #define SIM_H 1
5
6 #include "defs.h"
7
8 char *SimOptStr();
9 char *SimUsage();
10 char SimParamStr[256];
11
12 float MaxErr; /* Maximum error for succes */
13 int MaxIter; /* Maximum no. of iterations */
14 int SeedRand; /* random seed */
15
16 int handleSimOpt(char opt,char* arg);
17 int initSim();
18
19 #endif
1 /* Declarations of simulation features (backpropagation) */
2
3 #include "defs.h"
4 #include "sim.h"
5
6 /* Parameter Handling */
7
8 #define DEFMAXITER 100000
9 #define DEFMAXERR 0.01
10 #define DEFSEED AUTO
11
12 char *SimOptStr() {return "g:e:s:\0";}
13
14 char *SimUsage() {return
15 "Simulation Parameters:\n"
16 "-g <max. no. of iterations:>: 10000\n"
17 "-e <max. error for succes>: 0.01\n"
18 "-s <random seed value>: time\n\0";
19 }
20
21 /* set default values */
22
23 int MaxIter =DEFMAXITER; /* Maximum no. of generations */
24 float MaxErr =DEFMAXERR; /* Maximum error for succes */
25 int SeedRand =DEFSEED; /* random seed */
26
27 int handleSimOpt(char opt,char* arg)
28 {
29 switch(opt)
30 {
31 case 'g': return (MaxIter =getint(arg,1,1000000000))<0;
32 case 'e': return getfloat(&MaxErr,arg,0,1000000);
33 case 's': return (SeedRand =getint(arg,0,MAXRANDOM))<0;
34 default: return 1;
35 };
36 }
37
38 int initSim()
39 {
40 if(SeedRand==AUTO) SeedRand=gettime();
41 seedrand(SeedRand);
42
43 sprintf(SimParamStr,
44 "Simulation: MaxIter = %d, MaxErr = %7.4f, Seed = %d\n",
45 MaxIter,MaxErr,SeedRand);
46 return 0;
47 }
48
(c) Bernhard Ömer - oemer@tph.tuwien.ac.at - http://tph.tuwien.ac.at/~oemer/