@@ -79,7 +79,7 @@ CDemandOptimizer::CDemandOptimizer(CModel *pMod)
7979
8080 _nNonLinVars=0 ;
8181 _pNonLinVars=NULL ;
82- _maxIterations=5 ;
82+ _maxIterations=5 ;
8383 _iterTolerance=0.01 ;
8484 _relaxCoeff=1.0 ;
8585}
@@ -230,7 +230,7 @@ void CDemandOptimizer::SetMaxIterations (const int Nmax )
230230
231231// ////////////////////////////////////////////////////////////////
232232// / \brief sets nonlinear solver tolerance
233- // / \params tol [in] - tolerance, as ratio dX/X
233+ // / \params tol [in] - tolerance, as ratio dX/X
234234//
235235void CDemandOptimizer::SetSolverTolerance (const double tol )
236236{
@@ -354,7 +354,7 @@ void CDemandOptimizer::AddUserDecisionVar(const decision_var* pDV)
354354// ////////////////////////////////////////////////////////////////
355355// / \brief disables stage discharge curve handling for reservoir in subbasin p
356356//
357- void CDemandOptimizer::OverrideSDCurve (const int p)
357+ void CDemandOptimizer::OverrideSDCurve (const int p)
358358{
359359 _aDisableSDCurve[p]=true ;
360360 }
@@ -401,7 +401,7 @@ void CDemandOptimizer::AddUserConstant(const string name, const double& val)
401401// ////////////////////////////////////////////////////////////////
402402// / \brief adds nonlinearvariable
403403//
404- void CDemandOptimizer::AddNonLinVariable (const string name, const string targetDV)
404+ void CDemandOptimizer::AddNonLinVariable (const string name, const string targetDV)
405405{
406406 if (name[0 ]!=' ?' ){
407407 ExitGracefully (" CDemandOptimizer::AddNonLinVariable: non-linear variable must start with ? character" ,BAD_DATA_WARN);
@@ -472,7 +472,7 @@ bool CDemandOptimizer::VariableNameExists(const string &name) const
472472 for (int i = 0 ; i < _nUserConstants; i++) {
473473 if (_aUserConstNames[i]==name){return true ;}
474474 }
475-
475+
476476 if (GetUnitConversion (name)!=RAV_BLANK_DATA){return true ;}
477477
478478 return false ;
@@ -878,7 +878,7 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
878878 // ------------------------------------------------------------------
879879 for (int i = 0 ; i < _nNonLinVars; i++) {
880880 expressionTerm* term=new expressionTerm ();
881- if (ConvertToExpressionTerm (_pNonLinVars[i]->target , term, 0 , " internal" )) {
881+ if (ConvertToExpressionTerm (_pNonLinVars[i]->target , term, 0 , " internal" )) {
882882 _pNonLinVars[i]->DV_index =term->DV_ind -1 ; // using 0 indexing for dv rateher than lp 1 indexing
883883 // cout<<" NONLINEAR TARGET FOUND : "<<term->DV_ind-1<<" "<<term->origexp<<" "<<expTypeToString(term->type)<<endl;
884884 }
@@ -959,7 +959,7 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
959959 cout<<" " <<i<<" [WORKFLOWVAR]: " <<_pWorkflowVars[i]->name <<endl;
960960 for (int k=0 ; k<_pWorkflowVars[i]->nOperRegimes ; k++)
961961 {
962-
962+
963963 cout<<" +oper regime: " <<_pWorkflowVars[i]->pOperRegimes [k]->reg_name <<endl;
964964 cout<<" +expression: " <<_pWorkflowVars[i]->pOperRegimes [k]->pExpression ->origexp <<endl;
965965 comparison ctype=_pWorkflowVars[i]->pOperRegimes [k]->pExpression ->compare ;
@@ -1368,12 +1368,12 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O
13681368
13691369 int *col_ind=new int [_nDecisionVars]; // index of column to insert value in current row (1:nDV, not zero-indexed)
13701370 double *row_val=new double [_nDecisionVars]; // values of row[col_ind]
1371- double *dDV =new double [_nDecisionVars]; // change in decision variables between iterations
1371+ double *dDV =new double [_nDecisionVars]; // change in decision variables between iterations
13721372 double *h_iter =new double [_pModel->GetNumSubBasins ()]; // value of stage from previous iteration for all reservoirs
1373- double *Q_iter =new double [_pModel->GetNumSubBasins ()]; // value of reservoir outflows from previous iteration for all reservoirs
1373+ double *Q_iter =new double [_pModel->GetNumSubBasins ()]; // value of reservoir outflows from previous iteration for all reservoirs
13741374 int *lprow =new int [_pModel->GetNumSubBasins ()]; // index of goal equation for non-linear reservoir stage discharge curve in subbasin p
13751375 int *lpsbrow=new int [_pModel->GetNumSubBasins ()]; // index of constraint equation for subbasin reaches
1376- int *lpgoalrow=new int [_nGoals]; // index of goal equation for all user-specified goals
1376+ int *lpgoalrow=new int [_nGoals]; // index of goal equation for all user-specified goals
13771377
13781378 // instantiate linear programming solver
13791379 // ----------------------------------------------------------------
@@ -1715,7 +1715,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O
17151715 retval = lp_lib::add_constraintex (pLinProg,i,row_val,col_ind,ROWTYPE_EQ,RHS);
17161716 ExitGracefullyIf (retval==0 ," SolveManagementProblem::Error adding mass balance constraint" ,RUNTIME_ERR);
17171717 IncrementAndSetRowName (pLinProg,rowcount," reach_MB_" +to_string (pSB->GetID ()));
1718-
1718+
17191719 lpsbrow[p]=lp_lib::get_Nrows (pLinProg);
17201720 }
17211721 }
@@ -2022,7 +2022,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O
20222022 int nInfeasibleIters=0 ;
20232023 int iter=0 ;
20242024 double norm;
2025- do
2025+ do
20262026 {
20272027 if (_do_debug_level==2 )// EXTREME OUTPUT!!
20282028 {
@@ -2092,8 +2092,8 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O
20922092 if (fabs (_aSolverResiduals[j])>REAL_SMALL)
20932093 cout<<" -" <<_aSolverRowNames[j] << " " << _aSolverResiduals[j] << endl;
20942094 }
2095-
2096- // lp_lib::print_debugdump(pLinProg, dumpfile.c_str());
2095+
2096+ // lp_lib::print_debugdump(pLinProg, dumpfile.c_str());
20972097 WriteLPSubMatrix (pLinProg," overconstrained_lp_matrix.csv" ,Options);
20982098 ExitGracefully (" SolveManagementProblem: non-optimal solution found. Problem is over-constrained. Remove or adjust management constraints." ,RUNTIME_ERR);
20992099 }
@@ -2120,7 +2120,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O
21202120 double val;
21212121 for (int i=0 ;i<_nDecisionVars;i++)
21222122 {
2123- if ((typ == DV_STAGE) || (typ == DV_QOUT)) {
2123+ if ((typ == DV_STAGE) || (typ == DV_QOUT)) {
21242124 val=_pDecisionVars[i]->value ;
21252125 if (val==0 ){val=1.0 ;}
21262126 norm+=dDV[i]*dDV[i]/val/val; N++;
@@ -2130,7 +2130,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O
21302130 int i=_pNonLinVars[j]->DV_index ;
21312131 val=_pDecisionVars[i]->value ;
21322132 if (val==0 ){val=1.0 ;}
2133- norm+=dDV[i]*dDV[i]/val/val; N++;
2133+ norm+=dDV[i]*dDV[i]/val/val; N++;
21342134 }
21352135 norm=sqrt (norm)/N;
21362136
0 commit comments