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

📄 classification.cpp

📁 GEP(基因表达式程序设计)是一种新的演化算法
💻 CPP
字号:
// classification.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>         
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include "Gene.h"
#define  maxnode 34

char stringinitial[maxnode+1];
int  strlength;
  
char headtype[]="+-*/ILE~SCQa?";     //what kinds of characters can be read to the head.
char tailtype[]="a?";
double Dc[7]={1.0,2.0,3.0,5.0,7.0};

void initialchar();

void main(int argc, char* argv[])
{
	int i,count;
	
	for(count=0;count<20;count++)
	{
		initialchar();
	    cout<<"initial:";
        cout<<stringinitial<<endl;

		i=13;
	    Gene gene(stringinitial,i);
	    gene.Insert();
	    gene.Postorder(gene.headpoint);
		double tenvary[2]={4.0,0.0};   
	    gene.Result(Dc,tenvary);
		cout<<"result="<<gene.Displayresult()<<endl;
		if(count%50==0)getch();
	}
}

void initialchar()
{
	int i,point;

	srand((unsigned)time(NULL));


	for(i=0;i<13;i++){
		if(i<6)
		{
			point=rand()%(13);
			stringinitial[i] = headtype[point];
		}                  /*get the genes' head from the head set.*/
		else
		{
			point=rand()%(2);
			stringinitial[i] = tailtype[point];
		}                 /*get the genes' tail from the tail set.*/
	}
	stringinitial[i]='\0';
	//for(int j=0;j<13;i++)cout<<string[j]<<endl;
}

⌨️ 快捷键说明

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