if (FALSE) {
testOM@cpars$Data = new('Data')
testOM@cpars$Data@MPrec=2000
Hist_1 = runMSE(testOM,Hist=T)
testOM2 = testOM
testOM2@D = testOM@D / 2
Hist_2 = runMSE(testOM2,Hist=T)
myMP = function(x, Data, reps=1, rate = 1){
CpI = mean(Data@Cat[x,46:50]) / mean(Data@Ind[x,46:50],na.rm=T)
I = Data@Ind[x,]
recI = mean(I[length(I)-((5-1):0)])
Rec=new('Rec')
Rec@TAC = recI * CpI * rate
Rec
}
class(myMP) = "MP"
C1000 = function(MSE_list){
mucat = mean(sapply(MSE_list,function(X){mean(X@Catch)}))
cat(paste0("mean catch = ",round(mucat,3),"\n"))
(mucat - 1000)^2 # try to match 1,250t mean yield
}
myMP_t = tune_MP(list(Hist_1,Hist_2), MP = "myMP", MP_parname = "rate",
interval = c(1,1.5), minfunc = C1000, tol=1E-3, parallel =F)
formals(myMP_t)$rate
}
Run the code above in your browser using DataLab