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

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

?? 新建 文本文檔.txt

?? 采用FORTRAN編制的小生境遺傳算法反演程序
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
/***************************************************************/
/*  程序功能: 實現小生境遺傳算法                              */
/*  參考文獻: 《遺傳算法原理及應用》                          */
/*  作者    : 周明 孫樹棟                                     */
/*  出版社  : 國防工業出版社(2001年第二版)                    */
/*  程序實現: 蔣龍聰                                          */
/*  單位    : 中國地質大學(武漢)地球物理與空間信息學院        */
/*  專業    : 地球探測與信息技術                              */
/*  研究方向: 地球物理數據處理及其地震層析成像                */
/*  説明    : 採用了Denis Cormier和Sita S.Raghavan的程序框架圖*/
/***************************************************************/

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

/* 初始化遺傳算法參數,讀者可以根據實際問題修改設置參數值的大小*/

#define POPSIZE 100          /* 種群大小 */
#define N 30                 /* 小生境保留值 */  
#define MAXGENS 200          /* 最大進化代數 */
#define NVARS 4             /* 反演參數的個數 */
#define PXOVER 0.8          /* 交叉概率 */
#define PMUTATION 0.2       /* 變異概率 采用實數編碼 變異率可以放大些 配合非均勻變異 */
#define TRUE 1
#define FALSE 0
#define Lenth 120            /* 產生Gauss正態分佈而用的均勻分佈的長度 */
#define PI 3.1415926     /* 圓周率 */
#define RECEIVES 1001      /* 地震波形記錄點數 */
#define shapeFactor 6        //非均勻變異中的形狀因子   //越大收斂早!~
#define HD  0.1              /*海明距離*/

int generation;              /* 當前代數值 */
int cur_best;                /* 最佳個體 */
double Penalty;
double Gfactor; 
double OBS[RECEIVES];
double h[3]={50,20,50};   
FILE *galog;                 /* 輸出文件 */


struct genotype              /* genotype (GT), a member of the population */
{
  double gene[NVARS];        /* a string of variables */
  double fitness;            /* GT's fitness */
  double upper[NVARS];       /* GT's variables upper bound */
  double lower[NVARS];       /* GT's variables lower bound */
  double cfitness;           /* cumulative fitness */
};

struct genotype population[POPSIZE+1];    /* population */
struct genotype newpopulation[POPSIZE+1]; /* new population; */
struct genotype nicheP[POPSIZE+N];        /* replaces the */
                                          /* old generation */
struct genotype popMemory[N];

/* Declaration of procedures used by this genetic algorithm */
void   initialize(void);
void   evaluate(void);
void   searchBest(void);
void   elitist(void);
void   select(void);
void   crossover(void);
void   Xover(int,int);
void   swap(double*,double*);
void   mutate(void);
void   nicheGA(void);
void   simulate(void);
double randval(double, double);
double randvalG(double,double);
double randvalNu(int,int,double,double);
double obFun(double x[]);
double hamming(int,int);
double hamming1(int,int);

/***************************************************************/
/* Initialization function: Initializes the values of genes    */
/* within the variables bounds. It also initializes (to zero)  */
/* all fitness values for each member of the population. It    */
/* reads upper and lower bounds of each variable from the      */
/* input file `gadata.txt'. It randomly generates values       */
/* between these bounds for each gene of each genotype in the  */
/* population. The format of the input file `gadata.txt' is    */
/* var1_lower_bound var1_upper bound                           */
/* var2_lower_bound var2_upper bound ...                       */
/***************************************************************/

void initialize(void)
{
	FILE *infile;
    int i, j;
    double lbound, ubound;
	double sum=0.0;
	if ((infile = fopen("gadata.txt","r"))==NULL)
	{
		fprintf(galog,"\nCannot open input file!\n");
        exit(1);
    }

/* initialize variables within the bounds */
	for(i=0; i<NVARS; i++)
	{
		fscanf(infile, "%lf",&lbound);
        fscanf(infile, "%lf",&ubound);
		for (j=0; j<POPSIZE; j++)
		{
			population[j].fitness = 0;
            population[j].cfitness= 0;
            population[j].lower[i]= lbound;
            population[j].upper[i]= ubound;
            population[j].gene[i] = randval(population[j].lower[i],population[j].upper[i]);
        }
	}
	fclose(infile);
	//產生第一個初始群體,爲了保持群體的差異性,引入Hamming距離加以控制和約束
/*
	j=0;
	for(i=0;i<NVARS; i++)
		population[j].gene[i]=randval(population[j].lower[i],population[j].upper[i]);
	while(j<POPSIZE)
	{
		j++;
		for(i=0; i<NVARS; i++)
		{
			population[j].gene[i]=randval(population[j].lower[i],population[j].upper[i]);
		}
		if(hamming(j,j-1)<HD)
			j--;
	}
*/
}

