RHMS (version 1.7)

tune: tunning an RHMS model

Description

a function for tunning an RHMS model based on a set of observed time series, using particle swarm optimization

Usage

tune(object,targetObject,decisionObjects,
     observationTS,delay=0,
     transformBandWith=list(ct=c(1  , 2.5),
                            cp=c(0.1, 0.3),
                            cn=c(25 , 85 ),
                            k =c(0.1, 2 )),
     routingBandWith=list(manning = c(0.0001, 0.1),
                          x       = c(0.2   , 0.6), 
                          k       = c(1     , 5 )),
     maxiter=NA,update=FALSE,plot=FALSE)

Arguments

object

an object from class of createBasin

targetObject

an object from either of classes: createDiversion, createReservoir, createSubbasin, createJunction, createReach associated to the observationTS

decisionObjects

A list of objects, also, already existing in the object which their parameters needed to be optimized. They objects must be from either of classes: createSubbasin, createReach

observationTS

a vector: an observed flow time series (cms)

delay

(optional) an integer presenting the number of time steps to delay observationTS time series

transformBandWith

an list: a list of vector(s), including upper and lower limit of parameters of tansformation methods. Each parameter search domain is set as a two-value vector, whose first element indicates lower limit and second elemnt is upper limit.

  • Ct=[1, 2.5] and Cp=[0.1, 0.3] are parameters for "Snyder" Unit Hydrograph (SUH)

  • cn=[25, 85] curve number for "SCS" loss method

  • k for "horton" loss method

routingBandWith

an list: a list of vector(s), including upper and lower limit of parameters of routing methods. Each parameter search domain is set as a two-value vector, whose first element indicates lower limit and second elemnt is upper limit.

  • manning=[0.0001, 0.1] is a parameter used "muskingumcunge" method

  • x = [0.2, 0.6] and k=[1, 5] belong to "muskingum" channel routing method

maxiter

(optional) an integer: maximum number of iterations. default to the square of dimension of decision variables

plot

(optional) logical: plots the optimization results

update

(optional) logical: If FALSE, the optimized parameter(s) are returned,If TRUE, the calibrated object from class of createBasin is returned

Value

a vector of tunned parameters or an object from class of createBasin

References

Kennedy, J. (1997). "The particle swarm: social adaptation of knowledge". Proceedings of IEEE International Conference on Evolutionary Computation. pp. 303-308

Examples

Run this code
# NOT RUN {
J1<-createJunction (name="J1")
R1<-createReach(name="R1",routingMethod="muskingum",
                routingParams=list(k=3,x=0.2),
                downstream=J1)
R2<-createReach(name="R2",routingMethod="muskingumcunge",
                routingParams=list(bedWith=50,
                                   sideSlope=2,
                                   channelSlope=0.0005,
                                   manningRoughness=0.025,
                                   riverLength=100),
                downstream=J1)
S1<-createSubbasin(name = "S1", 
                   precipitation=sin(seq(0,pi,length.out=20))*40,
                   Area=100,downstream=R1,
                   transformMethod="SCS",lossMethod="SCS",
                   transformParams=list(Tlag=4),lossParams=list(CN=60))
S2<-createSubbasin(name = "S2", 
                   precipitation=sin(seq(0,pi,length.out=20))*30,
                   Area=300,downstream=R2,
                   transformMethod="snyder",lossMethod="horton",
                   transformParams=list(Cp=0.17,Ct=2,L=30,Lc=15),
                   lossParams=list(f0=10,f1=4,k=1))

basin1<-createBasin(name = "Ghezil_Ozan",
                    simulation=list(start='2000-01-01',
                                    end  ='2000-01-05',
                                    by   =3600))
basin1<-addObjectToBasin(S1, basin1)
basin1<-addObjectToBasin(S2, basin1)
basin1<-addObjectToBasin(R1, basin1)
basin1<-addObjectToBasin(R2, basin1)
basin1<-addObjectToBasin(J1, basin1)

# }
# NOT RUN {
plot(basin1)
# }
# NOT RUN {
simulated<-sim(basin1)
plot(simulated)
observationTS1<-simulated$operation$junctions[[1]]$outflo[,1]
set.seed(1)
observationTS1<-observationTS1+rnorm(length(observationTS1),0,25)
y<-observationTS1; x<-1:length(observationTS1)
observationTS1<-predict(loess(y~x),x)
observationTS1[which(observationTS1<0)]<-0
observationTS<-observationTS1
plot(simulated$operation$junctions[[1]]$outflow[,1],typ='o',ylab='flow rate (cms)',xlab='time step')
lines(observationTS,col=2)

transformBandWith=list(ct=c(1  ,2.5),
                       cp=c(0.1,0.3),
                       cn=c(25 ,85) ,
                       k =c(0.1,2))
routingBandWith=list(maning = c(0.0001,0.1), 
                     x      = c(0.2   ,0.6),
                     k      = c(1     ,5))
targetObject<-J1
decisionObjects<-list(R1,R2,S1,S2)
# }
# NOT RUN {
tune(object=basin1, 
     targetObject=targetObject,
     decisionObjects=decisionObjects,
     observationTS=observationTS,
     routingBandWith=routingBandWith,
     transformBandWith=transformBandWith,
     plot=TRUE)
# }

Run the code above in your browser using DataLab