diff --git a/inst/ShinyApp/server.R b/inst/ShinyApp/server.R
index a5347a422ac4f25d5a2b5f51fe16f9dfaf41accb..70c0f12612a5ac18ef4fdbfa3554016aa91f2496 100644
--- a/inst/ShinyApp/server.R
+++ b/inst/ShinyApp/server.R
@@ -868,7 +868,7 @@ server <- function(input, output, session){
     )
   }
 
-  # Display the table       (Note the delay : piece is just there to avoid an error message - time for parameters to be "loaded in")
+  # Display the table       (Note : the "delay" piece is just there to avoid an error message - time for parameters to be "loaded in")
   delay(ms = 200,
         output$pop_size_by_age <- renderTable({
           if(any(is.na(param$survivals)) | any(is.na(param$fecundities))){
@@ -876,7 +876,7 @@ server <- function(input, output, session){
                    nrow = 1, dimnames = list(NULL, "Erreur"))
           }else{
             make_mat_popsizes(data_sf = data_sf, species = input$species_choice, pop_size = param$pop_size_mean,
-                              pop_size_unit = input$pop_size_unit, s = param$survivals, f = param$fecundities)
+                              pop_size_unit = input$pop_size_unit, s = param$s_calibrated, f = param$f_calibrated)
           } # end if
         },
         width = "500px",
@@ -993,22 +993,33 @@ server <- function(input, output, session){
                                          dimnames = list(ages, c("Survie", "F�condit�"))))
       } # end if 2
     } # end if 1
+  }) # end observeEvent species_choice
 
-  }) # end observeEvent species_list
 
+  # Display vital rates output table
+  delay(ms = 300,
+        output$vital_rates_info <- renderTable({
+
+          #input$mat_fill_vr
+
+          tab_species <- make_mat_vr(data_sf = data_sf, species = input$species_choice)
+          ages <- tab_species$classes_age
+          matrix(data = c(param$s_calibrated, param$f_calibrated),
+                  nrow = length(param$s_calibrated),
+                  ncol = 2,
+                  dimnames = list(ages, c("Survie", "F�condit�"))
+                 )
+        }, rownames = TRUE)
+  )
 
 
 
-  # Display vital rates output table
-  output$vital_rates_info <- renderTable({
-    input$mat_fill_vr
-  }, rownames = TRUE)
 
   # Display intrinsic lambda (based solely on Leslie matrix)
   delay(ms = 300,
         output$lambda0_info <- renderText({
           req(all(!is.na(input$mat_fill_vr)))
-          lam <- lambda(build_Leslie(s = input$mat_fill_vr[,1], f = input$mat_fill_vr[,2]))
+          lam <- lambda(build_Leslie(s = param$s_calibrated, f = param$f_calibrated))
           taux <- round(lam-1,2)*100
           if(taux < 0) Text <- "D�clin : " else Text <- "Croissance : "
           if(taux == 0) Text <- "Population stable : "
@@ -1150,7 +1161,7 @@ server <- function(input, output, session){
     input$run
   },{
     if(input$fatalities_unit == "h"){
-      pop_size_tot <- sum(pop_vector(pop_size = param$pop_size_mean, pop_size_type = param$pop_size_type, s = param$survivals, f = param$fecundities)[-1])
+      pop_size_tot <- sum(pop_vector(pop_size = param$pop_size_mean, pop_size_type = param$pop_size_type, s = param$s_calibrated, f = param$f_calibrated)[-1])
       param$fatalities_mean_nb <- (param$fatalities_mean/100) * pop_size_tot
       param$fatalities_se_nb <- se_prod2(mu1 = param$fatalities_mean/100,
                                          se1 = param$fatalities_se/100,
@@ -1308,6 +1319,11 @@ server <- function(input, output, session){
   observe({
     param$survivals <- input$mat_fill_vr[,1]
     param$fecundities <- input$mat_fill_vr[,2]
+
+    # for now, until calibration is really done
+    param$s_calibrated <- param$survivals
+    param$f_calibrated <- param$fecundities
+
   }) # end observeEvent
   #####
 
@@ -1316,6 +1332,7 @@ server <- function(input, output, session){
   ##-------------------------------------------
   observeEvent({
     input$run
+    input$button_calibrate_vr
   },{
 
     # We also define rMAX and theta here
@@ -1549,7 +1566,7 @@ server <- function(input, output, session){
       if(out$analysis_choice == "cumulated") Legend <- c("Sans parc", "+ Parc 1", paste("... + Parc", (3:n_scen)-1))
       if(out$analysis_choice == "multi_scenario") Legend <- paste("Scenario", (1:n_scen)-1)
 
-      plot_traj(N = out$run$N, onset_year = param$onset_year,
+      plot_traj(N = out$run$N, age_class_use = "all", fecundities = param$f_calibrated, onset_year = param$onset_year,
                 xlab = "\nAnn�e", ylab = "Taille de population\n", Legend = Legend, ylim = c(0, NA))}
   }
 
diff --git a/inst/ShinyApp/ui.R b/inst/ShinyApp/ui.R
index 20e4d9ec0b7673217bb2150388a7abf629404135..384cff693cffd672fe4ac3e21da8fe6739b4b2b8 100644
--- a/inst/ShinyApp/ui.R
+++ b/inst/ShinyApp/ui.R
@@ -430,12 +430,12 @@ rm(list = ls(all.names = TRUE))
                                          # Interval
                                          numericInput(inputId = "pop_size_lower",
                                                       label = "Borne inf�rieure (taille population)",
-                                                      value = 150,
+                                                      value = 350,
                                                       min = 0, max = Inf, step = 10),
 
                                          numericInput(inputId = "pop_size_upper",
                                                       label = "Borne sup�rieure (taille population)",
-                                                      value = 250,
+                                                      value = 350,
                                                       min = 0, max = Inf, step = 10),
 
                                          # Values
@@ -515,7 +515,7 @@ rm(list = ls(all.names = TRUE))
 
                                            numericInput(inputId = "pop_growth_upper",
                                                         label = HTML("Borne sup�rieure<br>(taux d'accroissement en %)"),
-                                                        value = -3,
+                                                        value = -6,
                                                         min = -100, max = 100, step = 1),
 
                                            ## Input values: mean and se
@@ -566,6 +566,9 @@ rm(list = ls(all.names = TRUE))
                                              ),
                                            )}, # close fluidRow
 
+                                           actionButton(inputId = "button_calibrate_vr", label = "Calibrer survies et f�condit�s"),
+
+
                                 )}, # close wellPanel
 
               )}, # close conditional panel
diff --git a/run_analysis.R b/run_analysis.R
index 86a6c7d37054a47daf2768334912aef3cd2ae954..13961998b2cc6ebf35b2e5acd0177bbbc197e80e 100644
--- a/run_analysis.R
+++ b/run_analysis.R
@@ -7,10 +7,11 @@ library(magrittr)
 library(eolpop)
 
 ## Inputs
-nsim = 100
+nsim = 10
 
-pop_size_mean = 500
+pop_size_mean = 350
 pop_size_se = 0
+pop_size_type = "Npair"
 
 carrying_capacity_mean = 1000
 carrying_capacity_se = 100
@@ -18,17 +19,19 @@ carrying_capacity_se = 100
 
 #(4.8/100)*sum(N000[-1])
 #(0.7/100)*sum(N000[-1])
-fatalities_mean = c(0, 5, 3, 4, 2, 1, 4, 2, 2, 3)
-fatalities_se = c(0, rep(0.5,9))
+fatalities_mean = c(0, 3) #c(0, 5, 3, 4, 2, 1, 4, 2, 2, 3)
+fatalities_se = c(0, 0.582) # c(0, rep(0.5,9))
 length(fatalities_mean)
 
+survivals <- c(0.65, 0.75, 0.85, 0.94)
+fecundities <- c(0, 0, 0.05, 0.40)
+
 #survivals <- c(0.47, 0.67, 0.67)
 #fecundities <- c(0, 0.30, 1.16)
+#survivals <- c(0.25, 0.30)
+#fecundities <- c(0, 19.8)
 
-survivals <- c(0.25, 0.30)
-fecundities <- c(0, 19.8)
-
-pop_growth_mean = 0.97
+pop_growth_mean = 0.94
 # lambda( build_Leslie(s = survivals, f = fecundities) )
 pop_growth_se = 0
 
@@ -37,10 +40,10 @@ model_demo = NULL # M2_noDD_WithDemoStoch #M1_noDD_noDemoStoch #M4_WithDD_WithDe
 time_horizon = 30
 coeff_var_environ = 0
 fatal_constant = "h"
-pop_size_type = "Ntotal"
+
 
 #if(length(fatalities_mean) > 2) cumulated_impacts = TRUE else cumulated_impacts = FALSE
-cumulated_impacts = TRUE
+cumulated_impacts = FALSE
 
 onset_year = c(2010, 2013, 2016, 2016, 2017, 2019, 2020, 2020, 2020, 2021) #rep(2010, 10)#
 length(onset_year)
@@ -91,7 +94,8 @@ s_calibrated <- head(vr_calibrated, length(survivals))
 f_calibrated <- tail(vr_calibrated, length(fecundities))
 
 lambda( build_Leslie(s = s_calibrated, f = f_calibrated) )
-
+s_calibrated
+f_calibrated
 
 
 length(survivals)
@@ -152,9 +156,37 @@ res = get_metrics(N = out$run$N, cumulated_impacts = cumulated_impacts)
 
 plot_impact(N, Legend = paste("sc", 1:length(fatalities_mean)))
 
+
+
+
+##
+# Pop size total
+N00 <- pop_vector(pop_size = pop_size_mean, pop_size_type = pop_size_type, s = s_calibrated, f = f_calibrated)
+sum(N00)
+
+pop_size_mean
+pop_size_type
+sum(N00)
+N00
+sum(N000)
+
+NN <- apply(N, c(1:3), mean)
+colSums(NN[,1,1:2])
+sum(NN[-c(1:2),1,1])/2
+sum(NN[-1,1,1])
+sum(NN[,1,1])
+
+
 x11()
 plot_traj(N, age_class_use = "pairs", fecundities = fecundities,
          Legend = paste("sc", 1:length(fatalities_mean)), ylim = c(0, NA))
-###
-plot_traj(N,
+
+plot_traj(N, age_class_use = "NotJuv0", fecundities = fecundities,
           Legend = paste("sc", 1:length(fatalities_mean)), ylim = c(0, NA))
+
+plot_traj(N, age_class_use = "all", fecundities = fecundities,
+          Legend = paste("sc", 1:length(fatalities_mean)), ylim = c(0, NA))
+
+
+###
+# plot_traj(N, Legend = paste("sc", 1:length(fatalities_mean)), ylim = c(0, NA))