亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
99久久99久久免费精品蜜臀| 日韩一级高清毛片| 欧美色图12p| 国产日产欧美一区二区视频| eeuss鲁片一区二区三区在线观看| 在线视频国内一区二区| 久久综合久久综合亚洲| 日精品一区二区| 在线看不卡av| 中文字幕一区二区三区av| 精品亚洲成a人| 欧美日韩黄色影视| 亚洲资源中文字幕| 91一区二区三区在线观看| 久久久久久久综合| 久久国产成人午夜av影院| 精品视频一区二区不卡| 亚洲色图另类专区| 99久久精品免费看国产| 国产亚洲精品免费| 国产精品综合一区二区三区| 日韩三级免费观看| 日韩国产一二三区| 制服丝袜av成人在线看| 性做久久久久久免费观看欧美| 91视频观看视频| 国产精品网站在线观看| 成人一区二区在线观看| 国产欧美一区视频| 不卡欧美aaaaa| 国产精品久久毛片a| 成人免费福利片| 欧美国产在线观看| 成人综合激情网| 国产精品嫩草久久久久| 成人综合在线观看| 国产精品毛片久久久久久久| 国产福利一区二区三区在线视频| 精品国产99国产精品| 国产一区二区三区在线观看免费视频| 婷婷中文字幕综合| 欧美日韩美少妇| 免费观看日韩电影| 久久女同互慰一区二区三区| 国产成人午夜精品5599| 综合在线观看色| 日本久久电影网| 日韩av一二三| 26uuu国产电影一区二区| 国产91在线观看丝袜| 亚洲欧美综合网| 欧美日韩亚州综合| 精品一区二区三区影院在线午夜| 久久久久久久网| 色婷婷激情久久| 免费精品视频在线| 国产精品日产欧美久久久久| 色丁香久综合在线久综合在线观看| 亚洲乱码一区二区三区在线观看| 欧美日韩免费电影| 国产麻豆精品在线观看| 中文字幕中文字幕在线一区 | 成人亚洲一区二区一| 亚洲素人一区二区| 欧美一级夜夜爽| 国产精品88888| 亚洲国产综合色| 久久久久久久久久电影| 亚洲视频小说图片| 6080yy午夜一二三区久久| 国产成人高清视频| 亚洲chinese男男1069| 欧美精品一区二区三区高清aⅴ| 91麻豆国产自产在线观看| 日本不卡不码高清免费观看| 中文字幕一区二区三区精华液| 91精品国产91久久久久久一区二区 | 色女孩综合影院| 卡一卡二国产精品| 亚洲蜜桃精久久久久久久| 欧美α欧美αv大片| 一本大道久久精品懂色aⅴ | 亚洲国产精品自拍| 国产精品色婷婷| 精品久久久久久久人人人人传媒| 成a人片亚洲日本久久| 免费成人结看片| 亚洲国产精品视频| 日韩久久一区二区| 国产偷国产偷精品高清尤物| 91精品国产品国语在线不卡| 91一区二区在线观看| 国产精品性做久久久久久| 亚洲www啪成人一区二区麻豆| 国产视频一区在线观看| 日韩欧美综合一区| 欧美日韩大陆在线| 色av成人天堂桃色av| 床上的激情91.| 国产乱一区二区| 精品一区二区三区香蕉蜜桃| 亚洲v中文字幕| 亚洲一区国产视频| 亚洲激情av在线| 一卡二卡欧美日韩| 亚洲免费看黄网站| 亚洲人成电影网站色mp4| 国产欧美一区视频| 中文一区二区在线观看| 久久精品欧美日韩| 久久精品免视看| 欧美激情综合五月色丁香| 欧美精品一区二区精品网| 欧美不卡一二三| 久久婷婷综合激情| 国产欧美日本一区二区三区| 久久久久久久综合日本| xnxx国产精品| 欧美国产精品一区| 亚洲欧美电影院| 亚洲电影中文字幕在线观看| 亚洲成人免费av| 日本一不卡视频| 久久激五月天综合精品| 久久99精品一区二区三区| 国内成人精品2018免费看| 国产精品亚洲成人| 99视频在线精品| 欧美午夜不卡在线观看免费| 欧美精品在线观看一区二区| 欧美一级艳片视频免费观看| 精品不卡在线视频| 中文字幕在线不卡一区二区三区 | 欧美精品一区视频| 欧美激情一区二区三区四区 | 亚洲成在线观看| 美腿丝袜亚洲色图| 懂色av一区二区夜夜嗨| 色综合天天综合在线视频| 欧美日韩精品三区| 欧美精品一区二区三区一线天视频 | 亚洲欧美另类小说| 偷拍自拍另类欧美| 国产经典欧美精品| 在线观看视频一区| 91精品国产综合久久久久久| 久久久久久99精品| 亚洲制服丝袜在线| 国产在线精品免费| 欧美色欧美亚洲另类二区| 精品免费日韩av| 亚洲男同性恋视频| 极品少妇xxxx精品少妇偷拍 | 国产精品视频免费| 午夜激情综合网| 国产精品香蕉一区二区三区| 欧美探花视频资源| 久久久精品免费观看| 亚洲一区影音先锋| 国产一区二区福利视频| 欧美亚洲一区三区| 国产免费成人在线视频| 石原莉奈在线亚洲三区| 国产白丝网站精品污在线入口| 在线亚洲高清视频| 国产欧美日韩三级| 另类综合日韩欧美亚洲| 色综合中文字幕| 久久免费午夜影院| 偷窥少妇高潮呻吟av久久免费| 成人精品高清在线| 日韩欧美一二区| 亚洲成人在线免费| 一本一道综合狠狠老| 国产日韩亚洲欧美综合| 免费看精品久久片| 欧美日韩一区精品| 亚洲免费大片在线观看| 成人一区二区三区视频在线观看 | 一本大道久久精品懂色aⅴ| 久久丝袜美腿综合| 久久精品国产99| 欧美精品日韩精品| 亚洲国产婷婷综合在线精品| 91蜜桃网址入口| 中文字幕亚洲不卡| av一区二区三区| 国产精品久久久久久久第一福利| 国产一区二区三区香蕉| 日韩一区二区三区视频在线 | 国产盗摄女厕一区二区三区| 欧美一区二区三区白人| 亚洲地区一二三色| 欧美日韩一区中文字幕| 亚洲一区二区五区| 欧美做爰猛烈大尺度电影无法无天| 国产精品久久久久久久第一福利| 国产河南妇女毛片精品久久久| 久久久久久电影| 国产成人a级片|