@@ -107,7 +107,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
107107
108108 // --Sift through file-----------------------------------------------
109109 firstword=pp->Peek ();
110- if ((firstword == " :DefineDecisionVariable" ) || (firstword == " :DemandExpression" ) || (firstword == " :ReturnExpression" ))
110+ if ((firstword == " :DefineDecisionVariable" ) || (firstword == " :DemandExpression" ) || (firstword == " :ReturnExpression" ) || (firstword == " :DefineControlVariable " ) )
111111 {
112112 pp->NextIsMathExp ();
113113 }
@@ -175,6 +175,9 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
175175 else if (!strcmp (s[0 ]," :DemandLookupTable" )) { code=61 ; }
176176 else if (!strcmp (s[0 ]," :DemandExpression" )) { code=62 ; }
177177 // else if(!strcmp(s[0],":AnnualLicense")) { code=63; }
178+ else if (!strcmp (s[0 ]," :ReservoirWaterDemand" )) { code=64 ; }
179+ else if (!strcmp (s[0 ]," :EndReservoirWaterDemand" )) { code=65 ; }
180+ else if (!strcmp (s[0 ]," :IsUnrestricted" )) { code=66 ; }
178181
179182 else if (!strcmp (s[0 ]," :UserTimeSeries" )) { code=70 ; }
180183
@@ -519,14 +522,15 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
519522 // TODO: Would it be better to support @date(), @between, @day_of_year() in general expression??
520523 // :Condition !Q32[0] < 300 + @ts(myTs,0)
521524 // :Condition DATE IS_BETWEEN 1975-01-02 and 2010-01-02
522- // :Condition DATE > @date(1975-01-02) //[NOT YET SUPPORTED]
523- // :Condition DATE < @date(2010-01-02) //[NOT YET SUPPORTED]
525+ // :Condition DATE > @date(1975-01-02) //\todo [NOT YET SUPPORTED]
526+ // :Condition DATE < @date(2010-01-02) //\todo [NOT YET SUPPORTED]
524527 // :Condition MONTH = 2
525528 // :Condition DAY_OF_YEAR IS_BETWEEN 173 and 210
526529 // :Condition DAY_OF_YEAR > 174
527530 // :Condition DAY_OF_YEAR < 210
528531 // :Condition DAY_OF_YEAR IS_BETWEEN 300 20 //wraps around
529- // :Condition @is_between(DAY_OF_YEAR,300,20) = 1 //[NOT YET SUPPORTED]
532+ // :Condition DAY_OF_YEAR IS_BETWEEN Apr-1 Aug-1 //\todo [NOT YET SUPPORTED]
533+ // :Condition @is_between(DAY_OF_YEAR,300,20) = 1 // \todo [NOT YET SUPPORTED]
530534 if (pGoal!=NULL ){
531535 bool badcond=false ;
532536 exp_condition *pCond = new exp_condition ();
@@ -976,7 +980,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
976980 break ;
977981 }
978982 case (54 ): // --------------------------------------------
979- {/* :ReturnDestination [SBID]*/
983+ {/* :ReturnDestination [SBID] */
980984 if (Options.noisy ) { cout <<" Return destination ID" <<endl; }
981985 if (pDemand==NULL ){
982986 ExitGracefully (" :ReturnTimeSeries must be between :WaterDemand and :EndWaterDemand commands." ,BAD_DATA_WARN);
@@ -1072,6 +1076,16 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
10721076 }
10731077 break ;
10741078 }
1079+ case (61 ): // --------------------------------------------
1080+ {/* :DemandLookupTable
1081+ N
1082+ {Q_i D_i} x N
1083+ :EndDemandLookupTable
1084+ */
1085+ if (Options.noisy ) { cout <<" Demand flow fraction" <<endl; }
1086+ ExitGracefully (" :DemandLookupTable." ,STUB);
1087+ break ;
1088+ }
10751089 case (62 ): // --------------------------------------------
10761090 {/* :DemandExpression [expression]*/
10771091 if (Options.noisy ) { cout <<" Demand expression" <<endl; }
@@ -1098,6 +1112,59 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
10981112 }
10991113 break ;
11001114 }
1115+ case (63 ): // --------------------------------------------
1116+ { /*
1117+ :ReservoirWaterDemand [SBID] [ID] [Name]
1118+ ...
1119+ :EndReservoirWaterDemand
1120+ */
1121+ if (Options.noisy ) { cout <<" Reservoir Water demand object" <<endl; }
1122+ if (Len<4 ){
1123+ ExitGracefully (" Incorrect number of terms in :ReservoirWaterDemand command header." ,BAD_DATA_WARN);
1124+ }
1125+ else {
1126+ demandSBID =s_to_l (s[1 ]);
1127+ demand_ID =s_to_i (s[2 ]);
1128+ demand_name=s[3 ];
1129+ CSubBasin *pSB=pModel->GetSubBasinByID (demandSBID);
1130+ if (pSB!=NULL ) {
1131+ if (pSB->GetReservoir () != NULL ) {
1132+ demand_ind=pSB->GetReservoir ()->GetNumWaterDemands ();
1133+ pDemand=new CDemand (demand_ID,demand_name,demandSBID,true );
1134+ pDemand->SetLocalIndex (demand_ind);
1135+ pSB->GetReservoir ()->AddDemand (pDemand);
1136+ pModel->GetDemandOptimizer ()->AddWaterDemand (pDemand);
1137+ }
1138+ else
1139+ {
1140+ ExitGracefully (" There is no reservoir in the subbasin specified within the :ReservoirWaterDemand command header." ,BAD_DATA_WARN);
1141+ break ;
1142+ }
1143+ }
1144+ else {
1145+ ExitGracefully (" Invalid subbasin ID in :ReservoirWaterDemand command header." ,BAD_DATA_WARN);
1146+ break ;
1147+ }
1148+ }
1149+ break ;
1150+ }
1151+ case (64 ): // --------------------------------------------
1152+ {/* :EndReservoirWaterDemand*/
1153+ if (Options.noisy ) { cout <<" ..end reservoir water demand object" <<endl; }
1154+ pDemand=NULL ;
1155+ break ;
1156+ }
1157+ case (65 ): // --------------------------------------------
1158+ {/* :IsUnrestricted*/
1159+ if (Options.noisy ) { cout <<" Set demand as Unrestricted" <<endl; }
1160+ if (pDemand == NULL ) {
1161+ ExitGracefully (" :IsUnrestricted command must be between :WaterDemand and :EndWaterDemand commands." ,BAD_DATA_WARN);
1162+ }
1163+ else {
1164+ pDO->SetDemandAsUnrestricted (pDemand->GetName ());
1165+ }
1166+ break ;
1167+ }
11011168 case (70 ): // ---------------------------------------------
11021169 {/* :UserTimeSeries {name} [units]
11031170 {yyyy-mm-dd} {hh:mm:ss.0} {double timestep} {int nMeasurements}
@@ -1106,7 +1173,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
11061173 */
11071174 CTimeSeries *pTimeSer;
11081175 if (Options.noisy ) { cout <<" User-specified Time Series" <<endl; }
1109- pTimeSer=CTimeSeries::Parse (pp,false ,s[1 ], DOESNT_EXIST, " none" , Options);
1176+ pTimeSer=CTimeSeries::Parse (pp,true ,s[1 ], DOESNT_EXIST, " none" , Options);
11101177 pModel->GetDemandOptimizer ()->AddUserTimeSeries (pTimeSer);
11111178 break ;
11121179 }
@@ -1146,7 +1213,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
11461213 }// end switch(code)
11471214
11481215 firstword=pp->Peek ();
1149- if ((firstword == " :DefineDecisionVariable" ) || (firstword == " :DemandExpression" ) || (firstword == " :ReturnExpression" ))
1216+ if ((firstword == " :DefineDecisionVariable" ) || (firstword == " :DemandExpression" ) || (firstword == " :ReturnExpression" ) || (firstword == " :DefineControlVariable " ) )
11501217 {
11511218 pp->NextIsMathExp ();
11521219 }
0 commit comments