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

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

?? popula~1.c

?? 簡單遺傳算法經典例子!! SGPC: Simple Genetic Programming in C by Walter Alden Tackett and Aviram Carmi
?? C
字號:
/*
SGPC: Simple Genetic Programming in C
(c) 1993 by Walter Alden Tackett and Aviram Carmi
 
 This code and documentation is copyrighted and is not in the public domain.
 All rights reserved. 
 
 - This notice may not be removed or altered.
 
 - You may not try to make money by distributing the package or by using the
   process that the code creates.
 
 - You may not distribute modified versions without clearly documenting your
   changes and notifying the principal author.
 
 - The origin of this software must not be misrepresented, either by
   explicit claim or by omission.  Since few users ever read sources,
   credits must appear in the documentation.
 
 - Altered versions must be plainly marked as such, and must not be
   misrepresented as being the original software.  Since few users ever read
   sources, credits must appear in the documentation.
 
 - The authors are not responsible for the consequences of use of this 
   software, no matter how awful, even if they arise from flaws in it.
 
If you make changes to the code, or have suggestions for changes,
let us know!  (gpc@ipld01.hac.com)
*/

#ifndef lint
static char populations_c_rcsid[]="$Id: populations.c,v 2.8 1993/04/22 07:39:12 gpc-avc Exp gpc-avc $";
#endif

/*
 *
 * $Log: populations.c,v $
 * Revision 2.8  1993/04/22  07:39:12  gpc-avc
 * Removed old log messages
 *
 * Revision 2.7  1993/04/14  04:59:00  gpc-avc
 * Fixed bug of not initializing fraction inside the for loop
 *
 *
 */

#include <stdio.h>
#include <malloc.h>
#include <errno.h>
#include <values.h>
#include "gpc.h"



#ifdef ANSI_FUNC

VOID allocate_populations(
  int		numpops,
  pop_struct	*pop
  )
#else

VOID allocate_populations(numpops,pop)
  int 		numpops;
  pop_struct	*pop;
#endif
{
  int	p;

  for (p=0; p<numpops; p++) {
    pop[p].standardized_fitness =
      (float *) malloc(pop[p].population_size*sizeof(float));
    pop[p].adjusted_fitness = (float *) malloc(pop[p].population_size*sizeof(float));
    pop[p].normalized_fitness =
      (float *) malloc(pop[p].population_size*sizeof(float));
    pop[p].fitness_sort_index = (int *) malloc(pop[p].population_size*sizeof(int));
    pop[p].tournament_index = (int *) malloc(pop[p].tournament_K*sizeof(int));
    pop[p].population = (tree **) malloc(pop[p].population_size*sizeof(tree *));
    pop[p].new_population = (tree **) malloc(pop[p].population_size*sizeof(tree *));
    pop[p].best_of_generation = (tree *) NULL; 
    pop[p].best_of_run = (tree *) NULL;
    pop[p].best_of_gen_fitness = (MAXFLOAT);
    pop[p].best_of_run_fitness = (MAXFLOAT);
  }
}


#ifdef ANSI_FUNC

VOID setup_deme_grid(
  int 		numpops,
  int		demerows,
  int		demecols,	       
  pop_struct 	*pop,
  pop_struct    ***grid
  )
#else

VOID setup_deme_grid(numpops,demerows,demecols,pop,grid)
  int 		numpops;
  int		demerows;
  int		demecols;
  pop_struct 	*pop;
  pop_struct    ***grid;
