资源简介
水库调度 不错的程序
代码片段和文件信息
#include
#include
#include
#include
#include
#include
using namespace std;
const int N = 100;
const int M = 372;
const int M1= 6;
const int M2= 6;
float chazhi(float x0float y1[]float y2[]int num)
{
int m1;
for(m1=1;m1<=num-1;m1++)
if(x0<=y1[m1]&&x0>y1[m1-1])
return(y2[m1 - 1] + (x0 - y1[m1 - 1]) * (y2[m1] - y2[m1 - 1]) / (y1[m1] -y1[m1 - 1]));
if(x0<=y1[0])
return(y2[0]);
if(x0>y1[num-1])
return(y2[num-2] + (x0- y1[num-2]) * (y2[num-1] - y2[num-2]) / (y1[num-1] - y1[num-2]));
}
int main()
{
//-----------变量的定义---------------------------------------------------
int cfxsijkjs;
int num1=Mnum2=M1num3=M2;
float vmaxvminsumexxz1xxz2zczvjunbvzdqzxqzcvxxv1xxv2svNzhNpmax[N]={0}Qclxs;
float qt[M]szabc; //来流量
float yv[M][N]yz[M][N]yzx[M][N]fz[M1]fv[M1]; //水库库容水位,水位库容曲线
float fqx[M2]fzx[M2]yqx[M][N]yh[M][N]yr[M][N]yw[M][N]={0}ye[M][N];//下泄流量曲线,各阶段出力
int ml[M][N]xx[M][N]xxx[N][N];
float c0=400.0; //惩罚系数
float le[N][N]lq[N][N]lzx[N][N]lh[N][N]lr[N][N]lw[N][N]lyz[N][N];//临时阶段变量
//-------输入输出数据---------------
char *fname=“result.txt“; //physical file name
ofstream fout(fnameios::out); //opening file for output
if( !fout ) //handles errors in file opening
{
cerr<<“Error in opening file for output!“;
exit(1);
}
string ifname;
ifstream fin;
cout<<“Enter the filename of in file“< cin>>ifname;
fin.open(ifname.c_str());
if( fin.fail() )
{
cout<<“ERROR open the in file “< exit(1);
}
else
{
for( i = 0; i < num1; i++ )
fin>>qt[i]; //来流量
for(i=0;i fin>>fz[i];
for(i=0;i fin>>fv[i]; //上游库容水位
for(i=0;i fin>>fzx[i];
for(i=0;i fin>>fqx[i]; //下游水位和下泄流量
fin>>zdq>>zxq>>Nzh>>Np>>xxz1>>xxz2>>zcz>>sz>>clxs;
}//end open infile and intialize tha array x[]
fin.close();
//---------------------------------------------------------------------------------------
sv=chazhi(szfzfvnum2);
xxv1=chazhi(xxz1fzfvnum2);
xxv2=chazhi(xxz2fzfvnum2);
zcv=chazhi(zczfzfvnum2);
for(i=0;i {
if (((i+1)%12)<3)
{
if(xxv1>sv)
{
vmax = xxv1;
vmin=sv;
}
else
{
vmax=xxv1;
vmin=xxv1;
}
}
if (((i+1)%12)==3)
{
if(xxv2>sv)
{
vmax = xxv2;
vmin=sv;
}
else
{
vmax=xxv2;
vmin=xxv2;
}
}
if (((i+1)%12)>=4)
{
vmax = zcv;
vmin=sv;
}
if(i==num1-1)
{
if(xxv1>sv) vmax=vmin=sv;
else vmax=vmin=xxv1;
}
vjun=(vmax-vmin)/(N-1);
for(j=0;j {
yv[i][j]=vmin+j*vjun; //各阶段各状态库容
}
}
//--------------------------------------------第一阶段 从死水位开始
for(i=0j=0;j {
if(xxv1>sv) vmin=sv;
else vmin=xxv1;
cfxs=0;
bv=yv[i][j]/2.0+vmin/2.0; //第一阶段平均库容
yz[i][j]=chazhi(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8168 2008-07-18 20:17 DP.cpp
----------- --------- ---------- ----- ----
8168 1
- 上一篇:CentOS7.0镜像包
- 下一篇:Unreal Engine 4 中文文档
评论
共有 条评论