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

📄 distribution.cpp

📁 This program proposed improved adaptive genetic algorithms saccording to the idea that the best indi
💻 CPP
字号:
// distribution.cpp: implementation of the distribution class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "2level.h"
#include "distribution.h"

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

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

distribution::distribution()
{
	


}

distribution::~distribution()
{
	

}
global distribution::distribute(double H1,double h5,int m,double B)
{
	
	int i;
	de_dragmodel yield;
	pressmodel press;
	speedmodel speed;
	double *p_speed;
	torquemodel torque;
	powermodel power;
	GA GA;
	double sum_power_ratio=0; //功率平衡因数和
	double aver_power_ratio;  //平均功率平衡因数
  	
	//confirm the thickness of last stand according the fixed 
	
	//select the yield number;
	
	double rH[5];  //整体压下量
	
	initialdistribute init;
	global y;
	y.label=false;
	y.m=m;
//////////////////////////////////////////////////////////////////////
// initialize
//////////////////////////////////////////////////////////////////////
	y.InitializeData();
	double *p1;
	p1=init.distribute(H1,h5,m,B);   //initial the schedule;
	rf=0.05;                             //ensure the relative press value of last stand;
	y.r[4]=rf;
	
	//according the relative press value to ensure the entry thickness of last stand;
    y.H[4]=h5/(1-rf); 
	y.H[0]=H1;
	//initial the out thickness of  all stands;
	y.h[0]=p1[0];
	y.h[1]=p1[1];
	y.h[2]=p1[2];
	y.h[3]=y.H[4];
	y.h[4]=h5;
	//initial the speed
	p_speed=speed.init_speed(y.h);
	for(i=0;i<=4;i++)
	{
		y.v[i]=p_speed[i];
	}
//////////////////////////////////////////////////////////////////////
// distribution
//////////////////////////////////////////////////////////////////////	

	p1=GA.GA_1(y);
	double x1,x2,x3;
	y.time=(int)p1[0];
	x1 = p1[1];
	x2 = p1[2];
	x3 = p1[3];
		
	y.h[4]=y.h5;
	y.h[0]=x1;
	y.h[1]=x2;
	y.h[2]=x3;
	y.h[3]=y.h[4]/(1-0.05);
	
		
	y.H[0]=y.H0;
	y.H[1]=y.h[0];
	y.H[2]=y.h[1];
	y.H[3]=y.h[2];
	y.H[4]=y.h[3];

	//compute the relative press value  of  1 stand to 4 stand;

	rH[0]=(y.H[0]-y.h[0])/y.H0;
	rH[1]=(y.H[0]-y.h[1])/y.H0;
	rH[2]=(y.H[0]-y.h[2])/y.H0;
	rH[3]=(y.H[0]-y.h[3])/y.H0;
	rH[4]=(y.H[0]-y.h[4])/y.H0;

	for(i=0;i<=4;i++)
	{
		y.r[i]=(y.H[i]-y.h[i])/y.H[i];
		
	}
		
	//compute the yield ;
	
	for (i=0;i<=4;i++)
	{
		y.de_drag[i]=yield.de_drag(y.m,rH[i]);

	}
	
	//compute the press value of every stand;
	
	for (i=0;i<=4;i++)
	{
		y.P[i]=press.press1(i,y,y.de_drag[i]);
	}
	
	//compute the rolling speed;
	for(i=0;i<=4;i++)
	{
		y.vr[i]=speed.roll_speed(i,y);
	}
	
	//compute the torque of every stand;
				
	for(i=0;i<=4;i++)
	{
		y.MM[i]=torque.torque(i,y);
		
	}
			
	//compute the power of every stand;
	
	for(i=0;i<=4;i++)
	{
		y.W[i]=power.power(i,y);
	}
//////////////////////////////////////////////////////////////////////
// 计算最终结果
//////////////////////////////////////////////////////////////////////		
				
	//重新计算功率
	y.v[4]=speed.max_speed(y);
	
	y.v[3]=y.h[4]/y.h[3]*y.v[4];
	y.v[2]=y.h[4]/y.h[2]*y.v[4];
	y.v[1]=y.h[4]/y.h[1]*y.v[4];
	y.v[0]=y.h[4]/y.h[0]*y.v[4];
		
	for(i=0;i<=4;i++)
	{
		y.vr[i]=speed.roll_speed(i,y);
	}
	for(i=0;i<=4;i++)
	{
		y.W[i]=power.power(i,y);
	}
//////////////////////////////////////////////////////////////////////
//检验目标是否达到
//////////////////////////////////////////////////////////////////////	
	
	//计算平衡因数
		
	for(i=0;i<=3;i++)
	{
		y.power_ratio[i]=y.W[i]/y.max_power[i];
	}
	//compute the average power ratio
		
	for(i=1;i<=3;i++)
	{
		sum_power_ratio=sum_power_ratio+y.power_ratio[i];
	}
	aver_power_ratio=sum_power_ratio/3;
		
	y.ratio[0]=y.P[0]/y.P[1];
	
	y.ratio[1]=y.power_ratio[1]/aver_power_ratio;
	y.ratio[2]=y.power_ratio[2]/aver_power_ratio;
	y.ratio[3]=y.power_ratio[3]/aver_power_ratio;

	double aa[4];
	aa[0]=0.8;
	aa[1]=1;
	aa[2]=1;
	aa[3]=1;
	double OBJECTIVE=0;
	for(i=0;i<=3;i++)
	{
		OBJECTIVE= OBJECTIVE+100*aa[i]*(1-y.ratio[i])*(1-y.ratio[i]);
			
	}
	y.n[0]=OBJECTIVE;
	
	return y;
}

⌨️ 快捷键说明

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