资源简介
求解水库优化调度,的C++源代码,直接可以下载应用
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int M=373;
const int N=100;
const int X=4;
const int L=4;
const int S=22;
//----------------------------------------------定义全局变量---------------------------------
int jd;
int num1=Mtj[X];
float V[M+1][L]qjqt[M][X]LR[M][X];
float fzs[L][S]fvs[L][S]fzx[X][S]fqx[X][S]zcsw[X]clxs[X];
float Nzh[X]zdq[X]gzNp[X]zxq[X]Np;
float xxz1[L]xxz2[L]sz[L]zcz[L]xxv1[L]xxv2[L]sv[L]zcv[L];
float QT[M][X]QX[M][X]H[M][X]R[M][X]QFD[M][X];
//------------------------------------函数的定义--------------------------
void DPSA(void);
float chazhi(float x0float y1[]float y2[]int num);
//----------------插值函数-----------------------------------------------------------
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 ijkzjsjs[X];
float sum[50]rzz;
float QS[M][X]Z[M+1][L];
float pjfdl[X]pjcl[X]bzl[X]zcl[X]zbzl;
//-----------------------------------------------------------------------------------------
//------- 数据的输出输入 ---------------
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 for(j=0;j fin>>qjqt[i][j];
for(i=0;i for(j=0;j fin>>V[i][j];
for(i=0;i for(j=0;j fin>>LR[i][j];
for(i=0;i fin>>zdq[i]>>zxq[i]>>zcsw[i]>>Nzh[i]>>gzNp[i]>>clxs[i];
for(i=0;i fin>>xxz1[i]>>xxz2[i]>>sz[i]>>zcz[i];
for(i=0;i for(j=0;j fin>>fzs[i][j];
for(i=0;i for(j=0;j fin>>fvs[i][j];
for(i=0;i for(j=0;j fin>>fzx[i][j];
for(i=0;i for(j=0;j fin>>fqx[i][j];
for(i=0;i fin>>tj[i];
}//end open infile and intialize tha array x[]
fin.close();
//-------------------主循环------------------------------------------------------------------
Np=0.0;
for(i=0;i for(i=0;i {
sv[i]=chazhi(sz[i]fzs[i]fvs
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11201 2008-11-16 21:09 POA-DPSA.cpp
----------- --------- ---------- ----- ----
11201 1
评论
共有 条评论