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

📄 rtcgpskur.cpp

📁 基于GPS的多目标优化及动态多目标优化源代码 里面 包含MOP, DMOP的程序
💻 CPP
字号:
// GPSKUR.cpp: implementation of the CGPSKUR class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "RTDMOEA.h"
#include "RTCGPSKUR.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

RTCGPSKUR::RTCGPSKUR()
{

}

RTCGPSKUR::~RTCGPSKUR()
{

}
void RTCGPSKUR::InitPop()
{
   CSolution t_temp;
   t_temp.Init();
   for (int i=0;i<PopSize;i++)
   {
	   /**  设置 KUR 的初始化GENE   **/
	   for (int j =0;j< CSolution::GetGeneLength() ;j++)
		   t_temp.Gene[j] =CRandom::Random(-5.0,5.0);   
      /***  增加个体 */
	   m_Pop[i].Init();
       m_Pop[i].Copy(&t_temp);
   }
      InitPopType();
}

void RTCGPSKUR::ComputeFitness(CSolution &m_1)
{
	   for (int j =0;j< CSolution::GetGeneLength() ;j++)
	   {
		   if ((m_1.Gene[j] > 5.0 ) ||(m_1.Gene[j] <- 5.0)) {
		   		   m_1.Gene[j] =CRandom::Random(-5.0,5.0);
		   };   
	   }
	//KUR 函数
     m_1.Objective[0] =  (-10) * exp(-0.2 * sqrt(m_1.Gene[0]*m_1.Gene[0] + m_1.Gene[1]*m_1.Gene[1]))
		 + (-10) * exp(-0.2 * sqrt(m_1.Gene[1]*m_1.Gene[1] + m_1.Gene[2]*m_1.Gene[2]));
     m_1.Objective[1]= pow(fabs(m_1.Gene[0]),0.8) + 5 * sin( m_1.Gene[0] *m_1.Gene[0]*m_1.Gene[0])
		 + pow(fabs(m_1.Gene[1]),0.8) + 5 * sin( m_1.Gene[1] *m_1.Gene[1]*m_1.Gene[1])
		 + pow(fabs(m_1.Gene[2]),0.8) + 5 * sin( m_1.Gene[2] *m_1.Gene[2]*m_1.Gene[2]);

}

void RTCGPSKUR::RandomMutate(int Index)
{
	   /**  设置 KUR 的初始化GENE   **/
	   for (int j =0;j< CSolution::GetGeneLength() ;j++)
		   m_Pop[Index].Gene[j] =CRandom::Random(-5.0,5.0);   
}

⌨️ 快捷键说明

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