📄 ga_main.cpp
字号:
// ga_main.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
//自定义头文件
#include "myRandom.h"
#include "parameter.h"
#include "myga.h"
//标准头文件
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//*************算法参数设定***********************//
//产生伪随机数
MyRandom myRandom;
//设置参数
MyParameter myparameter;
//*****************The End************************//
int _tmain(int argc, _TCHAR* argv[])
{
myparameter.set_parameter (40,40,200,0.6,0.0015,1);
ofstream outfile("output.txt");
MyGA myGA;
myGA.run (outfile);
double max_fitness = myGA.nodes [0].fitness ;
for(int i =0;i<100;i++){
cout<<"x1= "<<myGA.nodes [i].x1 <<" x2= "<<myGA.nodes [i].x2 <<" fitness = "<<myGA.nodes [i].fitness <<endl;
if(myGA.nodes [i].fitness > max_fitness)
max_fitness = myGA.nodes [i].fitness ;
}
cout<<"The best fitness is : "<<max_fitness<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -