Skip to content

Commit 85d154d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bad7352 commit 85d154d

13 files changed

+72
-73
lines changed

src/CommonFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ void quickSort(double arr[], int left, int right)
18311831
}
18321832
//////////////////////////////////////////////////////////////////
18331833
/// \brief adds value v to end of integer array a[] of original size n, expands a[] to size n+1
1834-
//
1834+
//
18351835
void pushIntoIntArray(int*&a, const int &v, int &n)
18361836
{
18371837
int *tmp=new int [n+1];

src/DemandExpressionHandling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ bool CDemandOptimizer::ConvertToExpressionTerm(const string s, expressionTerm* t
296296
return true;
297297

298298
}
299-
}
299+
}
300300
else {
301301
warn="ConvertToExpression:: Unparseable term in history expression starting with !/$ - only !Q, !D, !h, $B, or $E currently supported. "+warnstring;
302302
ExitGracefully(warn.c_str(), BAD_DATA_WARN);
@@ -383,7 +383,7 @@ bool CDemandOptimizer::ConvertToExpressionTerm(const string s, expressionTerm* t
383383
return true;
384384
}
385385
//----------------------------------------------------------------------
386-
else if (s[0] == '$')
386+
else if (s[0] == '$')
387387
{
388388
if ((s[1] == 'B') || (s[1] == 'E')) //Subbasin-indexed
389389
{

src/DemandGroups.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
CDemandGroup::CDemandGroup(string tag, int global_ind)
1313
{
1414
_name=tag;
15-
_nDemands=0;
15+
_nDemands=0;
1616
_pDemands=NULL;
1717
_global_ii=global_ind;
1818
}
@@ -91,4 +91,3 @@ void CDemandGroup::AddDemand(CDemand *pDem)
9191
void CDemandGroup::Initialize()
9292
{
9393
}
94-

src/DemandOptimization.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int CDemandOptimizer::GetDemandIndexFromName(const string demand_tag) const
120120
return DOESNT_EXIST;
121121
}
122122
//////////////////////////////////////////////////////////////////
123-
/// \brief gets demand from index
123+
/// \brief gets demand from index
124124
//
125125
CDemand* CDemandOptimizer::GetWaterDemand(const int d) {
126126
return _pDemands[d];
@@ -132,16 +132,16 @@ int CDemandOptimizer::GetNumWaterDemands() const {
132132
return _nDemands;
133133
}
134134
//////////////////////////////////////////////////////////////////
135-
/// \brief gets demand group from index
135+
/// \brief gets demand group from index
136136
//
137-
CDemandGroup* CDemandOptimizer::GetDemandGroup(const int ii)
137+
CDemandGroup* CDemandOptimizer::GetDemandGroup(const int ii)
138138
{
139139
return _pDemandGroups[ii];
140140
}
141141
//////////////////////////////////////////////////////////////////
142-
/// \brief gets demand group from name, or NULL if invalid name
142+
/// \brief gets demand group from name, or NULL if invalid name
143143
//
144-
CDemandGroup* CDemandOptimizer::GetDemandGroupFromName(const string name)
144+
CDemandGroup* CDemandOptimizer::GetDemandGroupFromName(const string name)
145145
{
146146
for (int ii=0;ii<_nDemandGroups;ii++){
147147
if (_pDemandGroups[ii]->GetName() == name) {
@@ -151,14 +151,14 @@ CDemandGroup* CDemandOptimizer::GetDemandGroupFromName(const string name)
151151
return NULL;
152152
}
153153
//////////////////////////////////////////////////////////////////
154-
/// \brief gets demand group from index
154+
/// \brief gets demand group from index
155155
//
156-
int CDemandOptimizer::GetNumDemandGroups() const
156+
int CDemandOptimizer::GetNumDemandGroups() const
157157
{
158158
return _nDemandGroups;
159159
}
160160
//////////////////////////////////////////////////////////////////
161-
/// \brief returns true if demands have been initialized
161+
/// \brief returns true if demands have been initialized
162162
//
163163
bool CDemandOptimizer::DemandsAreInitialized() const
164164
{
@@ -206,15 +206,15 @@ void CDemandOptimizer::SetDebugLevel(const int val)
206206
/// \brief assigns a demand 'unrestricted' status, meaning it wont be considered when applying environmental min flow constraints
207207
/// \params dname [in] - name of demand
208208
//
209-
void CDemandOptimizer::SetDemandAsUnrestricted(const string dname)
209+
void CDemandOptimizer::SetDemandAsUnrestricted(const string dname)
210210
{
211211
int d = GetDemandIndexFromName(dname);
212212
if (d!=DOESNT_EXIST){
213213
_pDemands[d]->SetAsUnrestricted();
214214
}
215215
else{
216216
string warn = "CDemandOptimizer::SetDemandAsUnrestricted: invalid or disabled demand name " + dname +" provided in : DemandIsUnrestricted command. This will be ignored ";
217-
WriteWarning(warn,true);
217+
WriteWarning(warn,true);
218218
}
219219
}
220220
//////////////////////////////////////////////////////////////////
@@ -229,7 +229,7 @@ void CDemandOptimizer::SetDemandPenalty(const string dname, const double& pen)
229229
}
230230
else {
231231
string warn = "CDemandOptimizer::SetDemandPenalty: invalid or disabled demand name " + dname +" provided in : DemandPenalty command. This will be ignored ";
232-
WriteWarning(warn,true);
232+
WriteWarning(warn,true);
233233
}
234234
}
235235
//////////////////////////////////////////////////////////////////
@@ -253,7 +253,7 @@ void CDemandOptimizer::SetCumulativeDate(const int julian_date, const string dem
253253
/// \brief adds demand group to array of demand groups
254254
/// \params groupname [in] - user-specified demand group name
255255
//
256-
void CDemandOptimizer::AddDemandGroup(const string groupname)
256+
void CDemandOptimizer::AddDemandGroup(const string groupname)
257257
{
258258
CDemandGroup *pDG=new CDemandGroup(groupname,_nDemandGroups);
259259

@@ -265,7 +265,7 @@ void CDemandOptimizer::AddDemandGroup(const string groupname)
265265
/// \brief adds demand ONLY if subbasin associated with demand is enabled, otherwise tosses out.
266266
/// \params pDem [in] - pointer to demand object
267267
//
268-
void CDemandOptimizer::AddWaterDemand(CDemand* pDem)
268+
void CDemandOptimizer::AddWaterDemand(CDemand* pDem)
269269
{
270270
long SBID=pDem->GetSubBasinID();
271271
if (_pModel->GetSubBasinByID(SBID)->IsEnabled())
@@ -548,7 +548,7 @@ void CDemandOptimizer::InitializeDemands(CModel* pModel, const optStruct& Option
548548

549549
if (Options.noisy){cout<<"CDemandOptimizer: Demand initialization..."<<endl;}
550550

551-
// reserve memory for delivery arrays
551+
// reserve memory for delivery arrays
552552
//------------------------------------------------------------------
553553
_aDelivery = new double[_nDemands];
554554
_aCumDelivery = new double[_nDemands];
@@ -560,14 +560,14 @@ void CDemandOptimizer::InitializeDemands(CModel* pModel, const optStruct& Option
560560

561561
// determine upstream demand connectivity
562562
//------------------------------------------------------------------
563-
IdentifyUpstreamDemands();
563+
IdentifyUpstreamDemands();
564564

565565
int p;
566566
decision_var *pDV;
567567

568-
// add delivered demand decision vars
568+
// add delivered demand decision vars
569569
//------------------------------------------------------------------
570-
for (int d = 0; d < _nDemands; d++)
570+
for (int d = 0; d < _nDemands; d++)
571571
{
572572
p=pModel->GetSubBasinByID(_pDemands[d]->GetSubBasinID())->GetGlobalIndex();
573573
pDV=new decision_var(_pDemands[d]->GetName(), p, DV_DELIVERY, d);
@@ -613,7 +613,7 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
613613
_aDhist[pp][i]=0.0;
614614
}
615615
}
616-
616+
617617
int p;
618618
_nSlackVars = 0;
619619
CSubBasin *pSB;
@@ -854,7 +854,7 @@ void CDemandOptimizer::AddReservoirConstraints()
854854

855855
TokenizeString(expString, s, Len);
856856
exp = ParseExpression((const char**)(s), Len, 0, "internal");
857-
857+
858858
pConst=new manConstraint();
859859
pConst->name=TSname;
860860
pConst->is_goal=true;
@@ -1116,7 +1116,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
11161116
for (int d = 0; d < _nDemands; d++) {
11171117
_pDemands[d]->UpdateDemand(Options,tt);
11181118
}
1119-
1119+
11201120
// instantiate linear programming solver
11211121
// ----------------------------------------------------------------
11221122
lp_lib::lprec *pLinProg;
@@ -1217,7 +1217,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
12171217
d=0;
12181218
// penalties for unmet demand
12191219
// ----------------------------------------------------------------
1220-
for (int d = 0; d < _nDemands; d++)
1220+
for (int d = 0; d < _nDemands; d++)
12211221
{
12221222
demand_penalty_sum+=(_pDemands[d]->GetPenalty()*_pDemands[d]->GetDemand());
12231223

@@ -1637,7 +1637,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
16371637
retval = lp_lib::solve(pLinProg);
16381638

16391639
if (retval!=OPTIMAL){
1640-
cout<<"code: "<<retval<<endl;
1640+
cout<<"code: "<<retval<<endl;
16411641
string filename=Options.output_dir+"/lp_bad_matrix.txt";
16421642
lp_lib::set_outputfile(pLinProg,&filename[0]);
16431643
lp_lib::print_lp(pLinProg);
@@ -1796,7 +1796,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
17961796
_aCumDelivery[d]+=value*(Options.timestep*SEC_PER_DAY);
17971797

17981798
if (tt.julian_day==_pDemands[d]->GetCumulDeliveryDate()){
1799-
_aCumDelivery[d]=0.0;
1799+
_aCumDelivery[d]=0.0;
18001800
}
18011801

18021802
if (!_pDemands[d]->IsReservoirDemand()){
@@ -1913,7 +1913,7 @@ void CDemandOptimizer::WriteMinorOutput(const optStruct &Options,const time_stru
19131913
int ii;
19141914
_GOALSAT<<tt.model_time <<","<<usedate<<","<<usehour;
19151915

1916-
for (int d = 0; d < _nDemands; d++)
1916+
for (int d = 0; d < _nDemands; d++)
19171917
{
19181918
if (include_pen){mult=_pDemands[d]->GetPenalty();}
19191919
ii =_pDemands[d]->GetLocalIndex();
@@ -1922,18 +1922,18 @@ void CDemandOptimizer::WriteMinorOutput(const optStruct &Options,const time_stru
19221922
}
19231923

19241924
int k=_nDemands+2*_nReservoirs; //first slack terms are due to environmental flow constraints (nDemands) and reservoir outflow targets (2*nReservoirs)
1925-
for (int i = 0; i < _nConstraints; i++)
1925+
for (int i = 0; i < _nConstraints; i++)
19261926
{
19271927
if (_pConstraints[i]->is_goal) {
1928-
if (_pConstraints[i]->pOperRegimes[0]->pExpression->compare != COMPARE_IS_EQUAL)
1928+
if (_pConstraints[i]->pOperRegimes[0]->pExpression->compare != COMPARE_IS_EQUAL)
19291929
{
19301930
if (include_pen){mult=_pConstraints[i]->penalty_over;}
19311931

19321932
pen = mult*_aSlackValues[k];
19331933
_GOALSAT<<","<<pen;
19341934
k++;
19351935
}
1936-
else
1936+
else
19371937
{
19381938
if (include_pen){mult=_pConstraints[i]->penalty_over;}
19391939
pen =mult*_aSlackValues[k];

src/Demands.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class CDemand
1515
{
1616
private:/*------------------------------------------------------*/
1717
int _ID; ///< unique integer identifier
18-
string _name; ///< unique name/alias identifier
18+
string _name; ///< unique name/alias identifier
1919

20-
long _SBID; ///< subbasin ID
21-
int _loc_index; ///< local demand index (counter in each subbasin)
22-
bool _is_reservoir; ///< true if withdrawal is from reservoir
20+
long _SBID; ///< subbasin ID
21+
int _loc_index; ///< local demand index (counter in each subbasin)
22+
bool _is_reservoir; ///< true if withdrawal is from reservoir
2323

2424
double _penalty; ///< penalty for not satisfying demand [s/m3]
2525

@@ -31,7 +31,7 @@ class CDemand
3131
//int _irrigHRUGroup; ///< index kk of HRU group on which withdrawn water is applied
3232
//double _returnPct; ///< percentage of flow which returns to stream
3333

34-
double _multiplier; ///< multiplies time series or any other means of calculating demand
34+
double _multiplier; ///< multiplies time series or any other means of calculating demand
3535

3636
CTimeSeries *_pDemandTS; ///< pointer to time series of demands (or NULL, if calculated elsewise)
3737

src/Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@
1111
# Mar 2017 Juliane Mai - increase stack size to 256 MB from standard 64MB
1212
# Jan 2019 Alan J. Barton - added OS name to created exe name
1313
# Dec 2023 David Huard - support for python binding
14-
# Jul 2024 James Craig and Bohao Tang - support for lp_solve
14+
# Jul 2024 James Craig and Bohao Tang - support for lp_solve
1515
###
1616
# appname := raven_rev$(shell svnversion -n . | sed -e 's/:/-/g')_$(shell uname -o).exe
1717
appname := Raven.exe
1818

1919
CXX := g++
2020
CXXFLAGS := -Wno-deprecated
21-
LDLIBS :=
21+
LDLIBS :=
2222
LDFLAGS :=
2323

2424
# OPTION 0) some compilers require the c++11 flag, some may not
2525
CXXFLAGS += -std=c++11 -fPIC
2626

27-
# OPTION 1) include netcdf - uncomment following two commands (assumes netCDF path = /usr/local):
28-
#CXXFLAGS += -Dnetcdf
29-
#LDLIBS += -L/usr/local -lnetcdf
27+
# OPTION 1) include netcdf - uncomment following two commands (assumes netCDF path = /usr/local):
28+
#CXXFLAGS += -Dnetcdf
29+
#LDLIBS += -L/usr/local -lnetcdf
3030

3131
# OPTION 2) include lp_solve - uncomment following two commands (assumes liblpsolve55.a in ../lib/lp_solve_unix/ folder):
32-
CXXFLAGS += -D_LPSOLVE_
32+
CXXFLAGS += -D_LPSOLVE_
3333
LDLIBS += -L../lib/lp_solve_unix -llpsolve55
3434

3535
# OPTION 3) if you use a OSX/BSD system, uncomment the LDFLAGS line below
3636
# this is to allow for use a 1Gb stack, see http://linuxtoosx.blogspot.ca/2010/10/stack-overflow-increasing-stack-limit.html
3737
# LDFLAGS += -Wl,-stack_size,0x80000000,-stack_addr,0xf0000000
3838

3939
# OPTION 4) uncomment for M1 and newer MacOS
40-
#CXXFLAGS := -Dfinite=isfinite
40+
#CXXFLAGS := -Dfinite=isfinite
4141

4242
srcfiles := $(shell ls *.cpp)
4343
objects := $(patsubst %.cpp, %.o, $(srcfiles))

src/ParseLib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ bool CParser::Tokenize(char **out, int &numwords){
138138

139139
if (_parsing_math_exp) {
140140
string line;
141-
line=AddSpacesBeforeOps(wholeline);
141+
line=AddSpacesBeforeOps(wholeline);
142142
strcpy(wholeline,line.c_str());
143143
_parsing_math_exp=false;
144144
}

src/ParseManagementFile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
566566
}
567567
}
568568
//----------------------------------------------
569-
else if (!strcmp(s[0], ":Penalty"))
569+
else if (!strcmp(s[0], ":Penalty"))
570570
{
571571
if (Options.noisy){cout<<" Penalty "<<endl; }
572572
if (!pConst->is_goal) {
@@ -579,7 +579,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
579579
}
580580
}
581581
//----------------------------------------------
582-
else if (!strcmp(s[0], ":Priority"))
582+
else if (!strcmp(s[0], ":Priority"))
583583
{
584584
if (Options.noisy){cout<<" Priority "<<endl; }
585585
pConst->priority = s_to_i(s[1]); //for later
@@ -609,7 +609,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
609609
if (!badgoal) {
610610
pDO->AddGoalOrConstraint(pConst);
611611
}
612-
612+
613613
break;
614614
}
615615
case(24): //----------------------------------------------
@@ -895,4 +895,4 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
895895
pp=NULL;
896896

897897
return true;
898-
}
898+
}

src/ParseTimeSeriesFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ bool ParseTimeSeriesFile(CModel *&pModel, const optStruct &Options)
627627

628628
pTimeSer->SetIDTag(demand_ID);
629629
pSB->GetReservoir()->AddDemandTimeSeries(pTimeSer);
630-
630+
631631
if (Options.management_optimization){
632632
CDemand *pDem=new CDemand(demand_ID,demand_name,SBID,true,pTimeSer);
633633
pDem->SetLocalIndex(ii);

src/Raven.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,4 +1039,4 @@
10391039
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
10401040
<ImportGroup Label="ExtensionTargets">
10411041
</ImportGroup>
1042-
</Project>
1042+
</Project>

0 commit comments

Comments
 (0)