📄 stdafx.h
字号:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__93438395_AA5A_404A_94ED_95F39EDE5AE5__INCLUDED_)
#define AFX_STDAFX_H__93438395_AA5A_404A_94ED_95F39EDE5AE5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#ifndef _GLOBALV_H
#define _GLOBALV_H
const int iAntCount=30;//ant numbers
const int iCityCount=51;
double Q=100;
//const int iItCount=1000;
// double alpha=1;
//double beta=1;
//double rou=0.5;
int besttour[iCityCount];
class GInfo
{
public:
double m_RateX,m_RateY;
double m_CityPos[iCityCount][2];
double m_dDeltTrial[iCityCount][iCityCount];
double m_dTrial[iCityCount][iCityCount];
double distance[iCityCount][iCityCount];
double counter[iCityCount][iCityCount];
public:
void LoadFromFile()
{
}
void init()
{
m_RateX=1;
m_RateY=1;
for(int i=0;i<iCityCount;i++)
{
for(int j=0;j<iCityCount;j++)
{
m_dTrial[i][j]=1;
m_dDeltTrial[i][j]=0;
counter[i][j]=0;
}
}
}
GInfo()
{
init();
}
};
double rnd(int low,double uper)
{
double p=(rand()/(double)RAND_MAX)*((uper)-(low))+(low);
// double p=(rand()%((uper)-(low))+(low));
return (p);
};
int rnd(int uper)
{
return (rand()%uper);
};
class CAnt
{
private:
int ChooseNextCity();
double prob[iCityCount];
int m_iCityCount;
int AllowedCity[iCityCount];
public:
void addcity(int city);
int tabu[iCityCount];
void Clear();
void UpdateResult();
double m_dLength;
double m_dShortest;
void move();
CAnt();
void move2last();
};
class CResearcher
{
public:
double leftX,topY,rightX,bottomY;
double temp; //每次迭代的长度
int m_Round; //迭代次数
int temptour[iCityCount]; //每次的顺序
public:
void UpdateTrial();
double m_dLength;
void init();
CAnt ants[iAntCount];
void GetAnt();
void LoadFile();
void StartSearch();
bool EndResearch();
CResearcher();
};
#endif
//---------------------------------------------------------------------------------
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//---------------------------------------------------------------------------------
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__93438395_AA5A_404A_94ED_95F39EDE5AE5__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -