本文实例讲述了C++实现简单遗传算法。分享给大家供大家参考。具体实现方法如下:
//遗传算法 GA
#include
#include
#include
using namespace std;
const int L=5; //定义编码的长度
int f(int x) //定义测设函数f(x)
{
int result;
result=x*x*x-60*x*x+900*x+100;
return result;
}
int main(int argc,char *argv[])
{
int
本文实例讲述了C++实现简单遗传算法。分享给大家供大家参考。具体实现方法如下:
// CMVSOGA.h : main header file for the CMVSOGA.cpp
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
#if !defined(AFX_CM