@@ -68,6 +68,7 @@ CDemandOptimizer::CDemandOptimizer(CModel *pMod)
6868 _aDhist=NULL ;
6969 _aIhist=NULL ;
7070 _ahhist=NULL ;
71+ _aAhist=NULL ;
7172
7273 _nGoals=0 ;
7374 _pGoals=NULL ;
@@ -113,10 +114,12 @@ CDemandOptimizer::~CDemandOptimizer()
113114 delete [] _aDhist[p];
114115 delete [] _aIhist[p];
115116 delete [] _ahhist[p];
117+ delete [] _aAhist[p];
116118 }
117119 }
118120 delete [] _aQhist;
119121 delete [] _ahhist;
122+ delete [] _aAhist;
120123 delete [] _aDhist;
121124 delete [] _aIhist;
122125 delete [] _aUserConstants;
@@ -768,19 +771,22 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
768771 _ahhist = new double *[_nEnabledSubBasins];
769772 _aDhist = new double *[_nEnabledSubBasins];
770773 _aIhist = new double *[_nEnabledSubBasins];
771- ExitGracefullyIf (_aDhist==NULL ," CDemandOptimizer::InitializePostRVMRead" ,OUT_OF_MEMORY);
774+ _aAhist = new double *[_nEnabledSubBasins];
775+ ExitGracefullyIf (_aAhist==NULL ," CDemandOptimizer::InitializePostRVMRead" ,OUT_OF_MEMORY);
772776 for (int pp=0 ;pp<_nEnabledSubBasins;pp++){
773777 _aDhist[pp]=NULL ;
774778 _aQhist[pp] = new double [_nHistoryItems];
775779 _ahhist[pp] = new double [_nHistoryItems];
776780 _aDhist[pp] = new double [_nHistoryItems];
777781 _aIhist[pp] = new double [_nHistoryItems];
778- ExitGracefullyIf (_aDhist[pp]==NULL ," CDemandOptimizer::InitializePostRVMRead (2)" ,OUT_OF_MEMORY);
782+ _aAhist[pp] = new double [_nHistoryItems];
783+ ExitGracefullyIf (_aAhist[pp]==NULL ," CDemandOptimizer::InitializePostRVMRead (2)" ,OUT_OF_MEMORY);
779784 for (int i = 0 ; i < _nHistoryItems; i++) {
780785 _aQhist[pp][i]=0.0 ;
781786 _ahhist[pp][i]=0.0 ;
782787 _aDhist[pp][i]=0.0 ;
783788 _aIhist[pp][i]=0.0 ;
789+ _aAhist[pp][i]=0.0 ;
784790 }
785791 }
786792
@@ -1290,17 +1296,20 @@ void CDemandOptimizer::UpdateHistoryArrays()
12901296 _aDhist[pp][i]=_aDhist[pp][i-1 ];
12911297 _aIhist[pp][i]=_aIhist[pp][i-1 ];
12921298 _ahhist[pp][i]=_ahhist[pp][i-1 ];
1299+ _aAhist[pp][i]=_aAhist[pp][i-1 ];
12931300 }
12941301 _aQhist[pp][0 ]=pSB->GetOutflowRate ();
12951302 _aDhist[pp][0 ]=0.0 ;
12961303 _aIhist[pp][0 ]=0.0 ;
12971304 _ahhist[pp][0 ]=0.0 ;
1305+ _aAhist[pp][0 ]=0.0 ;
12981306 for (int ii=0 ;ii<pSB->GetNumWaterDemands ();ii++){
12991307 _aDhist[pp][0 ]+=pSB->GetDemandDelivery (ii);
13001308 }
13011309 if (pSB->GetReservoir ()!=NULL ){
13021310 _aIhist[pp][0 ]=pSB->GetChannelOutflowRate ();
13031311 _ahhist[pp][0 ]=pSB->GetReservoir ()->GetResStage ();
1312+ _aAhist[pp][0 ]=pSB->GetReservoir ()->GetSurfaceArea ();
13041313 }
13051314 }
13061315 }
0 commit comments