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

📄 plant.cpp

📁 求解梯级水库群优化调度
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#ifndef PLANT_H
#include "Plant.h"
#endif
#ifndef OS_H
#include "Os.h"
#endif
CPlant::CPlant()
{
	Init();
}

CPlant::CPlant(string name,int serial,double coeff,double level,double storedprice)
{
	Init();
	PlantName=name;
	PlantSerial=serial;
	EvageCoeff=coeff;
	StartLevel=level;
	StoredPrice=storedprice;	
}
CPlant::CPlant(string name,string filepath)
{
	Init();
	PlantName=name;
	FloadPlantParam(name,filepath);
	SetConfiguration();
}

CPlant::CPlant(const CPlant &cpt)
{
	Init();
	PlantName=cpt.PlantName;
	PlantSerial=cpt.PlantSerial;
	StartSectionSerial=cpt.StartSectionSerial;
	EvageCoeff=cpt.EvageCoeff;
	StartLevel=cpt.StartLevel;
	StoredPrice=cpt.StoredPrice;
	NormalLevel=cpt.NormalLevel;
	DeadLevel=cpt.DeadLevel;
	LimitLevel=cpt.LimitLevel;
	DesignLevel=cpt.DesignLevel;
	CheckLevel=cpt.CheckLevel;
	HighLevel=cpt.HighLevel;
	SectionTime=cpt.SectionTime;////
	LevelLostParam=cpt.LevelLostParam;/////
	EvageLevelLost=cpt.EvageLevelLost;/////
	StepLength=cpt.StepLength;
	WaterRate=cpt.WaterRate;
	RatePowerLevel=cpt.RatePowerLevel;
	copy(cpt.MaxWaterLevel.begin(),cpt.MaxWaterLevel.end(),MaxWaterLevel.begin());
	copy(cpt.MinWaterLevel.begin(),cpt.MinWaterLevel.end(),MinWaterLevel.begin());
	copy(cpt.MaxPower.begin(),cpt.MaxPower.end(),MaxPower.begin());
	copy(cpt.MinPower.begin(),cpt.MinPower.end(),MinPower.begin());
	copy(cpt.MaxDownFlow.begin(),cpt.MaxDownFlow.end(),MaxDownFlow.begin());
	copy(cpt.MinDownFlow.begin(),cpt.MinDownFlow.end(),MaxDownFlow.begin());
	copy(cpt.MaxPowerFlow.begin(),cpt.MaxPowerFlow.begin(),MaxPowerFlow.begin());
	copy(cpt.MinPowerFlow.begin(),cpt.MinPowerFlow.begin(),MinPowerFlow.begin());
	copy(cpt.SectionIntervalFlow.begin(),cpt.SectionIntervalFlow.end(),SectionIntervalFlow.begin());
	copy(cpt.SectionPowerPrice.begin(),cpt.SectionPowerPrice.end(),SectionPowerPrice.begin());
	copy(cpt.VolumeLevelParam.begin(),cpt.VolumeLevelParam.end(),VolumeLevelParam.begin());
	copy(cpt.TailFlowParam.begin(),cpt.TailFlowParam.end(),TailFlowParam.begin());
	copy(cpt.LevelVolumeParam.begin(),cpt.LevelVolumeParam.end(),LevelVolumeParam.begin());
	copy(cpt.SectionPower.begin(),cpt.SectionPower.end(),SectionPower.begin());
	copy(cpt.SectionPowerFlow.begin(),cpt.SectionPowerFlow.end(),SectionPowerFlow.begin());
	copy(cpt.SectionDischarge.begin(),cpt.SectionDischarge.end(),SectionDischarge.begin());
	copy(cpt.SectionWaterLevel.begin(),cpt.SectionWaterLevel.end(),SectionWaterLevel.begin());
}

CPlant::~CPlant()
{
	//析构函数
}
void CPlant::Init()
{
	PlantName="";
	PlantSerial=0;
	StartSectionSerial=0;
	SectionTime=0;////////////
	EvageCoeff=0;
	StartLevel=0;
	StoredPrice=0;
	NormalLevel=0;
	DeadLevel=0;
	LimitLevel=0;
	DesignLevel=0;
	CheckLevel=0;
	HighLevel=0;
	LevelLostParam=0;/////////
	EvageLevelLost=0;/////////
	StepLength=0;///////
	WaterRate=0;/////
	RatePowerLevel=0;////
	EvageTailLevel=0;////
	for(int i=0;i<SectionNum;i++)
	{
		MaxWaterLevel.push_back(0);
	    MinWaterLevel.push_back(0);
	    MaxPower.push_back(0);
	    MinPower.push_back(0);
        MaxPowerFlow.push_back(0);
	    MinPowerFlow.push_back(0);
	    MaxDownFlow.push_back(0);
	    MinDownFlow.push_back(0);
        SectionIntervalFlow.push_back(0);
		SectionPowerPrice.push_back(0);
		SectionPower.push_back(0);
		SectionPowerFlow.push_back(0);
		SectionDischarge.push_back(0);
		SectionWaterLevel.push_back(0);
	}
	for(int j=0;j<ParamNum;j++)
	{
		VolumeLevelParam.push_back(0);
		TailFlowParam.push_back(0);
		LevelVolumeParam.push_back(0);
	}
}

