⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ga_intrinsics.c

📁 http://gaul.sourceforge.net/ 这里大部分人讨论的是在Matlab里实现GA的toolbox.以上为一个GA的C语言的软件包.如果你想利用GA做优化算法,非常有用.而且有
💻 C
📖 第 1 页 / 共 4 页
字号:
  {  return ((population*) ga_get_population_from_id(*pop))->len_chromosomes;  }/**********************************************************************  ga_population_get_generation_slang()  synopsis:	Access population's generation field.  parameters:  return:  last updated:	20 Mar 2003 **********************************************************************/static int ga_population_get_generation_slang(int *pop)  {  return ((population*) ga_get_population_from_id(*pop))->generation;  }/**********************************************************************  ga_entity_get_fitness_slang()  synopsis:	Access entity's fitness field.  parameters:  return:  last updated:	22/01/01 **********************************************************************/static double ga_entity_get_fitness_slang(int *pop, int *id)  {  return ga_get_entity_from_id(ga_get_population_from_id(*pop), *id)->fitness;  }/**********************************************************************  ga_entity_isallocated_slang()  synopsis:	Determine whether the given entity id is used.  parameters:  return:  last updated:	18 Mar 2002 **********************************************************************/static int ga_entity_isallocated_slang(int *pop, int *id)  {  return ga_get_entity_from_id(ga_get_population_from_id(*pop), *id) != NULL;  }/**********************************************************************  ga_extinction_slang()  synopsis:	Purge all memory used by a population.  parameters:  return:  last updated:	22/01/01 **********************************************************************/static int ga_extinction_slang(int *pop)  {  return ga_extinction( ga_get_population_from_id(*pop) );  }/**********************************************************************  ga_genocide_slang()  synopsis:	Kill population members.  parameters:  return:  last updated:	11/01/01 **********************************************************************/static int ga_genocide_slang(int *pop, int *target_size)  {  return ga_genocide( ga_get_population_from_id(*pop), *target_size );  }/**********************************************************************  ga_genocide_by_fitness_slang()  synopsis:	Kill population members.  parameters:  return:  last updated:	01 Jul 2004 **********************************************************************/static int ga_genocide_by_fitness_slang(int *pop, double *target_fitness)  {  return ga_genocide( ga_get_population_from_id(*pop), *target_fitness );  }/**********************************************************************  ga_allele_search_slang()  synopsis:	Wrapper around ga_allele_search() for the scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	18 Mar 2002 **********************************************************************/static int ga_allele_search_slang(	int	*pop_id,				int	*chromosomeid,				int 	*point,				int	*min_val,				int	*max_val,				int	*entity_id )  {  entity	*initial, *final;	/* Initial and final solutions. */  population	*pop;			/* Active population structure. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  final = ga_allele_search( pop,                            *chromosomeid, *point, *min_val, *max_val,                            initial );  return ga_get_entity_id(pop, final);  }#if 0/**********************************************************************  ga_metropolis_slang()  synopsis:	Wrapper around ga_metropolis_mutation() for the		scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	18 Mar 2002 **********************************************************************/int ga_metropolis_slang(	int	*pop_id,				int	*entity_id,				int	*num_iterations,				int 	*temperature)  {  entity	*initial, *final;	/* Initial and final solutions. */  population	*pop;			/* Active population structure. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  final = ga_metropolis_mutation( pop, initial,                         *num_iterations, *temperature );  return ga_get_entity_id(pop, final);  }#endif/**********************************************************************  ga_sa_slang()  synopsis:	Wrapper around ga_sa()		for the scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	06 Nov 2002 **********************************************************************/static int ga_sa_slang(	int	*pop_id,			int	*entity_id,			int	*max_iterations )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_sa( pop, initial, *max_iterations );  return num_iter;  }/**********************************************************************  ga_simpex_slang()  synopsis:	Wrapper around ga_simplex()		for the scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	06 Nov 2002 **********************************************************************/static int ga_simplex_slang(	int	*pop_id,			int	*entity_id,			int	*max_iterations )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_simplex( pop, initial, *max_iterations );  return num_iter;  }/**********************************************************************  ga_tabu_slang()  synopsis:	Wrapper around ga_tabu()		for the scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	06 Nov 2002 **********************************************************************/static int ga_tabu_slang(	int	*pop_id,			int	*entity_id,			int	*max_iterations )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_tabu( pop, initial, *max_iterations );  return num_iter;  }/**********************************************************************  ga_randomsearch_slang()  synopsis:	Wrapper around ga_randomsearch()		for the scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	06 Nov 2002 **********************************************************************/static int ga_random_search_slang(	int	*pop_id,			int	*entity_id,			int	*max_iterations )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_random_search( pop, initial, *max_iterations );  return num_iter;  }/**********************************************************************  ga_search_slang()  synopsis:	Wrapper around ga_search()		for the scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	08 Nov 2002 **********************************************************************/static int ga_search_slang(	int	*pop_id,			int	*entity_id )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_search( pop, initial );  return num_iter;  }/**********************************************************************  ga_nahc_slang()  synopsis:	Wrapper around ga_next_ascent_hillclimbing() for		scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	06 Nov 2002 **********************************************************************/static int ga_nahc_slang(	int	*pop_id,			int	*entity_id,			int	*num_iterations )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_next_ascent_hillclimbing( pop, initial, *num_iterations);  return num_iter;  }/**********************************************************************  ga_rahc_slang()  synopsis:	Wrapper around ga_random_ascent_hillclimbing() for		scripted API.  parameters:  return:	Index of best solution found (A new entity).  last updated:	06 Nov 2002 **********************************************************************/static int ga_rahc_slang(	int	*pop_id,			int	*entity_id,			int	*num_iterations )  {  entity	*initial;	/* Solution to optimise. */  population	*pop;		/* Active population structure. */  int		num_iter;	/* Number of iterations performed. */  pop = ga_get_population_from_id(*pop_id);  initial = ga_get_entity_from_id(pop, *entity_id);  num_iter = ga_random_ascent_hillclimbing( pop, initial, *num_iterations );  return num_iter;  }/**********************************************************************  ga_population_score_and_sort_slang()  synopsis:	Wrapper around ga_population_score_and_sort() for		scripted API.  Recommended for use after reading		the population from disk.  parameters:	Population handle.  return:	Success.  last updated:	28/02/01 **********************************************************************/static int ga_population_score_and_sort_slang(int *pop_id)  {  return ga_population_score_and_sort(ga_get_population_from_id(*pop_id));  }/**********************************************************************  ga_population_sort_slang()  synopsis:	Wrapper around ga_population_sort() for		scripted API.  parameters:	Population handle.  return:	Success.  last updated:	20 May 2002 **********************************************************************/static int ga_population_sort_slang(int *pop_id)  {  sort_population(ga_get_population_from_id(*pop_id));  return TRUE;  }#if 0/**********************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -