亚洲欧美第一页_禁久久精品乱码_粉嫩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福利小视频| av不卡免费在线观看| 精油按摩中文字幕久久| 丝袜亚洲另类欧美| 有码一区二区三区| 中文字幕成人网| 精品福利av导航| 欧美一三区三区四区免费在线看 | 亚洲欧美综合色| 国产精品盗摄一区二区三区| 欧美精选在线播放| 在线观看亚洲专区| 99re这里都是精品| 国产成人av一区二区三区在线 | 麻豆精品久久精品色综合| 亚洲在线中文字幕| 亚洲青青青在线视频| 国产亲近乱来精品视频| 精品精品国产高清a毛片牛牛| 欧美精品在线观看一区二区| 色婷婷av一区二区三区软件| 成人app在线| 高清av一区二区| 国产91丝袜在线播放九色| 精品一区二区在线观看| 久草热8精品视频在线观看| 日韩av网站免费在线| 天堂久久久久va久久久久| 亚洲成人精品影院| 亚洲成人在线网站| 亚洲午夜精品一区二区三区他趣| 一区二区三区四区国产精品| 亚洲精品成a人| 亚洲精品日韩一| 亚洲午夜久久久| 午夜视黄欧洲亚洲| 午夜精品久久久久久| 三级影片在线观看欧美日韩一区二区| 亚洲一区二区在线免费看| 亚洲国产日韩a在线播放性色| 亚洲一区二区综合| 日韩主播视频在线| 久久国产精品区| 国产精品一区免费在线观看| 国产成人h网站| 99久久久国产精品| 欧美中文字幕一区| 欧美精品色综合| 精品毛片乱码1区2区3区| 国产色婷婷亚洲99精品小说| 日本一区二区三区久久久久久久久不 | 不卡的电视剧免费网站有什么| 国产成a人亚洲精| 91丨porny丨在线| 欧美日韩一级黄| 精品久久久久久久一区二区蜜臀| 久久精品欧美一区二区三区不卡| 欧美激情一区二区三区不卡 | 国产精品一区二区无线| 粉嫩av一区二区三区| 一本久久a久久精品亚洲| 欧美日韩另类国产亚洲欧美一级| 欧美一区二区不卡视频| 久久久国产精品午夜一区ai换脸| 中文字幕亚洲综合久久菠萝蜜| 亚洲综合一区在线| 日本成人中文字幕| 国产成a人亚洲精| 欧美性受xxxx黑人xyx| 精品精品国产高清a毛片牛牛 | 一区二区三区91| 美洲天堂一区二卡三卡四卡视频| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲一区二区3| 激情久久久久久久久久久久久久久久| 国产成人啪免费观看软件| 一本色道亚洲精品aⅴ| 日韩欧美一区二区三区在线| 国产精品久久国产精麻豆99网站| 午夜成人免费视频| 高清在线成人网| 69久久99精品久久久久婷婷| 日本一区二区三区四区| 日韩1区2区日韩1区2区| 99视频精品在线| 欧美白人最猛性xxxxx69交| 亚洲欧洲在线观看av| 免费在线一区观看| 色综合久久久久综合体桃花网| 日韩免费观看高清完整版在线观看| 一区在线播放视频| 加勒比av一区二区| 欧美性高清videossexo| 国产欧美1区2区3区| 免费在线看一区| 欧美在线看片a免费观看| 欧美激情在线一区二区三区| 日本午夜精品视频在线观看 | 一级特黄大欧美久久久| 国产成人在线色| 欧美变态口味重另类| 天堂va蜜桃一区二区三区漫画版| 丁香婷婷综合色啪| 精品国产乱码久久久久久免费| 亚洲卡通动漫在线| 成人一级片在线观看| 亚洲一区在线观看网站| 懂色av一区二区三区蜜臀| 欧美xxxx老人做受| 日韩福利视频导航| 欧美四级电影网| 亚洲欧洲国产日韩| 成人精品视频一区二区三区尤物| 欧美v日韩v国产v| 日本va欧美va精品| 欧美精品在线观看一区二区| 亚洲一区在线观看免费 | 免费久久精品视频| 欧美日韩高清一区二区三区| 亚洲综合一区二区三区| 色香蕉成人二区免费| 国产精品第13页| www.色精品| 国产精品网曝门| 成人一级片在线观看| 中文av一区二区| 成人av电影免费观看| 欧美韩日一区二区三区四区| 国产91在线观看丝袜| 国产精品色呦呦| 成人午夜伦理影院| 国产精品久99| 99精品视频在线播放观看| 最新国产成人在线观看| av电影一区二区| 亚洲一区二区在线观看视频| 91久久精品一区二区| 一区二区三区精品久久久| 欧洲av在线精品| 亚洲成人一区二区在线观看| 欧美精品第一页| 裸体健美xxxx欧美裸体表演| 欧美成人乱码一区二区三区| 国产精品亚洲午夜一区二区三区 | 这里只有精品免费| 理论片日本一区| 久久久天堂av| jiyouzz国产精品久久| 日韩理论片网站| 欧美三级在线播放| 老司机午夜精品99久久| 久久久久久久久免费| 成人白浆超碰人人人人| 亚洲精品日韩专区silk| 欧美一区二区三区男人的天堂| 韩国v欧美v亚洲v日本v| 国产精品卡一卡二| 欧美性色aⅴ视频一区日韩精品| 日本美女一区二区三区| 国产亚洲欧美日韩日本| 99久久伊人网影院| 五月天久久比比资源色| 精品国精品自拍自在线| 成a人片国产精品| 樱花草国产18久久久久| 日韩视频免费观看高清完整版 | 国产精品日韩成人| 欧美日韩在线电影| 国产高清视频一区| 夜夜爽夜夜爽精品视频| 精品国产自在久精品国产| 色综合色综合色综合 | 日韩精品一级中文字幕精品视频免费观看 | 国产在线一区观看| 又紧又大又爽精品一区二区| 精品欧美一区二区久久| 色婷婷av一区二区三区软件 | 亚洲免费三区一区二区| 91麻豆精品91久久久久久清纯 | 亚洲狼人国产精品| 精品处破学生在线二十三| 色天使久久综合网天天| 国产一区二区视频在线| 夜夜亚洲天天久久| 国产色综合久久| 欧美老年两性高潮| 成人免费毛片aaaaa**| 日韩av一区二| 亚洲最新在线观看| 中文字幕第一区综合| 欧美一区二区视频在线观看2022 | 精品国产亚洲一区二区三区在线观看| www.色综合.com|