int CPlant::FloadPlantParam(string plant,string filepath)
{
	//Init();
	char strtemp[260];
	GetPrivateProfileString(plant.c_str(),"PlantName",NULL,strtemp,80,filepath.c_str());
 	PlantName=strtemp;
	PlantSerial=GetPrivateProfileInt(plant.c_str(),"PlantSerial",0,filepath.c_str());
	StartSectionSerial=GetPrivateProfileInt(plant.c_str(),"StartSectionSerial",0,filepath.c_str());
	GetPrivateProfileString(plant.c_str(),"EvageCoeff",NULL,strtemp,80,filepath.c_str());
    EvageCoeff=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"StepLength",NULL,strtemp,80,filepath.c_str());
	StepLength=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"StartLevel",NULL,strtemp,80,filepath.c_str());
    StartLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"RatePowerLevel",NULL,strtemp,80,filepath.c_str());
	RatePowerLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"EvageTailLevel",NULL,strtemp,80,filepath.c_str());
	EvageTailLevel=atof(strtemp);

	GetPrivateProfileString(plant.c_str(),"EvageLevelLost",NULL,strtemp,80,filepath.c_str());
	EvageLevelLost=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"SectionTime",NULL,strtemp,80,filepath.c_str());
	SectionTime=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"LevelLostParam",NULL,strtemp,80,filepath.c_str());
	LevelLostParam=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"StoredPrice",NULL,strtemp,80,filepath.c_str());
	StoredPrice=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"NormalLevel",NULL,strtemp,80,filepath.c_str());
	NormalLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"DeadLevel",NULL,strtemp,80,filepath.c_str());
	DeadLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"DesignLevel",NULL,strtemp,80,filepath.c_str());
	DesignLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"CheckLevel",NULL,strtemp,80,filepath.c_str());
	CheckLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"LimitLevel",NULL,strtemp,80,filepath.c_str());
	LimitLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"HighLevel",NULL,strtemp,80,filepath.c_str());
	HighLevel=atof(strtemp);
	GetPrivateProfileString(plant.c_str(),"WaterRate",NULL,strtemp,80,filepath.c_str());
	WaterRate=atof(strtemp);	
	GetPrivateProfileString(plant.c_str(),"MaxDownFlow",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MaxDownFlow,strtemp,',');// 
	GetPrivateProfileString(plant.c_str(),"SectionPower",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(SectionPower,strtemp,',');//获得时段出力
	GetPrivateProfileString(plant.c_str(),"MinDownFlow",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MinDownFlow,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"MaxWaterLevel",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MaxWaterLevel,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"MinWaterLevel",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MinWaterLevel,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"MaxPower",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MaxPower,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"MinPower",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MinPower,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"MaxPowerFlow",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MaxPowerFlow,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"MinPowerFlow",NULL,strtemp,80,filepath.c_str());
	GetDataOfString(MinPowerFlow,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"VolumeLevelParam",NULL,strtemp,200,filepath.c_str());
	GetDataOfString(VolumeLevelParam,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"TailFlowParam",NULL,strtemp,200,filepath.c_str());
	GetDataOfString(TailFlowParam,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"LevelVolumeParam",NULL,strtemp,200,filepath.c_str());
	GetDataOfString(LevelVolumeParam,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"SectionIntervalFlow",NULL,strtemp,200,filepath.c_str());
	GetDataOfString(SectionIntervalFlow,strtemp,',');
	GetPrivateProfileString(plant.c_str(),"SectionPowerPrice",NULL,strtemp,200,filepath.c_str());
	GetDataOfString(SectionPowerPrice,strtemp,',');
	return 1;
}
int CPlant::FloadPlantParam(string dbname,string userid,string password,int modelid)
{
	return 1;
}


void CPlant::InitVector(vector<double > &vec,int n)
{
	for(int i=0;i<n;i++)
		vec.push_back(0);
}
double CPlant::GetPowerFlow(double power,double start_level,double end_level,double last_down,int section)
{
	double v2,v1,hf,down;
	v2=GetPlantVolume(end_level);
	v1=GetPlantVolume(start_level);
	down=GetSectionIntervalFlow(section)+last_down+(v1-v2)/GetSectionTime();
	hf=GetPlantTailLevel(down);
	return power/(GetEvageCoeff()*((start_level+end_level)/2-hf-GetEvageLevelLost()));
}
double CPlant::GetPowerFlow(int section,double last_down)
{
	//给定功率求发电流量,功率由外面给定,存入对像
	double v2,v1,hf,down,power,h1,h2;
	h2=GetSectionWaterLevel(section);
	if(section>0)		

⌨️ 快捷键说明

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