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

📄 external.h

📁 遗传算法的简单程序
💻 H
字号:
//头文件external.h 

/*----------------------------------------------------------------------------*/
/*           external.h - external global declarations from sga.h.            */
/*----------------------------------------------------------------------------*/ 

#define LINELENGTH 80                                    /* width of printout */
#define BITS_PER_BYTE 8            /* number of bits per byte on this machine */
#define UINTSIZE (BITS_PER_BYTE*sizeof(unsigned))    /* # of bits in unsigned */
#include <stdio.h> 
FILE *outfp, *infp;                                         /* file pointers */

/* Global structures and variables */
struct individual
{ 
    unsigned *chrom;                  /* chromosome string for the individual */
    double   fitness;                            /* fitness of the individual */
    int      xsite;                               /* crossover site at mating */
    int      parent[2];                  /* who the parents of offspring were */
    int      *utility;            /* utility field can be used as pointer toa */

                /* dynamically allocated, application-specific data structure */
}; 

struct bestever 
{ 
    unsigned *chrom;        /* chromosome string for the best-ever individual */
    double   fitness;                  /* fitness of the best-ever individual */ 
    int      generation;                      /* generation which produced it */
}; 

extern struct individual *oldpop;           /* last generation of individuals */ 
extern struct individual *newpop;           /* next generation of individuals */ 
extern struct bestever bestfit;                  /* fittest individual so far */ 
extern double sumfitness;             /* summed fitness for entire population */ 
extern double max;                           /* maximum fitness of population */ 
extern double avg;                           /* average fitness of population */ 
extern double min;                           /* minumum fitness of population */ 
extern float  pcross;                             /* probability of crossover */ 
extern float  pmutation;                           /* probability of mutation */ 
extern int    numfiles;                               /* number of open files */ 
extern int    popsize;                                     /* population size */ 
extern int    lchrom;              /* length of the chromosome per individual */ 
extern int    chromsize;     /* number of bytes needed to store lchrom string */ 
extern int    gen;                               /* current generation number */ 
extern int    maxgen;                            /* maximum generation number */ 
extern int    run;                                      /* current run number */ 
extern int    maxruns;                      /* maximum number of runs to make */ 
extern int    printstrings;  /* flag to print chromosome strings (default on) */ 
extern int    nmutation;                              /* number of mutations  */ 
extern int    ncross;                                /* number of crossovers  */ 

/* Application-dependent external declarations go after here...  */ 

⌨️ 快捷键说明

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