• 大小: 18.6MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-16
  • 语言: C/C++
  • 标签: 遗传算法  c++  代码  

资源简介

附有遗传算法的C++代码,以及运行结果origin处理文件。

资源截图

代码片段和文件信息

#include “pch.h“
//*******************
//交叉算子函数,两点交叉
//*******************
void ga::crossover_operator(Individual population[N_genetic] vector low vector high)
{
int i j cpoint1 cpoint2 t;                //交叉点cpoint1 cpoint2生成t为替换值
double p_c;                              //随机产生交叉概率
extern RandomNumber r;       //定义全局随机数
extern ga GA;               //定义全局遗传算法相关函数
for (i = 0; i < N_genetic; i = i + 2)
{//随机产生两个交叉点的数
cpoint1 = r.integer(0 1000) % (N_variable* L_variable);
cpoint2 = r.integer(0 1000) % (N_variable* L_variable);
if (cpoint2 < cpoint1)
{
t = cpoint2; cpoint2 = cpoint1; cpoint1 = t;
}
p_c = r.decimal(0 1.0);
//交叉过程
if (p_c < C_pgentic)
{
for (j = cpoint1; j <= cpoint2; j++)
{
t = population[i].x_binary[j]; population[i].x_binary[j] = population[i + 1].x_binary[j]; population[i + 1].x_binary[j] = t;
}
}
}
//p_c = p(a); cout << p_c << endl;
//交叉后的染色转换为实数
for (i = 0; i < N_genetic; i++)
{
GA.Real_trans(population &i low high);
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        644  2019-09-05 22:19  Genetic_algorithm\debug.log

    ..A..H.     71168  2019-09-28 18:48  Genetic_algorithm\Genetic_algorithm\.vs\Genetic_algorithm\v15\.suo

     文件    6725632  2019-09-28 18:48  Genetic_algorithm\Genetic_algorithm\.vs\Genetic_algorithm\v15\Browse.VC.db

     文件   48168960  2019-09-28 18:48  Genetic_algorithm\Genetic_algorithm\.vs\Genetic_algorithm\v15\ipch\72677f9402e2ddf1.ipch

     文件     173568  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Debug\Genetic_algorithm.exe

     文件    5255620  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Debug\Genetic_algorithm.ilk

     文件    1822720  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Debug\Genetic_algorithm.pdb

     文件       1139  2019-09-04 18:32  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Crossover_operator.cpp

     文件     116044  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Crossover_operator.obj

     文件      56608  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\fitness_function.obj

     文件       8610  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\CL.command.1.tlog

     文件      23958  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\CL.read.1.tlog

     文件      16636  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\CL.write.1.tlog

     文件        224  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\Genetic_algorithm.lastbuildstate

     文件       3238  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\link.command.1.tlog

     文件       6326  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\link.read.1.tlog

     文件       2114  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_.68F3F92B.tlog\link.write.1.tlog

     文件        327  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_algorithm.log

     文件     408339  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_algorithm.obj

     文件   37617664  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Genetic_algorithm.pch

     文件     234766  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Initialize.obj

     文件     115782  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Mutate_operator.obj

     文件      62599  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\pch.obj

     文件     115468  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Real_trans.obj

     文件     197524  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\Select_operator.obj

     文件     175811  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\select_optimal.obj

     文件     289792  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\vc141.idb

     文件     610304  2019-09-04 20:16  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Debug\vc141.pdb

     文件        712  2019-09-05 10:50  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\fitness_function.cpp

     文件       1449  2019-09-04 20:13  Genetic_algorithm\Genetic_algorithm\Genetic_algorithm\Genetic_algorithm.cpp

............此处省略41个文件信息

评论

共有 条评论