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

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

?? userdefinables.cpp

?? 遺傳算法(Genetic Algorithm)是一類借鑒生物界的進化規律(適者生存
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
/***************************************************************/* Single & Multi-Objective Real-Coded Genetic Algorithms Code *//* Author: Kumara Sastry                                       *//* Illinois Genetic Algorithms Laboratory (IlliGAL)            *//* Deparment of General Engineering                            *//* University of Illinois at Urbana-Champaign                  *//* 104 S. Mathews Ave, Urbana, IL 61801                        *//***************************************************************/#include <iostream>#include <iomanip>#include "ga.hpp"#include "random.hpp"#include "globalSetup.hpp"#include <math.h>#define BLANK_STR " \t\n\r"using namespace std;GlobalSetup *globalSetup;Random myRandom;/* Objective function and constraints go here */void globalEvaluate(double *x, double *objArray, double *constraintViolation,		    double *penalty, int *noOfViolations){  int ii;  FILE *outEvals;   for(ii = 0; ii < globalSetup->finalNoOfObjectives; ii++)    objArray[ii] = 0.0;    if(globalSetup->gaType == SGA) {    *objArray = (x[0]*x[0] + x[1] - 11.0)*(x[0]*x[0] + x[1] - 11.0) +      (x[0] + x[1]*x[1] - 7.0)*(x[0] + x[1]*x[1] - 7.0);    constraintViolation[0] = (x[0]-5.0)*(x[0]-5.0) + x[1]*x[1] - 26.0;    if(constraintViolation[0] <= 0.0) constraintViolation[0] = 0.0;        constraintViolation[1] = 4*x[1] + x[2] - 20.0;    if(constraintViolation[1] <= 0.0) constraintViolation[1] = 0.0;  }  else {    objArray[0] = -10*exp(-0.2*sqrt(x[0]*x[0] + x[1]*x[1])) - 10*exp(-0.2*sqrt(x[1]*x[1] + x[2]*x[2]));    objArray[1] = pow(fabs(x[0]),0.8) + pow(fabs(x[1]),0.8) + pow(fabs(x[2]),0.8) + 5.0*sin(x[0]*x[0]*x[0]) + 5.0*sin(x[1]*x[1]*x[1]) + 5.0*sin(x[2]*x[2]*x[2]);  }  *penalty = 0.0;    *noOfViolations = 0;  for(ii = 0; ii < globalSetup->finalNoOfConstraints; ii++) {    if(constraintViolation[ii]) ++(*noOfViolations);    if(globalSetup->constraintMethod == Penalty) {      if(globalSetup->penaltyFunction == Linear) 	*penalty += globalSetup->penaltyWeights[ii]*fabs(constraintViolation[ii]);      else if(globalSetup->penaltyFunction == Quadratic)	*penalty += globalSetup->penaltyWeights[ii]*	  (constraintViolation[ii]*constraintViolation[ii]);    }    else      *penalty += fabs(constraintViolation[ii]);  }  if(globalSetup->savePopulation) {    outEvals = fopen(globalSetup->saveEvalSolutions, "a");    for(ii = 0; ii < globalSetup->noOfDecisionVariables; ii++) {      fprintf(outEvals, "%f\t", x[ii]);    }      for(ii = 0; ii < globalSetup->finalNoOfObjectives; ii++) {      fprintf(outEvals, "%f\t", objArray[ii]);    }    if(globalSetup->finalNoOfConstraints > 0) {      for(ii = 0; ii < globalSetup->finalNoOfConstraints; ii++) {	fprintf(outEvals, "%f\t", constraintViolation[ii]);      }      fprintf(outEvals, "%f", *penalty);    }    fprintf(outEvals, "\n");    fflush(outEvals);    fclose(outEvals);  }}/*  Read a non-comment, non-blank line from the specified file stream  At EOF, it returns NULL.  Otherwise, it returns the pointer to the first token.  (The string just read in is altered by strtok().)*/static char* readOneLine(char *pcBuf, int iMaxSize, FILE *fStream){  char *pToken;    do {    pToken = NULL;        *pcBuf = '\0';    fgets(pcBuf, iMaxSize, fStream);    if (feof(fStream))      break;        // get the first token    pToken = strtok(pcBuf, BLANK_STR);        // if there is no first token, it is a blank line.    // if the first token starts with '#', it is a comment line.  } while ((pToken == NULL) || (*pToken == '#'));     return (pToken);}  int main(int argc, char *argv[]) {  int ii;  const int ciBufSize = 1024;  char *pToken, caBuf[ciBufSize];  FILE *fInput, *fOutput;  if(argc != 2) {    printf("Error! Usage is GAtbx inputfile\n");    exit(1);  }  fInput = fopen(argv[1], "r");  if (fInput == NULL) {    printf("Error! opening file %s\n", argv[1]);    exit(1);  }           globalSetup = new GlobalSetup;    if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  //GA type  if (strcmp("SGA", pToken) == 0) {    globalSetup->gaType = SGA;  }  else if (strcmp("NSGA", pToken) == 0) {    globalSetup->gaType = NSGA;  }  else {    fclose(fInput);    printf("Unknown parameter! It should be either SGA or NSGA\n");    exit(1);  }  // decision variables    // read the number of decision variables  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  // the number can't be less than or equal to zero  if ((globalSetup->noOfDecisionVariables = atoi(pToken)) <= 0) {    fclose(fInput);    printf("Error! number of decision variables should be > 0\n");    exit(1);  }  globalSetup->variableTypes = new VariableType[globalSetup->noOfDecisionVariables];  globalSetup->variableRanges = new double*[(globalSetup->noOfDecisionVariables)];  for(ii = 0; ii < globalSetup->noOfDecisionVariables; ii++) {    // read a line    if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {      fclose(fInput);      printf("Error in the input file, please refer to the documentation\n");      exit(1);    }    // variable type    if (strcmp("double", pToken) == 0) {      globalSetup->variableTypes[ii] = Real;    }    else if (strcmp("int", pToken) == 0) {      globalSetup->variableTypes[ii] = Integer;    }    else {      fclose(fInput);      printf("Error in the input file, please refer to the documentation\n");      exit(1);    }        // variable ranges    // allocate memory    globalSetup->variableRanges[ii] = new double[2];    // lower bound    if ((pToken = strtok(NULL, BLANK_STR)) == NULL) {      fclose(fInput);      printf("Error in the input file, please refer to the documentation\n");      exit(1);    }    globalSetup->variableRanges[ii][0] = atof(pToken);    // upper bound    if ((pToken = strtok(NULL, BLANK_STR)) == NULL) {      fclose(fInput);      printf("Error in the input file, please refer to the documentation\n");      exit(1);    }    globalSetup->variableRanges[ii][1] = atof(pToken);    if(globalSetup->variableRanges[ii][1] <= globalSetup->variableRanges[ii][0]) {      fclose(fInput);      printf("Error! lower bound, %f, must be lower than the upper bound, %f\n", globalSetup->variableRanges[ii][0], globalSetup->variableRanges[ii][1]);      exit(1);    }  }  // objectives    // read the number of objectives  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  // the number can't be less than or equal to zero  if ((globalSetup->noOfRawObjectives = atoi(pToken)) <= 0) {    fclose(fInput);    printf("Error! number of objectives should be > 0\n");    exit(1);  }  globalSetup->finalNoOfObjectives = globalSetup->noOfRawObjectives;  globalSetup->noOfLinearObjectiveCombinations = 0;  globalSetup->typeOfOptimizations = new OptimType[globalSetup->finalNoOfObjectives];  for(ii = 0; ii < globalSetup->finalNoOfObjectives; ii++) {    // read a line    if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {      fclose(fInput);      printf("Error in the input file, please refer to the documentation\n");      exit(1);    }    // optimization type    if (strcmp("Min", pToken) == 0) {      globalSetup->typeOfOptimizations[ii] = Minimization;    }    else if (strcmp("Max", pToken) == 0) {      globalSetup->typeOfOptimizations[ii] = Maximization;    }    else {      fclose(fInput);      printf("Error! optimization type can either be Min or Max\n");      exit(1);    }   }  // constrained variables  // read the number of constrained variables  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  // the number can't be less than zero  if ((globalSetup->noOfRawConstraints = atoi(pToken)) < 0) {    fclose(fInput);    printf("Error! number of constraints should be >= 0\n");    exit(1);  }  else if (globalSetup->noOfRawConstraints == 0) {    if ((strlen(pToken) != 1) || (*pToken != '0')) {      fclose(fInput);      printf("Error! number of constraints should be >= 0\n");      exit(1);    }  }  globalSetup->noOfLinearConstraintCombinations = 0;  globalSetup->finalNoOfConstraints = globalSetup->noOfRawConstraints;    // penalty weights  globalSetup->penaltyWeights = new double[globalSetup->finalNoOfConstraints];  for(ii = 0; ii < globalSetup->finalNoOfConstraints; ii++) {    // read a line    if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {      fclose(fInput);      printf("Error in the input file, please refer to the documentation\n");      exit(1);    }    globalSetup->penaltyWeights[ii] = atof(pToken);  }  // general parameters  // population size  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  if(strcmp("default", pToken) == 0) {    // Use a default value of 30*ell*log(ell);    printf("Using default population-sizing thumbrule: n = 30*ell*log(ell)\n");    // Take care of small problem sizes where log(ell) < 1    if(globalSetup->noOfDecisionVariables > 2)      globalSetup->populationSize = (int)(30*(globalSetup->noOfDecisionVariables)*log((double)(globalSetup->noOfDecisionVariables)));    else      globalSetup->populationSize = (int)(30*(globalSetup->noOfDecisionVariables));    //Round it to next nearest tenth number    if((globalSetup->populationSize)%10) globalSetup->populationSize += (globalSetup->populationSize)%10;    printf("The population size used is: %d\n", globalSetup->populationSize);  }  // the number can't be less than or equal to zero  else if ((globalSetup->populationSize = atoi(pToken)) <= 0) {    fclose(fInput);    printf("The population size must be > 0\n");    exit(1);  }  else if ((globalSetup->populationSize % 2) != 0) {    // the number can't be an odd number    fclose(fInput);    printf("Error! population size must be an even number\n");    exit(1);  }  // maximum generations  // the number can't be less than or equal to zero  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  if(strcmp("default", pToken) == 0) {    // Use a default value of 6*ell;    printf("Using default convergence-time thumbrule: tc = 6*ell\n");    globalSetup->maxGenerations = 6*(globalSetup->noOfDecisionVariables);    if((globalSetup->maxGenerations)%10) globalSetup->maxGenerations += 10-(globalSetup->maxGenerations)%10;    printf("The maximum number of generations set is: %d\n", globalSetup->maxGenerations);  }  else if ((globalSetup->maxGenerations = atoi(pToken)) <= 0) {    fclose(fInput);    printf("Error! maximum number of generations must be > 0\n");    exit(1);  }  // replace proportion  // the number should be in (0.0, 1.0]  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  if(strcmp("default", pToken) == 0) {    // Setting a default value of 0.9    printf("Using default replacement proportion of 0.9\n");    globalSetup->replaceProportion = 0.9;  }  else if (((globalSetup->replaceProportion = atof(pToken)) <= 0.0) || (globalSetup->replaceProportion > 1.0)) {    fclose(fInput);    printf("Error! proportion of parent population that should be replaced must be > 0 and <= 1\n");    exit(1);  }  // niching (multimodal handling)  if ((pToken = readOneLine(caBuf, ciBufSize, fInput)) == NULL) {    fclose(fInput);    printf("Error in the input file, please refer to the documentation\n");    exit(1);  }  if(strcmp("default", pToken) == 0) {    // Using NoNiching by default    printf("No niching method is used by default\n");    globalSetup->nichingType = NoNiching;  }  // niching type  else if (strcmp("NoNiching", pToken) == 0) {    globalSetup->nichingType = NoNiching;  globalSetup->nichingParameters = NULL;  }  else if (strcmp("Sharing", pToken) == 0) {    globalSetup->nichingType = Sharing;  }  else if (strcmp("RTS", pToken) == 0) {    globalSetup->nichingType = RTS;  }  else if (strcmp("DeterministicCrowding", pToken) == 0) {    globalSetup->nichingType = DeterministicCrowding;  }  else {    fclose(fInput);    printf("Error! valid niching types are: NoNiching, Sharing, RTS, and DeterministicCrowding\n");    exit(1);  }  // check niching type  if ((globalSetup->gaType == NSGA) && (globalSetup->nichingType != NoNiching)) {    fclose(fInput);    printf("Error! valid choice for niching types with NSGA is: NoNiching\n");    exit(1);  }  // read niching parameters  switch(globalSetup->nichingType) {  case NoNiching:  case DeterministicCrowding:    // no extra parameters    break;  case Sharing:    {      globalSetup->nichingParameters = new double[2];      if ((pToken = strtok(NULL, BLANK_STR)) == NULL) {	printf("Using default sharing radius of 4.24\n");	((double *)(globalSetup->nichingParameters))[0] = 4.24;      }      else 	((double *)globalSetup->nichingParameters)[0] = atof(pToken);      if (((double*)globalSetup->nichingParameters)[0] <= 0.0) {	fclose(fInput);	printf("Error! niching radius must be > 0\n");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区欧美一区| 欧美成人激情免费网| 欧美一区二区三区在线观看视频 | 日韩午夜激情电影| 中文字幕日韩一区| 国产在线观看免费一区| 欧美日韩在线播放三区四区| 国产精品麻豆网站| 国内精品免费**视频| 欧美日韩电影在线播放| 中文字幕日韩一区| 成人午夜短视频| 欧美电视剧在线观看完整版| 亚洲高清视频中文字幕| 91原创在线视频| 国产精品网曝门| 国产在线一区二区综合免费视频| 欧美蜜桃一区二区三区| 亚洲一区在线播放| 色综合天天狠狠| 国产精品国产馆在线真实露脸| 韩国三级中文字幕hd久久精品| 欧美日韩不卡一区二区| 亚洲综合久久久| 色丁香久综合在线久综合在线观看| 中文字幕不卡的av| 99热国产精品| 一区在线中文字幕| 91网站最新地址| 亚洲视频在线观看一区| av一二三不卡影片| 亚洲欧美日韩系列| 色婷婷综合中文久久一本| 亚洲色图欧洲色图婷婷| 91亚洲国产成人精品一区二区三| 国产精品日产欧美久久久久| 丁香六月久久综合狠狠色| 久久久久99精品一区| 国产成人av电影免费在线观看| 久久精品欧美一区二区三区不卡| 国产另类ts人妖一区二区| 国产午夜精品一区二区三区嫩草 | 欧洲精品中文字幕| 亚洲国产日韩av| 欧美一激情一区二区三区| 久久国产乱子精品免费女| 亚洲精品在线观看网站| 国产精品一区二区在线播放| 18欧美亚洲精品| 欧美无人高清视频在线观看| 日韩va亚洲va欧美va久久| 26uuu亚洲婷婷狠狠天堂| 国产精品18久久久久| 亚洲免费观看高清| 欧美精品一级二级| 激情国产一区二区| 综合婷婷亚洲小说| 欧美久久久久中文字幕| 国产乱子伦视频一区二区三区| 国产精品丝袜91| 欧美肥妇毛茸茸| 国产精品一线二线三线精华| 亚洲精品写真福利| 欧美一级免费观看| 丰满亚洲少妇av| 视频一区欧美日韩| 国产精品天干天干在线综合| 欧美日韩国产欧美日美国产精品| 国内外精品视频| 一区二区高清视频在线观看| 26uuu亚洲综合色| 在线观看国产一区二区| 国产馆精品极品| 亚洲成人av一区二区三区| 中文子幕无线码一区tr| 欧美久久久久久久久久| 成人综合在线观看| 奇米综合一区二区三区精品视频| 日本一区二区三区高清不卡| 欧美肥妇bbw| 色天天综合久久久久综合片| 国产在线精品一区二区三区不卡| 亚洲一区二区三区四区在线免费观看 | 国产成人亚洲综合a∨婷婷图片| 亚洲一区二区三区美女| 国产欧美日韩在线看| 67194成人在线观看| 91免费视频网| 国产91在线观看| 久久精品国产精品亚洲综合| 亚洲资源在线观看| 国产精品免费免费| 久久女同互慰一区二区三区| 欧美一区日韩一区| 欧美午夜电影网| 在线一区二区观看| 99这里只有久久精品视频| 国内欧美视频一区二区| 麻豆专区一区二区三区四区五区| 亚洲在线视频一区| 日韩伦理av电影| 国产精品久久久久久福利一牛影视| 欧美电视剧免费观看| 欧美性一级生活| 色系网站成人免费| 在线一区二区观看| 欧洲亚洲国产日韩| 欧美影院午夜播放| 欧美影视一区二区三区| 色婷婷av一区二区三区软件 | 99精品桃花视频在线观看| 国产福利一区二区| 国产精品99久久久久| 激情六月婷婷久久| 国产成人自拍网| 夫妻av一区二区| 99视频热这里只有精品免费| 成人app下载| 91黄色在线观看| 欧美日韩国产一区| 这里只有精品电影| 精品日韩欧美在线| 国产亚洲欧美日韩俺去了| 亚洲国产高清aⅴ视频| 亚洲欧美日韩精品久久久久| 一区二区三区91| 午夜精品一区二区三区电影天堂 | 亚洲一区在线免费观看| 亚洲国产一二三| 蜜桃视频第一区免费观看| 国产在线视频不卡二| 波多野结衣在线一区| 色香蕉久久蜜桃| 日韩一区二区三区观看| 久久久噜噜噜久久人人看| 国产精品久久久久久久裸模| 亚洲美女免费视频| 日韩高清在线观看| 国产成人午夜电影网| thepron国产精品| 欧美三级资源在线| xfplay精品久久| 亚洲另类色综合网站| 免费的国产精品| 不卡高清视频专区| 91精品国产乱| 国产精品理伦片| 日日夜夜一区二区| 丁香另类激情小说| 91麻豆精品国产| 中文字幕一区二区三区乱码在线| 亚洲午夜成aⅴ人片| 黄一区二区三区| 91久久精品日日躁夜夜躁欧美| 91精品久久久久久蜜臀| 综合久久久久久久| 韩国在线一区二区| 在线亚洲人成电影网站色www| 日韩精品最新网址| 亚洲另类春色校园小说| 国产福利电影一区二区三区| 欧美日韩电影在线| 亚洲欧美日韩久久| 国产成人精品免费看| 欧美二区乱c少妇| 亚洲久草在线视频| 国产成人免费网站| 日韩一区二区三区四区| 亚洲男人天堂一区| 丁香一区二区三区| 精品日韩在线观看| 日本视频中文字幕一区二区三区| 91亚洲午夜精品久久久久久| 久久综合网色—综合色88| 婷婷开心激情综合| 91精品福利在线| 亚洲日本va午夜在线影院| 国产麻豆欧美日韩一区| 欧美肥妇毛茸茸| 亚洲va欧美va人人爽| 欧美亚洲另类激情小说| 国产精品天天看| 成人理论电影网| 国产女人aaa级久久久级| 久久精品理论片| 欧美一三区三区四区免费在线看| 亚洲午夜影视影院在线观看| 色诱亚洲精品久久久久久| 亚洲国产精品激情在线观看| 东方欧美亚洲色图在线| 国产性天天综合网| 国产精品一区专区| 国产日韩欧美不卡| 国产成人精品1024| 日本一区免费视频| 国产91精品露脸国语对白| 日本一区二区免费在线观看视频| 黄色资源网久久资源365| 久久你懂得1024| 风流少妇一区二区|