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

📄 random.cpp

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

#include "stdafx.h"
#include "RTDMOEA.h"
#include "Random.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
int CRandom::Seed=0;
CRandom::CRandom()
{
    RandomInit();
}

CRandom::~CRandom()
{

}

void CRandom::RandomInit()
{
	Seed= (int)time(NULL);
	RandomInit(Seed);
}

void CRandom::RandomInit(int seed)
{
	Seed=seed;
  	srand(Seed);
}

double CRandom::Random(double m_Start, double m_End)
{
	return m_Start + (m_End - m_Start) * rand() /RAND_MAX;
}

int CRandom::Random(int m_Start, int m_End)  //[m_Start , m_End]
{
	return (m_Start + rand() % (m_End -m_Start+1));
}

⌨️ 快捷键说明

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