#endif
{
  int	r, c;
  int	i, p, nperdeme;

  for (p=0;p<numpops;p++) {
    nperdeme = (pop[p].population_size/(demerows*demecols));
    for (r=0,i=0; r<demerows;r++) {
      for (c=0;c<demecols;c++,i+=nperdeme) {
	grid[r][c][p].my_row = r;
	grid[r][c][p].my_col = c;
	grid[r][c][p].population_size = nperdeme;
	grid[r][c][p].steady_state = pop[p].steady_state;
	grid[r][c][p].load_from_file = pop[p].load_from_file;
	grid[r][c][p].max_depth_for_new_trees =
	  pop[p].max_depth_for_new_trees;
	grid[r][c][p].max_depth_after_crossover =
	  pop[p].max_depth_after_crossover;
	grid[r][c][p].max_mutant_depth = pop[p].max_mutant_depth;
	grid[r][c][p].grow_method = pop[p].grow_method;
	grid[r][c][p].selection_method = pop[p].selection_method;
	grid[r][c][p].tournament_K = pop[p].tournament_K;
	grid[r][c][p].deme_search_radius_sigma =
	  pop[p].deme_search_radius_sigma;
	grid[r][c][p].tournament_index =
	  (int *) malloc(pop[p].tournament_K*sizeof(int));
	grid[r][c][p].crossover_func_pt_fraction =
	  pop[p].crossover_func_pt_fraction;
	grid[r][c][p].crossover_any_pt_fraction =
	  pop[p].crossover_any_pt_fraction;
	grid[r][c][p].fitness_prop_repro_fraction =
	  pop[p].fitness_prop_repro_fraction;
	grid[r][c][p].parsimony_factor = pop[p].parsimony_factor;
	grid[r][c][p].standardized_fitness =
	  &(pop[p].standardized_fitness[i]);
	grid[r][c][p].adjusted_fitness =
	  &(pop[p].adjusted_fitness[i]);
	grid[r][c][p].normalized_fitness =
	  &(pop[p].normalized_fitness[i]);
	grid[r][c][p].fitness_sort_index =
	  &(pop[p].fitness_sort_index[i]);
	grid[r][c][p].population = &(pop[p].population[i]);
	grid[r][c][p].new_population =
	  &(pop[p].new_population[i]);
	grid[r][c][p].best_of_generation = (tree *) NULL;
	grid[r][c][p].best_of_run = (tree *) NULL;
	grid[r][c][p].best_of_run_gen = -1;
	grid[r][c][p].best_of_gen_fitness = -1.0;
	grid[r][c][p].best_of_run_fitness = -1.0;
	grid[r][c][p].function_table = pop[p].function_table; 
	grid[r][c][p].terminal_table = pop[p].terminal_table;
	grid[r][c][p].function_table_size = pop[p].function_table_size;
	grid[r][c][p].terminal_table_size = pop[p].terminal_table_size;
      }
    }
  }
}

#ifdef ANSI_FUNC

VOID initialize_populations(
  int		numpops,
  pop_struct	*pop
  )
#else

VOID initialize_populations(numpops,pop)
  int		numpops;
  pop_struct	*pop;
#endif
{
  int	p;
  int	i;
  int	min_depth_for_new_trees = 1;
  int 	full_cycle;
  int 	grow;
  int	size;
  FILE	*f;
  tree	*temp;

  for (p=0; p<numpops; p++) {
    full_cycle = 0;
    for (i=0; i<pop[p].population_size; i++) {
      switch (pop[p].grow_method) {
      case FULL:
	size = pop[p].max_depth_for_new_trees;
	grow = 1;
	break;
      case GROW:
	size = pop[p].max_depth_for_new_trees;
	grow = 0;
	break;
      case RAMPED:
	size = (min_depth_for_new_trees +
		(i % (pop[p].max_depth_for_new_trees-min_depth_for_new_trees)));
	if (pop[p].max_depth_for_new_trees != min_depth_for_new_trees)
	  if (!(i % (pop[p].max_depth_for_new_trees-min_depth_for_new_trees)))
	    full_cycle = (!full_cycle);
	grow = (full_cycle);
	break;
      default:
	fprintf(stderr,"Error in initialize_populations(): Method %d must be %d %d or %d\n",
		pop[p].grow_method, FULL, GROW, RAMPED);
      }
      pop[p].population[i] = create_random_tree(pop, p, size, 1, grow);
    }
    /* replace the first members of population with those to be read
       from a file, if filename is not null */
    if (pop[p].load_from_file[0] != '\0') {
      f = fopen(pop[p].load_from_file,"r");
      for (i=0; (((int)(temp=read_tree(pop,p,f))) != EOF) &&
	   (i<pop[p].population_size); i++) {
	free_tree(pop[p].population[i]);
	pop[p].population[i] = temp;
      }
    }
  }
}

#ifdef ANSI_FUNC

VOID breed_new_population(
  pop_struct	*pop,
  int 		p,
  int 		demes,
  int 		nrows,
  int 		ncols,
  int		steady_state			  
  )
#else

VOID breed_new_population(pop,p,demes,nrows,ncols,steady_state)
  pop_struct *pop;
  int		p;
  int 		demes;
  int 		nrows;
  int 		ncols;
  int		steady_state;
