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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? unit1.c

?? 一個(gè)生產(chǎn)工序安排的算法(采用遺傳算法
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
//---------------------------------------------------------------------------

#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;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看av一区二区| 欧美韩国日本综合| 亚洲精品一区二区三区影院| 国产精品国产三级国产a| 亚洲国产一区二区在线播放| 欧美aⅴ一区二区三区视频| 成人午夜电影网站| 欧美一区二区三区公司| 一区二区三区免费网站| 美女一区二区三区| 91久久精品一区二区二区| 日韩一区二区高清| 亚洲人xxxx| 国产乱人伦偷精品视频不卡| 欧美性三三影院| 国产精品久久久久久福利一牛影视| eeuss鲁片一区二区三区| 欧美日韩一区在线观看| 亚洲欧洲日韩av| 国产高清精品在线| 精品免费视频一区二区| 丝袜a∨在线一区二区三区不卡| 捆绑紧缚一区二区三区视频| 欧美午夜影院一区| 国产欧美综合色| 久久电影网电视剧免费观看| 91精品国产日韩91久久久久久| 国产亚洲欧美色| 奇米精品一区二区三区在线观看 | 一区二区三区四区高清精品免费观看 | 麻豆一区二区三区| 成人免费视频一区| 国产偷国产偷精品高清尤物| 天堂午夜影视日韩欧美一区二区| 另类综合日韩欧美亚洲| 制服丝袜一区二区三区| 日本伊人色综合网| 欧美一级一区二区| 久久精品999| 欧美成人bangbros| 国产剧情一区二区| 国产网站一区二区三区| 成人激情免费网站| 亚洲欧美日韩国产中文在线| 99久久精品国产导航| 国产精品久久久久精k8| 色伊人久久综合中文字幕| 亚洲精品中文在线影院| 欧美私人免费视频| 五月婷婷激情综合| 欧美精品电影在线播放| 日本不卡视频一二三区| 欧美xxx久久| 国产精品一区久久久久| 国产精品精品国产色婷婷| 91久久免费观看| 蜜臀av亚洲一区中文字幕| 久久久久97国产精华液好用吗| 日韩av午夜在线观看| 久久久亚洲综合| 91免费观看视频| 欧美bbbbb| 国产精品狼人久久影院观看方式| 国产福利一区在线| 一区二区三区欧美| 精品国产伦一区二区三区观看体验| 精品一区二区影视| 亚洲同性gay激情无套| 欧美日韩黄色一区二区| 精品一区二区三区的国产在线播放 | 激情都市一区二区| 国产精品久久免费看| 欧美日韩亚洲国产综合| 九九国产精品视频| 亚洲美女免费在线| 久久久噜噜噜久久中文字幕色伊伊 | 国产精品视频一二三区| 国产成人亚洲综合a∨猫咪| 欧美精品久久99| 国产主播一区二区三区| 亚洲欧美日韩综合aⅴ视频| 欧美高清www午色夜在线视频| 免费在线观看日韩欧美| 亚洲黄色性网站| 久久久久久免费| 91视频在线观看免费| 蜜臀va亚洲va欧美va天堂| 国产精品二区一区二区aⅴ污介绍| 欧美特级限制片免费在线观看| 免费看精品久久片| 亚洲精品高清在线| 国产精品热久久久久夜色精品三区| 91一区一区三区| 一区二区三区日韩欧美| 欧美国产日韩a欧美在线观看| 91视频在线看| 99精品在线观看视频| 国产精品456露脸| 久久精品久久精品| 亚洲午夜精品17c| 亚洲免费色视频| 国产精品色呦呦| 久久精品视频免费观看| 精品av久久707| 精品国产一区二区三区久久久蜜月 | 成人毛片视频在线观看| 久久草av在线| 久久国产剧场电影| 蜜臀91精品一区二区三区| 亚洲一区在线观看免费| 亚洲日穴在线视频| 欧美激情在线一区二区| xf在线a精品一区二区视频网站| 色菇凉天天综合网| 日本韩国精品在线| 91浏览器打开| 色屁屁一区二区| 色婷婷久久久久swag精品 | 亚洲最色的网站| 亚洲免费在线电影| 亚洲免费av网站| 亚洲综合网站在线观看| 亚洲精品老司机| 亚洲大片精品永久免费| 日韩在线一二三区| 免费av网站大全久久| 精品一区在线看| 国产不卡在线视频| 99re成人精品视频| 欧亚一区二区三区| 欧美三级视频在线观看| 91精品国产一区二区| 精品蜜桃在线看| 日本一区二区三区视频视频| 亚洲欧美偷拍另类a∨色屁股| 国产精品免费aⅴ片在线观看| 国产亚洲精品福利| 中文字幕一区二区三区乱码在线| 国产精品女人毛片| 亚洲国产日产av| 麻豆精品一区二区av白丝在线| 六月婷婷色综合| 成人动漫一区二区| 欧美日韩一区小说| 欧美精品一区二区不卡| 亚洲色图20p| 美女在线观看视频一区二区| 大桥未久av一区二区三区中文| 国产一区二区三区免费在线观看| 风间由美中文字幕在线看视频国产欧美| 极品少妇xxxx精品少妇偷拍| 99精品国产99久久久久久白柏| 色综合色综合色综合色综合色综合| 日本韩国欧美国产| 精品不卡在线视频| 亚洲精品成人精品456| 久久精品国产精品亚洲综合| 99精品热视频| 精品播放一区二区| 亚洲一区二区影院| 国产成人日日夜夜| 欧美日韩国产一级| 国产精品久久久久久久久晋中| 亚洲一区二区三区四区在线| 国产一区二区伦理| 欧美视频三区在线播放| 国产日产精品1区| 日韩有码一区二区三区| 91免费看`日韩一区二区| wwwwxxxxx欧美| 日韩电影在线免费| 一本大道久久精品懂色aⅴ| 久久亚洲二区三区| 日本va欧美va瓶| 色狠狠一区二区三区香蕉| 国产免费观看久久| 毛片一区二区三区| 日本精品视频一区二区| 中文字幕欧美激情一区| 久久69国产一区二区蜜臀| 欧美猛男超大videosgay| 亚洲精品欧美综合四区| 福利电影一区二区三区| 久久综合色播五月| 男女性色大片免费观看一区二区 | av动漫一区二区| 精品成人佐山爱一区二区| 天天操天天色综合| 在线免费av一区| 一区二区三区成人| 99天天综合性| **性色生活片久久毛片| 成人免费看片app下载| 日本一区二区三区国色天香| 精品综合久久久久久8888| 日韩欧美国产综合一区| 麻豆精品视频在线观看视频| 欧美岛国在线观看| 精品一区二区三区影院在线午夜| 欧美日韩一区小说|