sim.c

来自「GENETIC ALGORITHM FOR NEURAL NETWORKS ON」· C语言 代码 · 共 49 行

C
49
字号
/* Declarations of simulation features (backpropagation) */#include "defs.h"#include "sim.h"/* Parameter Handling */#define DEFMAXITER	100000#define DEFMAXERR	0.01#define DEFSEED		AUTOchar *SimOptStr() {return "g:e:s:\0";}char *SimUsage() {return 	  "Simulation Parameters:\n"  "-g <max. no. of iterations:>:     10000\n"  "-e <max. error for succes>:       0.01\n"  "-s <random seed value>:           time\n\0";}/* set default values */int MaxIter	=DEFMAXITER;	/* Maximum no. of generations */float MaxErr	=DEFMAXERR;	/* Maximum error for succes */int SeedRand	=DEFSEED;	/* random seed */int handleSimOpt(char opt,char* arg){  switch(opt)  {    case 'g': return (MaxIter 	=getint(arg,1,1000000000))<0;    case 'e': return getfloat(&MaxErr,arg,0,1000000);    case 's': return (SeedRand	=getint(arg,0,MAXRANDOM))<0;    default: return 1;  };}int initSim(){  if(SeedRand==AUTO) SeedRand=gettime();  seedrand(SeedRand);  sprintf(SimParamStr,    "Simulation: MaxIter = %d, MaxErr = %7.4f, Seed = %d\n",    MaxIter,MaxErr,SeedRand);  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?