⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 petrol.h

📁 比较完整的遗传算法的源代码
💻 H
字号:
#ifndef _PETROL_H#define _PETROL_H#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endif#define PETROL_CHROMOSOME_LEN	100#define PETROL_PROB_CROSSOVER	0.66#define PETROL_PROB_MUTATION	0.001#define PETROL_NUM_GEN		500#define PETROL_POP_SIZE		100#define PETROL_MAXIMIZE		TRUE#define PETROL_PACKET_SIZE	10typedef struct {  int    *chrom;  int     chromLen;  double  fitness;} Individual;typedef Individual INDIVIDUAL;typedef Individual *IPTR;typedef struct {  Individual *pop;  int         popSize;  int         chromosomeLen;  double      probCrossover;  double      probMutation;  int         numGenerations;    int         maximize;  int         numMutations;  int         numCrossovers;  int         maxFitness;  int         minFitness;  double      sumFitness;  double      avgFitness;} Population;typedef struct {  int     verbose;  char   *outputFile;  int     packetSize;  } Settings;void ReportSetup(Settings *s);void ReportInitial(Settings *s, Population *p);void ReportGeneration(Settings *s, Population *p, int g);void ReportDone(Settings *s, Population *p);void ReportCrossover(Population *p, Individual *p1, Individual *p2,		     Individual *c1, Individual *c2, int point);void PopulationRun(Settings *s, Population *p);double Fitness(Individual *i);#ifdef USE_PVM#define PETROL_WORK		100#define PETROL_WORK_REQUEST	101#define PETROL_WORK_INDIVIDUALS	102#define PETROL_WORK_DONE	103void PVMFitness(Settings *s, Population *p);void PVMExit(void);#endif /* USE_PVM */#endif /* _PETROL_H */

⌨️ 快捷键说明

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