遗传算法-C语言模板

using System;

using System.IO;

usingSystem.Collections;

usingSystem.Collections.Generic;

usingSystem.Text;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Data.OleDb;

namespace ConsoleApplication1 {

public class Genetic_Algorithm变量声明

{

Random rand=new Random();

intMaxTime;//最大运行时间

intpopsize;//种群数量

intChromosomeLength;//染色体长度

double CrossRate;//交叉率

double MutateRate;//变异率

double[] f;//适应度值

int[] selected;//定义selected数组,用于表示需要进行交叉操作的染色体序号

double[] wheel;//轮盘

int[,] pregeneration;//上一代

int[,] nextgeneration;//下一代

int[] Best;//定义当前最优解

int convergence;//定义当前最优解的已持续代数

public Genetic_Algorithm(intpopulationsize, intchromolength)//GA--构造函数,变量初始化

{

rand = new Random(System.DateTime.Now.Millisecond);

MaxTime = 50;

popsize=populationsize;

ChromosomeLength = chromolength;

CrossRate = 0.8;

MutateRate = 0.2;

f = new double[2*popsize];

你可能喜欢

  • 算法代码
  • 遗传算法程序
  • C语言算法描述
  • C语言算法大全
  • C语言经典算法
  • C语言PID算法

遗传算法 C语言模板相关文档

最新文档

返回顶部