#endif
{
  int	i, j, incr;
  float fraction = 0.0;
  tree	*parent1, *parent2, *offspring1, *offspring2, *pptr;
  int	worst_index1, worst_index2, best_index1, best_index2;

#if DBSS == 1
    if (demes) {
      printf(" Steady state breeding in deme (%d,%d) \n",
	     pop[p].my_row, pop[p].my_col);
    }
#endif
  if (steady_state && ((pop[p].selection_method == OVERSELECT) ||
		      (pop[p].selection_method == FITNESSPROP))) {
    printf("SORRY: steady_state population requires either DEMES or \n \
            selection_method = TOURNAMENT");
    exit (1);
  }
  for (i = 0, fraction = random_float(1.0); 
       i < pop[p].population_size;
       i += incr, fraction = random_float(1.0)) {

    parent1 = find_tree(pop,p,demes,nrows,ncols,&worst_index1,&best_index1);
    while (steady_state && (POP[p].population[worst_index1] == parent1))
      parent1 = find_tree(pop,p,demes,nrows,ncols,&worst_index1,&best_index1);
#if DBSS == 1
    printf("Parent 1: selected POP[%d] to breed. Fitness = %f\n \
            \tselected POP[%d] to replace. Fitness = %f\n",
	   best_index1, POP[p].standardized_fitness[best_index1],
	   worst_index1, POP[p].standardized_fitness[worst_index1]);
#endif
    if ((i < (pop[p].population_size-1)) &&
	(fraction <
	 (pop[p].crossover_func_pt_fraction+pop[p].crossover_any_pt_fraction))) {
      parent2 = find_tree(pop,p,demes,nrows,ncols,&worst_index2,&best_index2);
      while (steady_state && ((worst_index1 == worst_index2) ||
			      (POP[p].population[worst_index2] == parent2) ||
			      (POP[p].population[worst_index2] == parent1) ||
			      (POP[p].population[worst_index1] == parent2)))
	parent2 = find_tree(pop,p,demes,nrows,ncols,&worst_index2,&best_index2);
#if DBSS == 1
      printf("Parent 2: selected POP[%d] to breed. Fitness = %f\n \
            \tselected POP[%d] to replace. Fitness = %f\n",
	     best_index2, POP[p].standardized_fitness[best_index2],
	     worst_index2, POP[p].standardized_fitness[worst_index2]);
#endif

      if (fraction < pop[p].crossover_func_pt_fraction) {
	crossover_at_func_pt(pop, parent1, parent2, &offspring1, &offspring2);
      } else {
	crossover_at_any_pt(pop, parent1, parent2, &offspring1, &offspring2);
      }
      if (steady_state) {
	free_tree(POP[p].population[worst_index1]);
	free_tree(POP[p].population[worst_index2]);
	POP[p].population[worst_index1] = offspring1;
	POP[p].population[worst_index2] = offspring2;
	POP[p].standardized_fitness[worst_index1] =
	  evaluate_fitness_of_individual(POP,p,
					 POP[p].population[worst_index1],
					 worst_index1) +
          ((float) count_crossover_pts(POP[p].population[worst_index1]))*
	    pop[p].parsimony_factor;

	POP[p].standardized_fitness[worst_index2] =
	  evaluate_fitness_of_individual(POP,p,
					 POP[p].population[worst_index2],
					 worst_index2) +
          ((float) count_crossover_pts(POP[p].population[worst_index2]))*
	    pop[p].parsimony_factor;
      } else {
	pop[p].new_population[i] = offspring1;
	pop[p].new_population[i+1] = offspring2;
      }
      incr = 2;
    } else if (fraction <
	 (pop[p].crossover_func_pt_fraction
	  + pop[p].crossover_any_pt_fraction
	  + pop[p].fitness_prop_repro_fraction)) {
      if (steady_state) {
#if DBSS == 1
	printf("performing straight copy of parent 1\n");
#endif
	free_tree(POP[p].population[worst_index1]);
	POP[p].population[worst_index1] = copy_tree(parent1);
	/* kind of a waste - you should really set fitess-prop-repro-frac
	   to zero for the steady-state elitist model... */
	POP[p].standardized_fitness[worst_index1] =
	  evaluate_fitness_of_individual(POP,p,
					 POP[p].population[worst_index1],
					 worst_index1) +
            ((float) count_crossover_pts(POP[p].population[worst_index1]))*
	      pop[p].parsimony_factor;
      } else {
	pop[p].new_population[i] = copy_tree(parent1);
      }
      incr = 1;
    } else {
      if (steady_state) {
#if DBSS == 1
	printf("performing mutation of parent 1\n");
#endif
	free_tree(POP[p].population[worst_index1]);
	POP[p].population[worst_index1] = mutate(pop,copy_tree(parent1));
	POP[p].standardized_fitness[worst_index1] =
	  evaluate_fitness_of_individual(POP,p,
					 POP[p].population[worst_index1],
					 worst_index1) +
            ((float) count_crossover_pts(POP[p].population[worst_index1]))*
	      pop[p].parsimony_factor;
      } else {
	pop[p].new_population[i] = mutate(pop,copy_tree(parent1));
      }
      incr = 1;
    }
  }
}
     
