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

📄 gamblingpad.cpp

📁 c写的遗传和蚁群融合用于tsp的代码 很好的写论文的材料
💻 CPP
字号:
// GamblingPad.cpp: implementation of the GamblingPad class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ASA.h"
#include "GamblingPad.h"

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

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

GamblingPad::GamblingPad()
{
	citycnt=0;       //表示城市数目
	type=YUANSHIPRO;
}

int GamblingPad::getCity()
{
	if (type==YUANSHIPRO/*原始分布概率*/) 
	{

		double leijipr=0;
		int i;
		for (i=0; i<citycnt; i++)
		{
			leijipr +=pr[i];
			pr[i]    =leijipr;
		}
		pr[citycnt-1]=1.1;
	}

	double point = (rand()%100)/100.0;
	for (int j=0; j<citycnt;j++)
	{
		if (point<pr[j])break;
	}
	return city[j];
}

GamblingPad::~GamblingPad()
{

}

⌨️ 快捷键说明

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