@@ -742,7 +742,7 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
742742 // Convert reservoir commands to user-specified constraints
743743 // allowed here because it doesnt introduce new DVs
744744 // ------------------------------------------------------------------
745- AddReservoirConstraints ();
745+ AddReservoirConstraints (Options );
746746
747747 // Calculate penalty units correction for reservoirs
748748 // ------------------------------------------------------------------
@@ -858,8 +858,9 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
858858 }
859859
860860 string tmpstr,tmpstr2;
861- cout<<" # History Items : " <<_nHistoryItems<<endl;
861+ cout<<" # Lookback intervals : " <<_nHistoryItems<<endl;
862862 cout<<" # Slack Vars: " <<_nSlackVars<<endl;
863+ cout<<" # Named constants : " <<_nUserConstants<<endl;
863864 cout<<" # Constraints/Goals: " <<_nGoals<<endl;
864865 for (int i = 0 ; i < _nGoals; i++) {
865866 if (_pGoals[i]->is_goal ){tmpstr=" [GOAL] " ; }
@@ -935,7 +936,7 @@ void TokenizeString(string instring, char **s, int &Len)
935936// these are done as if the corresponding constraints were read in as expressions from the .rvm file
936937// initialization step: called from InitializePostRVMFileRead()
937938//
938- void CDemandOptimizer::AddReservoirConstraints ()
939+ void CDemandOptimizer::AddReservoirConstraints (const optStruct &Options )
939940{
940941 int p;
941942 CSubBasin *pSB;
@@ -960,7 +961,7 @@ void CDemandOptimizer::AddReservoirConstraints()
960961 int k=pSB->GetReservoir ()->GetHRUIndex ();
961962 if (k==DOESNT_EXIST){
962963 advice=" AddReservoirConstraints: The reservoir in subbasin " +SBIDs+" doesnt have an :HRUID - this will negatively impact the units scaling of management optimization penalties." ;
963- ExitGracefully (advice.c_str (), BAD_DATA_WARN );
964+ WriteAdvisory (advice.c_str (), Options. noisy );
964965 }
965966
966967 // Max Stage constraints
@@ -1301,6 +1302,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
13011302 double *h_iter =new double [_pModel->GetNumSubBasins ()];
13021303 double *Q_iter =new double [_pModel->GetNumSubBasins ()];
13031304 int *lprow =new int [_pModel->GetNumSubBasins ()]; // index of goal equation for non-linear reservoir stage discharge curve in subbasin p
1305+ int *lpsbrow=new int [_pModel->GetNumSubBasins ()]; // index of constraint equation for subbasin reaches
13041306
13051307 // instantiate linear programming solver
13061308 // ----------------------------------------------------------------
@@ -1642,6 +1644,8 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
16421644 retval = lp_lib::add_constraintex (pLinProg,i,row_val,col_ind,ROWTYPE_EQ,RHS);
16431645 ExitGracefullyIf (retval==0 ," SolveDemandProblem::Error adding mass balance constraint" ,RUNTIME_ERR);
16441646 IncrementAndSetRowName (pLinProg,rowcount," reach_MB_" +to_string (pSB->GetID ()));
1647+
1648+ lpsbrow[p]=lp_lib::get_Nrows (pLinProg);
16451649 }
16461650 }
16471651
@@ -2051,12 +2055,12 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
20512055 sum_diverted+=div_Q;
20522056 }
20532057
2054- RHS=lp_lib::get_rh (pLinProg,lprow [p]);// TMP DEBUG - NOT SAME LPROW AS RESERVOIRS !!!
2058+ RHS=lp_lib::get_rh (pLinProg,lpsbrow [p]);
20552059
20562060 RHS+=(sum_diverted-aDivGuess[p]);
20572061 aDivGuess[p]=sum_diverted;
20582062
2059- lp_lib::set_rh (pLinProg,lprow [p],RHS);
2063+ lp_lib::set_rh (pLinProg,lpsbrow [p],RHS);
20602064 }
20612065 }
20622066 }/* end iteration loop*/
@@ -2076,6 +2080,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
20762080 delete [] h_iter;
20772081 delete [] Q_iter;
20782082 delete [] lprow;
2083+ delete [] lpsbrow;
20792084 delete [] aDivert;
20802085 delete [] aDivGuess;
20812086
0 commit comments