#ifdef ANSI_FUNC

VOID free_population(
  pop_struct	*pop,
  int 	p
  )
#else

VOID free_population(pop,p)
  pop_struct	*pop;
  int		p;
#endif
{
  int	i;

  for (i=0; i<pop[p].population_size; i++) {
    free_tree(pop[p].population[i]);
  }
}

#ifdef ANSI_FUNC

VOID load_new_population(
  pop_struct	*pop,
  int p
  )
#else

VOID load_new_population(pop,p)
  pop_struct	*pop;
  int		p;
#endif
{
  int	i;

  for (i=0; i<pop[p].population_size; i++) {
    pop[p].population[i] = pop[p].new_population[i];
  }
}


  
       
      

  for (i=0; i<pop[p].population_size; i++) {
    free_tree(pop[p].population[i]);
  }
}

#ifdef ANSI_FUNC

VOID load_new_population(
  pop_struct	*pop,
  int p
  )
#else

VOID load_new_population(pop,p)
  pop_struct	*pop;
  int		p;
#endif
{
  int	i;

  for (i=0; i<pop[p].population_size; i++) {
    pop[p].population[i] = pop[p].new_population[i];
  }
}


  
       
      

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产日产欧美精品一区二区三区| 亚洲高清免费在线| 亚洲精品免费在线观看| 日本视频免费一区| 色综合久久中文字幕综合网| 日韩久久久久久| 亚洲超碰97人人做人人爱| 国产一区二区看久久| 欧美久久久影院| 亚洲综合色噜噜狠狠| av一二三不卡影片| 久久久亚洲精品一区二区三区| 亚洲成人在线观看视频| 97精品国产97久久久久久久久久久久| 日韩欧美国产午夜精品| 亚洲国产毛片aaaaa无费看| 成人国产精品免费观看| 久久五月婷婷丁香社区| 日韩精品五月天| 欧美色图免费看| 亚洲伦理在线精品| 99久久综合狠狠综合久久| 亚洲精品一区二区三区香蕉| 天天av天天翘天天综合网色鬼国产| 北岛玲一区二区三区四区| 久久日一线二线三线suv| 日韩高清电影一区| 4438x亚洲最大成人网| 婷婷一区二区三区| 91精品欧美福利在线观看| 天堂午夜影视日韩欧美一区二区| 在线亚洲+欧美+日本专区| 亚洲区小说区图片区qvod| 91小宝寻花一区二区三区| 国产精品盗摄一区二区三区| 成人激情小说乱人伦| 国产精品三级久久久久三级| 成人一区二区三区视频在线观看| 久久久不卡影院| 成人免费视频一区二区| 中文字幕不卡的av| 91在线视频免费91| 一区二区三区四区视频精品免费| 在线看一区二区| 午夜精品爽啪视频| 日韩欧美国产一区在线观看| 国产一区二区调教| 中文字幕免费不卡在线| 色综合天天综合给合国产| 亚洲国产日韩一级| 日韩视频123| 国产99久久久久| 亚洲欧美欧美一区二区三区| 欧美性感一区二区三区| 免费成人av在线| 中文字幕 久热精品 视频在线| 99久久婷婷国产综合精品| 一级日本不卡的影视| 欧美一区二区三区人| 国产麻豆午夜三级精品| 亚洲欧洲日韩在线| 欧美伦理影视网| 国产精品综合二区| 亚洲自拍偷拍欧美| 日韩欧美国产午夜精品| 波多野洁衣一区| 免费高清在线一区| 最新欧美精品一区二区三区| 欧美高清你懂得| 成人免费高清在线观看| 夜色激情一区二区| 久久精品亚洲一区二区三区浴池| 色婷婷综合久久| 国产自产2019最新不卡| 亚洲最色的网站| 久久综合九色综合97婷婷女人| 97精品久久久久中文字幕| 久久er99精品| 亚洲一区在线视频| 欧美经典一区二区| 欧美一区中文字幕| 色视频欧美一区二区三区| 极品少妇xxxx精品少妇偷拍| 亚洲欧美日韩人成在线播放| 精品国产一区二区三区久久影院| 色综合天天在线| 国产成人在线视频免费播放| 三级一区在线视频先锋| 国产精品伦理一区二区| 精品伦理精品一区| 欧美久久久久免费| 色综合欧美在线| 丰满少妇久久久久久久| 日本午夜精品视频在线观看| 伊人一区二区三区| 国产精品久99| 国产欧美日本一区二区三区| 91精品国产品国语在线不卡| 91福利社在线观看| av在线不卡电影| 国产成人av电影在线观看| 日韩有码一区二区三区| 夜夜爽夜夜爽精品视频| 中文字幕一区二区三区四区| 国产欧美日韩精品a在线观看| 日韩视频免费直播| 日韩亚洲欧美中文三级| 9191久久久久久久久久久| 欧美日韩中文字幕一区| 色诱亚洲精品久久久久久| voyeur盗摄精品| 成人国产精品免费观看动漫 | 美女视频黄久久| 亚洲va欧美va人人爽| 亚洲国产婷婷综合在线精品| 亚洲一区二区三区免费视频| 亚洲一区二区三区四区五区中文| 亚洲视频一区二区在线观看| 亚洲欧美中日韩| 亚洲另类在线一区| 亚洲一卡二卡三卡四卡 | 色94色欧美sute亚洲线路一ni| jiyouzz国产精品久久| 99精品偷自拍| 欧美亚洲图片小说| 5566中文字幕一区二区电影| 日韩三级av在线播放| 欧美tickle裸体挠脚心vk| 久久久亚洲高清| 中文字幕第一区二区| 亚洲乱码国产乱码精品精可以看| 亚洲综合色区另类av| 日本欧美一区二区| 国产一区二区导航在线播放| 国产不卡一区视频| 91麻豆精东视频| 91精品国产综合久久精品性色| 日韩美女一区二区三区四区| 国产无人区一区二区三区| 国产精品久久久久影院老司 | 日韩精品视频网| 国产一区二区三区最好精华液| 成人晚上爱看视频| 欧美色大人视频| 26uuu国产一区二区三区| 国产欧美日韩久久| 亚洲一区二区三区免费视频| 六月丁香婷婷久久| 成人app网站| 欧美一区二区三区男人的天堂| 久久久久99精品国产片| 亚洲精品国产视频| 全部av―极品视觉盛宴亚洲| 国产不卡视频在线播放| 欧美日韩国产美| 久久久久久久综合色一本| 亚洲天堂福利av| 久久精品国产99国产精品| 91浏览器在线视频| 亚洲精品在线免费播放| 一区二区三区在线不卡| 韩国三级中文字幕hd久久精品| 91精品国产综合久久福利软件| 国产精品天美传媒| 日韩**一区毛片| 色综合天天综合网天天狠天天 | 天堂久久一区二区三区| 国产白丝精品91爽爽久久| 欧美精品第1页| 最新国产の精品合集bt伙计| 久久99这里只有精品| 色天天综合色天天久久| 欧美极品另类videosde| 日韩国产在线一| 在线精品视频一区二区| 国产精品你懂的| 国产美女av一区二区三区| 欧美精品久久天天躁| 一区二区三区丝袜| 成人免费视频视频在线观看免费| 精品对白一区国产伦| 亚洲成人av一区| 91福利在线看| 亚洲天堂久久久久久久| 成人福利视频网站| 久久久不卡网国产精品一区| 久久精品国产亚洲高清剧情介绍 | 欧美美女激情18p| 亚洲美女一区二区三区| 成人高清免费在线播放| 国产丝袜美腿一区二区三区| 狠狠色丁香婷综合久久| 日韩欧美www| 久久99精品久久久久婷婷| 欧美一区二区三区啪啪| 全部av―极品视觉盛宴亚洲| 91精品婷婷国产综合久久性色| 亚洲aaa精品| 欧美一区二区三区性视频| 日本网站在线观看一区二区三区 |