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

📄 head.h

📁 C++解决VRPTW的源码,采用遗传算法编写
💻 H
字号:
#ifndef head_h
#define head_h

class CBase
{private:
  int pointx;
  int pointy;
 public:
  CBase(int=0,int=0);
  int GetPointx();
  int GetPointy();
  void SetPointx(int=0);
  void SetPointy(int=0);
 };

CBase::CBase(int x,int y)
 :pointx(x),pointy(y)
{
}

int CBase::GetPointx() 
{
	return pointx;
}

int CBase::GetPointy() 
{
	return pointy;
}

void CBase::SetPointx(int x)
{
	pointx=x;
}

void CBase::SetPointy(int y)
{
	pointy=y;
}

class CImport :public CBase
{//城市或收获点类
 private:
   int  Order;
   double  Time;
   double  Earlytime;
   double  Latetime;
   double  Load;
 public:
   CImport(int=0,int=0,int=0,double=0,double=0,double=0,double=0);
   void SetTime(int=0);
   int GetOrder() ;
   double GetTime() ;
   double GetEarlytime() ;
   double GetLatetime() ;
   double GetLoad() ;

   void Print () ;
 //  void operator=(const Import&);
};

CImport::CImport(int x,int y,int ord, double lo,double t1,double t2,double t3)
:CBase(x,y)
{//构造函数
 Order=ord;
 Load=lo;
 Earlytime=t1;
 Latetime=t2;
 Time=t3;
}

int CImport::GetOrder() 
{
	return Order;
}

double CImport::GetTime() 
{
	return Time;
}

double CImport::GetEarlytime() 
{
	return Earlytime;
}

double CImport::GetLatetime() 
{
	return Latetime;
}

double CImport::GetLoad() 
{
	return Load;
}


class CVehicleExport:public CBase
{//发货点类(发货点集合了车场的性能)
 private:
   char name;
   int  VehicleNum;
 public:
   CVehicleExport(char='A',int=0,int=0,int=0);
   void SetVehicleNum(int);
   char GetName() ;
   int GetVehicleNum() ;
   operator CImport();
   void Print() ;
  // void operator=(const VehicleExport&);
};

CVehicleExport::CVehicleExport(char ch,int x,int y,int num)
:CBase(x,y)
{//构造函数
 name=ch;
 VehicleNum=num;
}

void CVehicleExport::SetVehicleNum(int z)
{//某出货点运货需要的车辆数初始化
    VehicleNum=z;
}

char CVehicleExport::GetName() 
{
	return name;
}

int CVehicleExport::GetVehicleNum() 
{
	return VehicleNum;
}

template<class T>
void ss(T& t1,T& t2)
{
	T hold=t2;
	t2=t1;
	t1=hold;
}


template<class T>
void quicksort (T *array,int hi,int lo=0)
{
	while (hi>lo)
	{
		int i=lo;
		int j=hi;
		do {
			while ((array[i]<array[lo])&&(i<j))  i++;
            while (array[--j]>array[lo]);
			if (i<j)
			{
				ss(array[j], array[i]);
	    	    ss(ff[i],ff[j]);
			}
		}while (i<j);
		ss(array[lo],array[j]);
    	ss(ff[lo],ff[j]);
		if (j-lo>hi-(j+1))
		{
			quicksort (array,j-1,lo);
			lo=j+1;
		}
		else
		{
			quicksort (array,hi,j+1);
			hi=j-1;
		}
	}// end of for while (hi>lo)
}// end of for quicksort

#endif

⌨️ 快捷键说明

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