/***********************************************************/
/* Calculate the Hamming distance of two dataset           */
/***********************************************************/

double hamming(int i,int j)
{
	int k=0;
	double sum=0;
    for(k=0;k<NVARS;k++)
		sum=sum+(population[i].gene[k]-population[j].gene[k])*(population[i].gene[k]-population[j].gene[k]);
	return(sqrt(sum));
}

double hamming1(int i,int j)
{
	int k=0;
	double sum=0;
    for(k=0;k<NVARS;k++)
		sum=sum+(nicheP[i].gene[k]-nicheP[j].gene[k])*(nicheP[i].gene[k]-nicheP[j].gene[k]);
	return(sqrt(sum));
}

/***********************************************************/
/* Random value generator: Generates a value within bounds */
/* Generate uniform random numbers,the mutation is uniform */
/***********************************************************/

double randval(double low, double high)
{
	double val;
	val = low+((double)(rand()%1000)/1000.0)*(high-low);
	return(val);
}

/***********************************************************/
/* Random value generator: Generates a value within bounds */
/* Generate Gauss distribution random numbers,mutation also*/
/*****???????????????????????????????????????????????*******/
double randvalG(double low,double high)
{
	int i=0;
	double val,sum=0.0;
	for(i=0;i<Lenth;i++)
	{
		sum+=(double)(rand()%500)/500.0;
	}
	return (val=(low+high)/2+(high-low)*(sum-Lenth/2)/(Lenth/2));
}
/***********************************************************/
/* Random value generator: Generates a value within bounds */
/* Generate Non-unform random numbers,also the mutation    */
/*****???????????????????????????????????????????***********/

double randvalNu(int i,int j,double low,double high)
{
	double val;
	double r=generation/MAXGENS;
	double randN=(rand()%500)/500.0;
	if( (int) (randN+0.5)==0 )
		val=population[i].gene[j]+(high-population[i].gene[j])*(pow(randN*(1-r),shapeFactor));
	if( (int) ( randN+0.5)==1 )
		val=population[i].gene[j]-(population[i].gene[j]-low)*(pow(randN*(1-r),shapeFactor));
	return(val);          //非均勻變異
}

/*************************************************************/
/* Calculate the object function                             */
/* I chose Shuber function as a test function,while X[-10 10]*/
/* This function has the global minimum value,F(X)=-186.731  */
/*************************************************************/

double obFun(double x[])
{
	double g[RECEIVES],b[201],r[RECEIVES];//定義數組
	double dt=0.5,f0=60;  //數組賦值
	double t[3];//時間
	double v[4];
	double SUM=0.0;
    int mx=1;  
    int i=0,j=0,nw=100;



	v[0]=x[0];
	
	v[1]=x[1];
	
	v[2]=x[2];

	v[3]=x[3];
   
	
	//初始化反射系數數組		  
	for(i=0;i<RECEIVES;i++)
		r[i]=0.0;

	t[0]=2*h[0]/v[0];
	j=(int)(1000*t[0]/dt);
	r[j]=(v[1]-v[0])/(v[1]+v[0]); //1層 

	
	for(i=1;i<NVARS;i++)
	{
		t[i]=t[i-1]+2*h[i]/v[i];
		j=(int)(1000*t[i]/dt);
		r[j]=(v[i+1]-v[i])/(v[i+1]+v[i]);//2-4層
	}	

	
	for(i=-nw;i<nw+1;i++)
	{
		double a=(0.001*PI*f0*i*dt);
        b[i+nw]=(1.0-2.0*a*a)*exp(-a*a);//求取子波,0相位,
        
	}

	
	//Convolution   子波和參數做卷積
	for(i=0;i<RECEIVES;i++)//從第一道循環
	{
		double sum=0.0;
	    for(j=0;j<2*nw+1;j++)
		{
			if(i-j>=0&&i-j<=2*nw)
		    sum=sum+b[j]*r[i-j+1];
		}
		g[i]=sum;
		
	}

	for(i=0;i<RECEIVES;i++)         //目標函數
		SUM+=(OBS[i]-g[i])*(OBS[i]-g[i]);
	    SUM=sqrt(SUM);
	return(5000.0-SUM);

}

/*************************************************************/
/* Evaluation function: This takes a user defined function.  */
/*************************************************************/

void evaluate(void)
{
	int mem;
	int i;
	double x[NVARS];
	for (mem = 0; mem < POPSIZE; mem++)
	{
		for (i=0;i<NVARS;i++)
            x[i] = population[mem].gene[i];
		population[mem].fitness =obFun(x);
	}
}

/***************************************************************/
/* searchBest function: This function keeps track of the       */
/* best member of the population. Note that the last entry in  */
/* the array Population holds a copy of the best individual    */
/***************從大到小排序排序********************************/

void searchBest()
{
	int mem;
    int i;
	struct genotype tempGA;
	for (mem=0;mem<POPSIZE-1;mem++)
	{
		for(i=mem+1;i<POPSIZE;i++)
		if (population[mem].fitness<population[i].fitness)
		{
			tempGA=population[mem];
			population[mem]=population[i];
			population[i]=tempGA;
		}
	}

	for(mem=0;mem<N;mem++)
		popMemory[mem]=population[mem];//記憶前N個基因
	
// once the best member in the population is found, copy the genes 
	population[POPSIZE]=population[0];
//    for (i = 0; i < NVARS; i++)
//		population[POPSIZE].gene[i] = population[0].gene[i];
}

/****************************************************************/
/* Elitist function: The best member of the previous generation */
/* is stored as the last in the array. If the best member of    */
/* the current generation is worse than the best member of the  */
/* previous generation, the latter one would replace the worst  */
/* member of the current population(保留最佳策略方案)           */
/****************************************************************/

void elitist()
{
	int i;
    double best, worst;             /* best and worst fitness values */
    int best_mem, worst_mem; /* indexes of the best and worst member */
    best = population[0].fitness;
    worst= population[0].fitness;
    for (i=0;i<POPSIZE-1;++i)
    {
		if(population[i].fitness>population[i+1].fitness)
		{  
            if (population[i].fitness>=best)
			{
				best = population[i].fitness;
                best_mem = i;
             }
            if (population[i+1].fitness<=worst)
            {
				worst=population[i+1].fitness;
                worst_mem=i+1;
            }
            }
		else
            {
			if (population[i].fitness<=worst)
			{
				worst = population[i].fitness;
                worst_mem=i;
            }
            if (population[i+1].fitness>= best)
            {
				best = population[i+1].fitness;
                best_mem =i+1;
             }
		}
	}
	printf("BestFitness=%8.4f \n",-best+5000.0);
/* if best individual from the new population is better than */
/* the best individual from the previous population, then    */
/* copy the best from the new population; else replace the   */
/* worst individual from the current population with the     */
/* best one from the previous generation                     */
	if (best>=population[POPSIZE].fitness)
    {
		for (i=0; i<NVARS; i++)
			population[POPSIZE].gene[i] = population[best_mem].gene[i];
		population[POPSIZE].fitness = population[best_mem].fitness;
    }
	else
    {
		for (i=0; i<NVARS; i++)
			population[worst_mem].gene[i] = population[POPSIZE].gene[i];
		population[worst_mem].fitness = population[POPSIZE].fitness;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕精品三区| 一区二区成人在线观看| 亚洲欧洲av色图| 久久精品国产澳门| 91黄色免费观看| 中文字幕欧美日韩一区| 三级欧美在线一区| 91视频91自| 国产日产欧产精品推荐色| 午夜电影一区二区三区| 91在线国产福利| 久久精品亚洲麻豆av一区二区| 亚洲综合成人在线视频| 成人黄色电影在线| 欧美v日韩v国产v| 亚洲国产精品人人做人人爽| 99视频精品在线| 日本一区二区三区四区| 九九**精品视频免费播放| 欧美另类高清zo欧美| 亚洲精品欧美激情| zzijzzij亚洲日本少妇熟睡| 久久看人人爽人人| 国产在线播放一区三区四| 欧美一区二区三区小说| 亚洲成人午夜电影| 精品视频一区二区不卡| 亚洲主播在线观看| 久久天天做天天爱综合色| 图片区小说区区亚洲影院| 欧美中文字幕久久| 亚洲狠狠爱一区二区三区| 在线这里只有精品| 亚洲韩国一区二区三区| 欧美日韩精品一区二区在线播放| 有码一区二区三区| 欧美亚洲综合网| 午夜激情综合网| 欧美一级免费大片| 麻豆国产精品一区二区三区| 日韩视频免费观看高清在线视频| 日本aⅴ精品一区二区三区| 欧美一级欧美三级在线观看| 久久99精品久久只有精品| 欧美电视剧在线观看完整版| 狠狠色狠狠色合久久伊人| 国产三级久久久| 91麻豆自制传媒国产之光| 亚洲素人一区二区| 欧美日韩高清一区二区三区| 视频一区二区欧美| 久久久91精品国产一区二区精品 | 欧美在线观看视频在线| 亚洲一区二区av电影| 在线播放/欧美激情| 久久国产免费看| 国产精品美女视频| 欧美中文字幕亚洲一区二区va在线 | 91欧美一区二区| 亚洲成人激情av| 精品电影一区二区| 成人高清免费在线播放| 亚洲777理论| 久久久久久久综合日本| 成人免费毛片app| 午夜一区二区三区视频| 久久久久久夜精品精品免费| 91香蕉视频污| 蜜桃av一区二区三区电影| 中文av一区二区| 欧美精品在线视频| 成人午夜视频在线观看| 午夜精品久久久久久久| 国产欧美一区二区三区网站| 欧美三级一区二区| 国产激情精品久久久第一区二区| 亚洲综合色丁香婷婷六月图片| 日韩精品一区二区三区视频在线观看| 国产成人免费视频网站高清观看视频| 伊人婷婷欧美激情| 国产午夜亚洲精品理论片色戒 | 欧美一区二区三区四区视频| 成人精品gif动图一区| 麻豆精品在线看| 亚洲一区免费观看| 国产精品不卡视频| 337p日本欧洲亚洲大胆精品 | 粉嫩av一区二区三区| 日韩成人午夜电影| 一区二区三区在线免费视频| 2023国产精品自拍| 91精品国产美女浴室洗澡无遮挡| 91免费在线视频观看| 国产91露脸合集magnet| 在线免费观看日韩欧美| 国产精品99久久久久久久vr| 五月婷婷色综合| 一区二区三区鲁丝不卡| 亚洲欧洲精品天堂一级 | 亚洲四区在线观看| 国产色爱av资源综合区| 日韩视频123| 欧美一区日本一区韩国一区| 在线看国产一区| 色噜噜夜夜夜综合网| 成人精品小蝌蚪| 懂色av一区二区三区免费看| 国产精品123区| 国产精品影视在线观看| 国产在线观看免费一区| 加勒比av一区二区| 精品在线免费视频| 韩国在线一区二区| 国产一区二区三区最好精华液| 久久66热偷产精品| 国产美女精品在线| 成人性生交大片免费看在线播放| 国产精品亚洲第一| 成人一级片在线观看| 成人精品鲁一区一区二区| 成人小视频免费观看| gogo大胆日本视频一区| 91免费版在线| 欧美三片在线视频观看| 欧美精品99久久久**| 日韩三级精品电影久久久 | 久久疯狂做爰流白浆xx| 久久不见久久见免费视频1| 美女高潮久久久| 国产精品456露脸| 成人毛片视频在线观看| 91在线免费视频观看| 欧美写真视频网站| 日韩伦理电影网| 亚洲午夜羞羞片| 久久激五月天综合精品| 国产a级毛片一区| 欧洲一区二区三区在线| 欧美一区日本一区韩国一区| 日韩欧美卡一卡二| 欧美国产禁国产网站cc| 亚洲另类春色国产| 日本午夜一本久久久综合| 韩国av一区二区三区| 99综合电影在线视频| 欧美日韩国产中文| 亚洲精品在线免费播放| 亚洲桃色在线一区| 日产国产高清一区二区三区| 国产福利一区二区| 在线一区二区观看| 26uuu亚洲综合色欧美| 一区二区在线免费| 黄色成人免费在线| 91麻豆精品视频| 欧美v日韩v国产v| 亚洲免费av观看| 韩国欧美国产一区| 色94色欧美sute亚洲线路一久 | 日本网站在线观看一区二区三区| 国产一区二区91| 欧美挠脚心视频网站| 国产欧美日韩视频一区二区| 亚洲综合网站在线观看| 国产成人精品亚洲日本在线桃色| 欧美在线色视频| 国产精品护士白丝一区av| 奇米色一区二区| 欧美在线视频你懂得| 国产精品网站在线播放| 欧美视频你懂的| 中文字幕不卡在线观看| 蜜臀99久久精品久久久久久软件 | 国产一区二区主播在线| 在线免费亚洲电影| 国产精品理论片在线观看| 九九久久精品视频| 欧美乱妇15p| 亚洲一区在线视频| av在线不卡电影| 国产精品无圣光一区二区| 韩国理伦片一区二区三区在线播放| 欧美日韩欧美一区二区| 亚洲欧美成人一区二区三区| 成人蜜臀av电影| 中文字幕二三区不卡| 国产a精品视频| 国产嫩草影院久久久久| 韩国欧美国产1区| 日韩午夜电影av| 美女脱光内衣内裤视频久久影院| 欧美日韩一区二区三区在线看| 国产精品美日韩| 国产成人啪免费观看软件| 国产日韩一级二级三级| 国产成人免费xxxxxxxx| 久久九九久久九九| 国产成人午夜精品5599| 国产午夜精品一区二区| 国内成人自拍视频|