亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? unit1.c

?? 一個生產工序安排的算法(采用遺傳算法
?? C
?? 第 1 頁 / 共 2 頁
字號:
//---------------------------------------------------------------------------

#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
//int main(int argc, char* argv[])
//{
//        return 0;
//}
//---------------------------------------------------------------------------



/**************************************************************************/
/* This is a simple genetic algorithm implementation where the */
/* evaluation function takes positive values only and the      */
/* fitness of an individual is the same as the value of the    */
/* objective function                                          */
/**************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* Change any of these parameters to match your needs */

#define POPSIZE 50               /* population size */
#define MAXGENS 60             /* max. number of generations */
#define NVARS 8                  /* no. of problem variables */
#define PXOVER 0.89               /* probability of crossover */
#define PMUTATION 0.29           /* probability of mutation */
#define TRUE 1
#define FALSE 0

int generation;                  /* current generation no. */
int cur_best;                    /* best individual */
FILE *galog;                     /* an output file */

#define NMACHINE 4          /* Number of machines */
#define MAXTIME 1000000          /* THE MAX OF ALL CONSUMING TIME.. (UNIT IN SECOND) */

double time_consuming[NMACHINE][NVARS];

struct genotype /* genotype (GT), a member of the population */
{
  double gene[NVARS];        /* a string of variables */
  double fitness;            /* GT's fitness */
  double upper[NVARS];       /* GT's variables upper bound */
  double lower[NVARS];       /* GT's variables lower bound */
  double rfitness;           /* relative fitness */
  double cfitness;           /* cumulative fitness */
};

struct genotype population[POPSIZE+1];    /* population */
struct genotype newpopulation[POPSIZE+1]; /* new population; */
                                          /* replaces the */
                                          /* old generation */

/* Declaration of procedures used by this genetic algorithm */

void initialize(void);
unsigned int randval(void);
void evaluate(void);
void keep_the_best(void);
void elitist(void);
void select(void);
void crossover(void);
void Xover(int,int);
void swap(double *, double *);
void mutate(void);
void report(void);

/***************************************************************/
/* Initialization function: Initializes the values of genes    */
/* within the variables bounds. It also initializes (to zero)  */
/* all fitness values for each member of the population. It    */
/* reads upper and lower bounds of each variable from the      */
/* input file `gadata.txt'. It randomly generates values       */
/* between these bounds for each gene of each genotype in the  */
/* population. The format of the input file `gadata.txt' is    */
/* var1_lower_bound var1_upper bound                           */
/* var2_lower_bound var2_upper bound ...                       */
/***************************************************************/

void initialize(void)
{
FILE *infile;
int i, j;
double lbound, ubound;

if ((infile = fopen("gadata.txt","r"))==NULL)
      {
      fprintf(galog,"\nCannot open input file!\n");
      exit(1);
      }

/* initialize the time_consuming[][] from file */
for(i = 0; i < NVARS; i++) 
	{
	for(j = 0; j < NMACHINE; j ++) 
		{
		fscanf(infile, "%lf",&time_consuming[j][i]);
		}
	}


/* initialize variables within the bounds */

for (i = 0; i < NVARS; i++)
      {
      fscanf(infile, "%lf",&lbound);
      fscanf(infile, "%lf",&ubound);

      for (j = 0; j < POPSIZE; j++)
           {
           population[j].fitness = 0;
           population[j].rfitness = 0;
           population[j].cfitness = 0;
           population[j].lower[i] = 0;
           population[j].upper[i]= 0;
           population[j].gene[i] = randval();
           }
      }

fclose(infile);
}

/***********************************************************/
/* Random value generator: Generates a value within bounds */
/***********************************************************/

unsigned int randval(void)
{
double val;
val = ((double)(rand()%1000)/1000.0);
return ((unsigned int)(val*NMACHINE));
}

/*************************************************************/
/* Evaluation function: This takes a user defined function.  */
/* Each time this is changed, the code has to be recompiled. */
/* The current function is:  x[1]^2-x[1]*x[2]+x[3]           */
/*************************************************************/
/* ****************************************************** */
/* Here is the user defined function:  the time consuming is less */

void evaluate(void)
{
int mem;
int i;
int machine;
double consuming[NMACHINE];
double max_consuming;

for (mem = 0; mem < POPSIZE; mem++)
      {
      for(i = 0; i < NMACHINE; i ++) consuming[i] = 0; // clear
      for (i = 0; i < NVARS; i++) {
      	machine = population[mem].gene[i];
  			if(machine >= NMACHINE) { // not neede for speed here, but filter the data 
					fprintf(galog,"\nThe initialize error!\n");
					exit(1);
				}
        consuming[machine] += time_consuming[machine][i];
      }
      // get the maxium time as fitness.
      max_consuming = 0;;
      for(i = 0; i < NMACHINE; i ++) {
      	if(consuming[i] > max_consuming) 
      		max_consuming = consuming[i];
      }
      population[mem].fitness = MAXTIME - max_consuming;
      }      
}

/***************************************************************/
/* Keep_the_best function: This function keeps track of the    */
/* best member of the population. Note that the last entry in  */
/* the array Population holds a copy of the best individual    */
/***************************************************************/

void keep_the_best()
{
int mem;
int i;
cur_best = 0; /* stores the index of the best individual */

for (mem = 0; mem < POPSIZE; mem++)
      {
      if (population[mem].fitness > population[POPSIZE].fitness)
            {
            cur_best = mem;
            population[POPSIZE].fitness = population[mem].fitness;
            }
      }
/* once the best member in the population is found, copy the genes */
for (i = 0; i < NVARS; i++)
      population[POPSIZE].gene[i] = population[cur_best].gene[i];
}






/****************************************************************/
/* Elitist function: The best member of the previous generation */
/* is stored as the last in the array. If the best member of    */
/* the current generation is worse then the best member of the  */
/* previous generation, the latter one would replace the worst  */
/* member of the current population                             */
/****************************************************************/

void elitist()
{
int i;
double best, worst;             /* best and worst fitness values */
int best_mem, worst_mem; /* indexes of the best and worst member */

best = population[0].fitness;
worst = population[0].fitness;
for (i = 0; i < POPSIZE - 1; ++i)
      {
      if(population[i].fitness > population[i+1].fitness)
            {      
            if (population[i].fitness >= best)
                  {
                  best = population[i].fitness;
                  best_mem = i;
                  }
            if (population[i+1].fitness <= worst)
                  {
                  worst = population[i+1].fitness;
                  worst_mem = i + 1;
                  }
            }
      else
            {
            if (population[i].fitness <= worst)
                  {
                  worst = population[i].fitness;
                  worst_mem = i;
                  }
            if (population[i+1].fitness >= best)
                  {
                  best = population[i+1].fitness;
                  best_mem = i + 1;
                  }
            }
      }
/* if best individual from the new population is better than */
/* the best individual from the previous population, then    */
/* copy the best from the new population; else replace the   */
/* worst individual from the current population with the     */
/* best one from the previous generation                     */

if (best >= population[POPSIZE].fitness)
    {
    for (i = 0; i < NVARS; i++)
       population[POPSIZE].gene[i] = population[best_mem].gene[i];
    population[POPSIZE].fitness = population[best_mem].fitness;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲图片小说| 激情图区综合网| 看电视剧不卡顿的网站| 国产乱色国产精品免费视频| 成人免费视频caoporn| 一本色道久久综合亚洲aⅴ蜜桃 | 国产欧美精品区一区二区三区| 国产欧美日韩精品a在线观看| 亚洲一区在线观看网站| 久久精品国产亚洲aⅴ| 99久久精品国产观看| 555夜色666亚洲国产免| 日本一区二区成人| 亚洲成人av福利| 国产精品系列在线播放| 欧美亚洲丝袜传媒另类| 久久亚洲免费视频| 亚洲综合久久久| 国产高清在线精品| 欧美日韩高清在线播放| 国产欧美精品一区aⅴ影院| 五月婷婷久久综合| 成人毛片在线观看| 日韩午夜精品电影| 亚洲人午夜精品天堂一二香蕉| 精品一区二区三区日韩| 99久久精品国产毛片| 精品久久久久久综合日本欧美| 亚洲色图欧洲色图婷婷| 久久不见久久见中文字幕免费| 91视频在线观看免费| 精品成人一区二区三区四区| 亚洲黄色片在线观看| 国产不卡免费视频| 欧美精选一区二区| 亚洲欧美一区二区三区国产精品| 国产一区二区在线影院| 777奇米成人网| 亚洲人成精品久久久久久| 国产一区二区在线观看视频| 欧美人与禽zozo性伦| 亚洲丝袜精品丝袜在线| 国产精品18久久久| 欧美成人午夜电影| 午夜a成v人精品| 99精品视频一区| 国产视频不卡一区| 六月婷婷色综合| 欧美日韩成人在线一区| 一区二区三区在线免费视频| 成人不卡免费av| 国产欧美日韩在线| 国产精品一区二区不卡| 精品播放一区二区| 美国精品在线观看| 91麻豆精品久久久久蜜臀| 亚洲一区二区三区精品在线| 色噜噜久久综合| 国产精品国产三级国产aⅴ入口 | 国产精品久线在线观看| 国产精品一二三四| 欧美va亚洲va| 久久福利资源站| 精品国产一区二区在线观看| 日本视频免费一区| 欧美一级在线观看| 免费成人在线网站| 日韩三级高清在线| 久久99最新地址| 26uuu国产电影一区二区| 国内精品视频666| 久久婷婷久久一区二区三区| 精品系列免费在线观看| 久久综合精品国产一区二区三区| 激情亚洲综合在线| 久久精品一区蜜桃臀影院| 国产成人高清在线| 中文字幕电影一区| 91视频免费播放| 一区二区三区国产豹纹内裤在线| 91视频免费播放| 悠悠色在线精品| 欧美性猛片aaaaaaa做受| 亚洲成人资源在线| 欧美一区二区精品| 国产综合久久久久久久久久久久| 久久久久国产精品麻豆ai换脸| 国产成人福利片| 亚洲图片你懂的| 欧美在线免费播放| 日韩精品一二三区| 精品黑人一区二区三区久久| 久久99精品国产麻豆不卡| 久久久不卡影院| 成人av在线影院| 亚洲一区二区三区在线看| 欧美高清www午色夜在线视频| 久久狠狠亚洲综合| 国产日韩欧美一区二区三区乱码 | 最近中文字幕一区二区三区| 色综合天天综合狠狠| 亚洲一区二区欧美日韩| 欧美一区二区成人| 国产suv精品一区二区6| 亚洲精品国产品国语在线app| 777奇米成人网| 国产91精品一区二区麻豆亚洲| 亚洲男人电影天堂| 日韩一二三区视频| 成人一区二区视频| 天使萌一区二区三区免费观看| 久久久久免费观看| 色香蕉成人二区免费| 日韩成人免费电影| 国产欧美日韩不卡免费| 欧美日韩你懂得| 国产成人精品影视| 天涯成人国产亚洲精品一区av| 久久久国产午夜精品| 欧美亚洲日本一区| 国产成人免费9x9x人网站视频| 亚洲成人av在线电影| 国产亚洲一区二区三区在线观看| 91国模大尺度私拍在线视频| 九色综合狠狠综合久久| 亚洲免费大片在线观看| 精品国精品自拍自在线| 一本色道久久综合亚洲aⅴ蜜桃 | 久久精品一区二区三区四区| 欧美视频完全免费看| 国产成人av影院| 日一区二区三区| 亚洲视频一区在线| 精品国产一区二区三区久久影院| 9i在线看片成人免费| 久久99热这里只有精品| 亚洲一区二区三区自拍| 国产精品久久久久影院老司| 日韩精品中文字幕在线一区| 色综合天天综合| 成人在线视频一区| 国内偷窥港台综合视频在线播放| 亚洲国产日韩综合久久精品| 国产欧美一区二区精品性| 3d动漫精品啪啪| 欧美视频一二三区| 一本久久a久久精品亚洲| 国产精品一二三区在线| 麻豆成人综合网| 日韩精品一区第一页| 一区二区三区电影在线播| 日本一区二区在线不卡| 欧美电视剧免费观看| 欧美日韩精品欧美日韩精品| 色综合网色综合| 波多野洁衣一区| 国产不卡免费视频| 国产精品一二三区| 极品少妇一区二区| 日韩不卡一二三区| 午夜成人在线视频| 午夜影院久久久| 亚洲专区一二三| 亚洲自拍偷拍网站| 亚洲综合无码一区二区| 亚洲精品水蜜桃| 成人欧美一区二区三区黑人麻豆| 亚洲国产精品二十页| 久久久99精品免费观看不卡| 久久综合给合久久狠狠狠97色69| 日韩一卡二卡三卡| 日韩视频在线你懂得| 欧美一级爆毛片| 日韩欧美一级二级三级| 欧美一区二区福利在线| 日韩限制级电影在线观看| 日韩一区二区三区在线| 91麻豆精品国产91久久久更新时间| 欧美三级欧美一级| 欧美日韩在线观看一区二区| 欧美在线观看视频一区二区三区| 色综合久久中文综合久久97| 一本色道久久综合亚洲aⅴ蜜桃 | 亚洲综合色视频| 亚洲电影你懂得| 亚洲成a人v欧美综合天堂| 五月激情综合网| 青娱乐精品在线视频| 久久精品久久精品| 精品一区二区三区香蕉蜜桃| 国产精选一区二区三区| 国产99一区视频免费| 成人a区在线观看| 在线免费观看日本欧美| 欧美日韩精品系列| 日韩欧美视频在线| 亚洲国产成人在线| 亚洲欧美成人一区二区三区| 亚洲午夜私人影院| 免费人成网站在线观看欧美高清|