📄 seq.c
字号:
/* Implementation of sequential features */#include "defs.h"#include "seq.h"/* Parameter Handling */#define DEFPOPSIZE 100#define DEFMAXGEN 10000#define DEFMAXERR 0.01#define DEFSEED AUTOchar *SeqOptStr() {return "p:g:e:s:\0";}char *SeqUsage() {return "Simulation Parameters:\n" "-p <population size>: 100\n" "-g <max. no. of generations>: 10000\n" "-e <max. error for succes>: 0.01\n" "-s <random seed value>: time\n\0";}/* set default values */int PopSize =DEFPOPSIZE; /* size of actual population */int MaxGen =DEFMAXGEN; /* Maximum no. of generations */errtyp MaxErr =DEFMAXERR; /* Maximum error for succes */int SeedRand =DEFSEED; /* random seed */int handleSeqOpt(char opt,char* arg){ switch(opt) { case 'p': return (PopSize =getint(arg,2,1000000))<0; case 'g': return (MaxGen =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; };}void errorexit(char *msg){ printf(msg); exit(1);}int initSeq(){ if(SeedRand==AUTO) SeedRand=gettime(); seedrand(SeedRand); sprintf(SeqParamStr, "Simulation: serial, PopSize = %d, MaxGen = %d, " "MaxErr = %7.4f\n RandomSeed = %d\n", PopSize,MaxGen,MaxErr,SeedRand); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -