Commit b4c090bd authored by Poulet Camille's avatar Poulet Camille
Browse files

Comments and TODO

parent 17afd760
......@@ -168,6 +168,7 @@ computeOgive = function(lengthTrajectories, lengthAtMaturity) {
```
```{r test}
#Do not run
tic()
computeMultipleLengthTrajectories(temperaturePattern, Nind = 1000, growParStich) %>%
......@@ -187,6 +188,7 @@ computeMultipleLengthTrajectories(temperaturePattern %>% filter(age < 10) ,
```
```{r ogive variability}
#Do not run
tic(msg = 'ogive variability')
replicate(10, computeMultipleLengthTrajectories(temperaturePattern %>% filter(age < 10) ,
Nind = 100000, growPar) %>%
......@@ -221,6 +223,7 @@ computeMultipleLengthTrajectories(temperaturePattern , Nind = 10000, growParStic
```
```{r optimisation}
#obsolete (presque) au k ou!
ogiveObs = data.frame(age = seq.int(9), p = c(0, 0, 0.01, 0.09, 0.33, 0.63, 0.92, 1, 1))
lengthTrajectoriesInSpring = computeMultipleLengthTrajectories(temperaturePattern, Nind = 1000, growPar) %>%
......@@ -260,7 +263,7 @@ res_A <- optim(par = c(lengthAtMaturity = 35),
upper = growPar$Linf)
computeOgive(yearlyLengthTrajectories = lengthTrajectoriesInSpring,
computeOgive(lengthTrajectories = lengthTrajectoriesInSpring,
lengthAtMaturity = res_A$par) %>%
inner_join(ogiveObs, by = 'age', suffix = c(".pred", ".obs"))
......@@ -329,15 +332,16 @@ computeMultipleLengthTrajectories(temperaturePattern,
geom_abline(slope =0, intercept = 44)
```
```{r calibration K and lengthAtMaturity by gender with ogive}
```{r calibration K and lengthAtMaturity by gender with ogive, warning = "FALSE"}
#par = res_D$par
objFn_D = function(par, fixedPar, ogivesObs, parGrowRef, temperaturePattern,
Nind = 1000, seasonSelected = 'spring',
RNGseed =1) {
fullPar <- enframe(c(par, fixedPar)) %>% pivot_wider()
fullPar <- enframe(c(par, fixedPar)) %>% pivot_wider() #full set of parameters
#extract parameters by sex
parFemale = fullPar %>% select(tempMinGrow, tempOptGrow, tempMaxGrow,
lengthAtHatching,
Linf = linfVonBert,
......@@ -359,7 +363,7 @@ objFn_D = function(par, fixedPar, ogivesObs, parGrowRef, temperaturePattern,
RNGseed = RNGseed) %>%
filter(season == seasonSelected) %>%
computeOgive(lengthAtMaturity = parFemale$lengthAtMaturity) %>%
# add a penalty when p(max(age)) < 1
# add a penalty when p(max(age)) < 1 - avoid immature individuals at maximuma age
mutate(p = if_else(age == max(age) & p < 1, 10*(p-1)^2, p))
SSEfemale = ogivesObs %>% select(age, p = p_female) %>%
......@@ -387,18 +391,19 @@ objFn_D = function(par, fixedPar, ogivesObs, parGrowRef, temperaturePattern,
unlist(use.names = FALSE)
### SSE for growth curve
#growth curve for female by using temperature pattern with sigma = 0 (mean_curve)
femaleCurve <- computeMultipleLengthTrajectoriesWithRandomSeed(temperaturePattern ,
Nind = 1,
growPar = parFemale %>% mutate(sigmaDeltaLVonBert=0) ,
RNGseed = RNGseed) %>%
filter(season == seasonSelected) %>%
select(age, Lfemale = L)
select(age, Lfemale = L)#rename L by Lfemale
maleCurve <- computeMultipleLengthTrajectoriesWithRandomSeed(temperaturePattern ,
Nind = 1,
growPar = parMale %>% mutate(sigmaDeltaLVonBert=0) ,
RNGseed = RNGseed) %>%
filter(season == seasonSelected) %>%
filter(season == seasonSelected) %>% #1 value for a season
select(age, Lmale = L)
SCE1growth <-
......@@ -407,19 +412,24 @@ objFn_D = function(par, fixedPar, ogivesObs, parGrowRef, temperaturePattern,
mutate(Lref = vonBertalanffyGrowth(age, parGrowRef$L0, parGrowRef$Linf, parGrowRef$K),
L2genders = (Lfemale + Lmale)/2,
SE = ((Lfemale + Lmale)/2 - Lref)^2 ) %>%
#SE = (((Lfemale + Lmale)/2 - Lref)/Lref)^2)#TODO TESTER
summarise(SSE = sum(SE)) %>% unlist(use.names = FALSE)
return((SSEmale + SSEfemale)*10 + SCE1growth)
return((SSEmale + SSEfemale)*10 + SCE1growth)# 10 for weigthed the sumSquare compared to the sum squared for gives so that both sum squared varied in the same interval
}
#TODO: ajuster les bonnes valeurs par rapport aux ogives de la literature
ogivesObs = data.frame(age = seq.int(9), p_female = c(0, 0, 0.01, 0.09, 0.33, 0.63, 0.92, 1, 1),
p_male = c(0, 0, 0.01, 0.15, 0.45, 0.75, 0.92, 1, 1))
#TODO verifier si ce sont bien les parametres de Stich
#TODO verifier si ce sont bien les parametres de Stich ou les valeurs ajustés sur les paramètres de Stich expeté sur le Top ? A retravailler pour voir la manière dont on peu enchainer les processus.
#Quelle source de paramètre choisit-on ?
parGrowRef = growParStich %>% select(L0 = lengthAtHatching, K, Linf)
#TODO: modifer les paramètres fixés et les paramètres à optimiser à mon bon vouloir ahah
par = c(tempOptGrow = 5,
kOptForFemale = 0.32,
kOptForMale = .21,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment