Skip to content

Commit 8af857f

Browse files
James CraigJames Craig
authored andcommitted
2 parents c28d146 + c013f5f commit 8af857f

11 files changed

+48
-48
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
# - id: include-what-you-use
2727

2828
- repo: https://github.com/python-jsonschema/check-jsonschema
29-
rev: 0.30.0
29+
rev: 0.32.1
3030
hooks:
3131
- id: check-github-workflows
3232
- repo: meta

src/CustomOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,4 +1213,4 @@ CCustomOutput *CCustomOutput::ParseCustomOutputCommand(char *s[MAXINPUTITEMS], c
12131213
}
12141214

12151215
return pCustom;
1216-
}
1216+
}

src/DemandExpressionHandling.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ int CDemandOptimizer::GetUserDVIndex(const string s) const
227227
//////////////////////////////////////////////////////////////////
228228
/// \brief index of non-linear variable given guess string
229229
/// \params s [in] - string (in format ?Q130, ?Q.RavenRiver, ?UserDV)
230-
/// \returns index of non-linear variable in _aNonLinNames[] array
230+
/// \returns index of non-linear variable in _aNonLinNames[] array
231231
//
232-
int CDemandOptimizer::GetNLIndexFromGuessString(const string& s) const
232+
int CDemandOptimizer::GetNLIndexFromGuessString(const string& s) const
233233
{
234234
for (int i = 0; i < _nNonLinVars; i++) {
235235
if (_pNonLinVars[i]->name==s){return i;}
@@ -1028,13 +1028,13 @@ expressionStruct *CDemandOptimizer::ParseExpression(const char **s,
10281028
return tmp;
10291029
}
10301030
//////////////////////////////////////////////////////////////////
1031-
/// \brief Parses :Condition within management goal or workflow variable definition
1031+
/// \brief Parses :Condition within management goal or workflow variable definition
10321032
/// \param s [in] - array of strings of [size: Len]
10331033
/// \param Len [in] - length of string array
10341034
/// \param lineno [in] - line number of original expression in input file filename, referenced in errors
10351035
/// \param filename [in] - name of input file, referenced in errors
10361036
/// \returns exp_condition: a pointer to an expression condition variable
1037-
///
1037+
///
10381038
/// \todo[funct]: Would it be better to support @date(), @between, @day_of_year() in general expression??
10391039
/// :Condition !Q32[0] < 300 + @ts(myTs,0)
10401040
/// :Condition DATE IS_BETWEEN 1975-01-02 2010-01-02
@@ -1048,13 +1048,13 @@ expressionStruct *CDemandOptimizer::ParseExpression(const char **s,
10481048
/// :Condition DAY_OF_YEAR IS_BETWEEN Apr-1 Aug-1 //\todo [NOT YET SUPPORTED]
10491049
/// :Condition @is_between(DAY_OF_YEAR,300,20) = 1 // \todo [NOT YET SUPPORTED]
10501050
//
1051-
exp_condition* CDemandOptimizer::ParseCondition(const char** s, const int Len, const int lineno, const string filename) const
1051+
exp_condition* CDemandOptimizer::ParseCondition(const char** s, const int Len, const int lineno, const string filename) const
10521052
{
10531053
bool badcond=false;
10541054
exp_condition *pCond = new exp_condition();
10551055
pCond->dv_name=s[1];
10561056
const optStruct *Options=_pModel->GetOptStruct();
1057-
1057+
10581058
bool is_exp=false;
10591059
for (int i = 2; i < Len; i++) {
10601060
if ((s[i][0]=='+') || (s[i][0]=='-') || (s[i][0]=='*') || (s[i][0]=='/') || (s[i][0]=='=') || (s[i][0]=='<') || (s[i][0]=='>')){
@@ -1091,7 +1091,7 @@ exp_condition* CDemandOptimizer::ParseCondition(const char** s, const int Len, c
10911091
char tmp =pCond->dv_name[1];
10921092
string tmp2=pCond->dv_name.substr(2);
10931093
char code=pCond->dv_name[1];
1094-
if ((code=='Q') || (code=='h') || (code=='I')) //subbasin state decision variable
1094+
if ((code=='Q') || (code=='h') || (code=='I')) //subbasin state decision variable
10951095
{
10961096
long long SBID=s_to_ll(tmp2.c_str());
10971097
if (_pModel->GetSubBasinByID(SBID) == NULL) {
@@ -1218,7 +1218,7 @@ bool CDemandOptimizer::CheckOpRegimeConditions(const op_regime *pOperRegime, con
12181218
}
12191219
else {//handle user specified DVs and workflow variables
12201220
int i=GetUserDVIndex(pCond->dv_name);
1221-
if (i != DOESNT_EXIST) //decision variable
1221+
if (i != DOESNT_EXIST) //decision variable
12221222
{
12231223
dv_value =_pDecisionVars[i]->value;
12241224
}
@@ -1399,7 +1399,7 @@ void CDemandOptimizer::AddConstraintToLP(const int ii, const int kk, lp_lib::lpr
13991399
ExitGracefullyIf(retval==0,"AddConstraintToLP::Error updating user-specified constraint/goal",RUNTIME_ERR);
14001400
retval = lp_lib::set_rh(pLinProg,lpgoalrow,RHS);
14011401
}
1402-
1402+
14031403
}
14041404
#endif
14051405

@@ -1535,7 +1535,7 @@ double CDemandOptimizer::EvaluateTerm(expressionTerm **pTerms,const int k, const
15351535
}
15361536
else if (pT->type == TERM_ITER)
15371537
{
1538-
return _pNonLinVars[pT->DV_ind]->guess_val;//treated as if constant
1538+
return _pNonLinVars[pT->DV_ind]->guess_val;//treated as if constant
15391539
}
15401540
else if (pT->type == TERM_WORKFLOW)
15411541
{

src/DemandOptimization.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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
//
235235
void 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

src/DemandOptimization.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ struct decision_var
7878
struct nonlin_var
7979
{
8080
string name; //< name of nonlinear variable !Qxxx or !UserVar
81-
string target; //< decision variable name Qxxx or UserVar
82-
double guess_val; //< current guess of value
83-
int DV_index; //index of linear decision variable (0:_nDecisionVars-1) corresponding to nonlinear variable
81+
string target; //< decision variable name Qxxx or UserVar
82+
double guess_val; //< current guess of value
83+
int DV_index; //index of linear decision variable (0:_nDecisionVars-1) corresponding to nonlinear variable
8484

8585
nonlin_var(string nam, string targ) {
8686
name=nam; target=targ; DV_index=DOESNT_EXIST; guess_val=0.0;
@@ -142,7 +142,7 @@ struct managementGoal
142142
string name; //< goal or constraint name
143143

144144
bool is_goal; //< true if constraint is soft (goal rather than constraint)
145-
bool is_nonlinear; //< current expression has non-linear terms
145+
bool is_nonlinear; //< current expression has non-linear terms
146146
int priority; //< priority (default==1, for goals only)
147147
double penalty_under; //< DEFAULT penalty if under specified value (for goals only)
148148
double penalty_over; //< DEFAULT penalty if over value (for goals only)
@@ -204,9 +204,9 @@ class CDemandOptimizer
204204
int _nWorkflowVars; //< total number of workflow variables considered
205205
workflowVar **_pWorkflowVars; //< array of pointers to workflow variables [size: _nWorkflowVars]
206206

207-
int _nNonLinVars; //> total number of non-linear variables (e.g., ?Q130)
208-
nonlin_var **_pNonLinVars; //> array of pointers to non-linear variable pairs
209-
int _maxIterations; //> maximum iterations in iterative scheme (default:5)
207+
int _nNonLinVars; //> total number of non-linear variables (e.g., ?Q130)
208+
nonlin_var **_pNonLinVars; //> array of pointers to non-linear variable pairs
209+
int _maxIterations; //> maximum iterations in iterative scheme (default:5)
210210
double _iterTolerance; //> iterative solve tolerance (%)
211211
double _relaxCoeff; //> iterative solve relaxation coefficient (default:1.0=no relaxation)
212212

@@ -323,7 +323,7 @@ class CDemandOptimizer
323323
void SetRelaxationCoeff (const double relax);
324324

325325
void AddGoalOrConstraint (const managementGoal *pGoal);
326-
326+
327327
void AddUserDecisionVar (const decision_var *pDV);
328328
void SetUserDecisionVarBounds(const string name, const double &min, const double &max);
329329
void AddUserConstant (const string name, const double &val);

src/IsotopeTransport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CIsotopeModel routines related to isotope transport
77
Raven transports is in terms of mass concentration, mg/L or mg/mm/m2 (as is is for all species)
88
this is assumed to be equivalent to mass concentrations e.g., mg18O/(mgO); units conversions are IMPLICIT
99
and is internally converted to composition for advection corrections used to represent enrichment
10-
Raven reports these concentrations as compositions in the standard output
10+
Raven reports these concentrations as compositions in the standard output
1111
----------------------------------------------------------------*/
1212
#include "RavenInclude.h"
1313
#include "IsotopeTransport.h"

src/ParseInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ bool ParseMainInputFile (CModel *&pModel,
327327
Options.assimilate_flow =false;
328328
Options.assimilate_stage =false;
329329
Options.assim_method =DA_RAVEN_DEFAULT;
330-
Options.assimilation_start =-1.0; //start before simulation
330+
Options.assimilation_start =-1.0; //start before simulation
331331
Options.time_zone =0;
332332
Options.rvl_read_frequency =0.0; //do not read at all
333333
Options.custom_interval =1.0; //daily

src/ParseManagementFile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
185185

186186
else if(!strcmp(s[0],":UserTimeSeries")) { code=70; }
187187

188-
else if(!strcmp(s[0],":NonlinearVariable")) { code=80; }
188+
else if(!strcmp(s[0],":NonlinearVariable")) { code=80; }
189189
else if(!strcmp(s[0],":MaxNLSolverIterations")) { code=81; }
190190
else if(!strcmp(s[0],":NLSolverTolerance")) { code=82; }
191191
else if(!strcmp(s[0],":NLRelaxationCoeff")) { code=83; }
@@ -1316,13 +1316,13 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
13161316
if(Options.noisy) { cout <<"Non-linear solver tolerance"<<endl; }
13171317
pModel->GetManagementOptimizer()->SetSolverTolerance(s_to_d(s[1]));
13181318
break;
1319-
}
1319+
}
13201320
case (83): //---------------------------------------------
13211321
{/*:NLRelaxationCoeff [#]*/
13221322
if(Options.noisy) { cout <<"Non-linear solver relaxation coefficient"<<endl; }
13231323
pModel->GetManagementOptimizer()->SetRelaxationCoeff(s_to_d(s[1]));
13241324
break;
1325-
}
1325+
}
13261326
default://------------------------------------------------
13271327
{
13281328
/*cout << "UNREC LINE: (Len=" << Len << ")";
@@ -1411,4 +1411,4 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
14111411
pp=NULL;
14121412

14131413
return true;
1414-
}
1414+
}

src/Reservoir.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ double CReservoir::ScaleFlow(const double& scale,const bool overriding, const do
11891189

11901190
return va;
11911191
}
1192-
double CReservoir::AdjustFlow(const double& Qadjust, const bool overriding, const double& tstep, const double& t)
1192+
double CReservoir::AdjustFlow(const double& Qadjust, const bool overriding, const double& tstep, const double& t)
11931193
{
11941194
double scale=(_Qout+Qadjust)/_Qout;
11951195
if (_Qout=0){scale=1.0;}
@@ -1202,7 +1202,7 @@ double CReservoir::AdjustFlow(const double& Qadjust, const bool overriding, cons
12021202
//Estimate volume added through scaling
12031203
va+=0.5*(_Qout_last+_Qout)*sf*tstep*SEC_PER_DAY;
12041204

1205-
return va;
1205+
return va;
12061206
}
12071207
/////////////////////////////////////////////////////////////////
12081208
/// \brief update demand magnitudes, called in solver at start of every time step

src/SoilClass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ void CSoilClass::AutoCalculateSoilProps(const soil_struct &Stmp,
164164
warn="The required parameter FIELD_CAPACITY for soil class "+_tag+" was autogenerated with value "+to_string(_Soil.field_capacity);
165165
if (chatty){WriteAdvisory(warn,false);}
166166
}
167-
if (_Soil.field_capacity == 0) {
168-
WriteWarning("Soil Parameter FIELD_CAPACITY should be greater than zero. This can lead to issues with some model configurations", false);
167+
if (_Soil.field_capacity == 0) {
168+
WriteWarning("Soil Parameter FIELD_CAPACITY should be greater than zero. This can lead to issues with some model configurations", false);
169169
}
170170

171171

0 commit comments

Comments
 (0)