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

📄 initiali.c

📁 GA遗传算法的C语言版改进实现
💻 C
字号:
/* file: initiali.c
 *
 * purpose: create an initial population of structures,
 * and initalize some performance variables.
 * This is called at the start of each experiment.
 */

#include <stdlib.h>
#include <time.h>


void
initiali(int **Popu,int p_size,int len)
{
	int 	i;
	int	j;
	double 	prob;
	time_t  t;

	/* generate the initialzied population */
	srand((unsigned) time(&t));

	for (i=0;i<p_size;i++)
	{
		for (j=0;j<len;j++)
		{
			prob=(1.0*random(1000))/1000;
			if (prob>0.5)
				Popu[i][j]=1;
			else
				Popu[i][j]=0;
		}
	}
}


⌨️ 快捷键说明

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