From 12963a9b30d6ef2890a49acbbc69b7a8b3cee9cf Mon Sep 17 00:00:00 2001 From: Irene Terrone <62707828+IreneTerrone@users.noreply.github.com> Date: Tue, 25 Jul 2023 10:16:43 +0100 Subject: [PATCH 1/3] Update ReadME.md --- ReadME.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ReadME.md b/ReadME.md index c710684..8b45f2d 100644 --- a/ReadME.md +++ b/ReadME.md @@ -207,12 +207,14 @@ the number is located, 3) a second integer that is the index of the column. on a file which contain a numeric matrix where the first column symbolize a list of time steps as a list of numbers sorting in ascending order. The function takes as parameters 1) a string which represents the name -of the file 2) an integer that is the time we are interested in and based on which +of the file 2) An integer representing the index of the +column of the matrix, which goes from 0 to n-2 where n is the total number of columns. +The *i-th* time step representing the index of the row +we are interested in is automatically passed inside the process as an integer; thanks to it we will extract the index of the row. The exact value of time may not be present in the first column so the index of the row is selected as the position of the first value lower than the one passed -as parameter. 3) An integer representing the index of the -column of the matrix. +as parameter. SIRFile: 3,9,13 @@ -221,9 +223,12 @@ column of the matrix. 16,90,23 33,44,88 - FromTimeTable["SIRFile", 1,1] = 13 - FromTimeTable["BSIRFile", 10,1] = 1 - FromTimeTable["SIRFile", 50,1] = 88 + Time step: 1 + FromTimeTable["SIRFile",1] = 13 + Time step: 10 + FromTimeTable["SIRFile",1] = 1 + Time step: 50 + FromTimeTable["SIRFile", 50,0] = 44 \label{fig:SIR_PN} Petri Net representation of the SIR model.

From 69bac0565a725fa97eef299294e0b3cdd145d1ae Mon Sep 17 00:00:00 2001 From: Irene Terrone <62707828+IreneTerrone@users.noreply.github.com> Date: Tue, 25 Jul 2023 10:30:45 +0100 Subject: [PATCH 2/3] Update ReadME.md --- ReadME.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReadME.md b/ReadME.md index 8b45f2d..6e8b197 100644 --- a/ReadME.md +++ b/ReadME.md @@ -228,7 +228,7 @@ as parameter. Time step: 10 FromTimeTable["SIRFile",1] = 1 Time step: 50 - FromTimeTable["SIRFile", 50,0] = 44 + FromTimeTable["SIRFile",0] = 44 \label{fig:SIR_PN} Petri Net representation of the SIR model.

From 5334703f781f1362c2ffe01f1dd297850d1ee8b3 Mon Sep 17 00:00:00 2001 From: IreneTerrone Date: Thu, 30 Nov 2023 15:37:09 +0100 Subject: [PATCH 3/3] update of main and function sensitivity by Chiabrando --- Main.R | 20 ++++++++++++-------- Rfunction/FunctionSensitivity.R | 2 +- Rfunction/SensitivityPlot.R | 15 ++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Main.R b/Main.R index 4b018db..7c4ce65 100644 --- a/Main.R +++ b/Main.R @@ -32,7 +32,7 @@ end_time <- Sys.time()-start_time ############################## source("./Rfunction/SensitivityPlot.R") -pl = SensitivityPlot(folder = "SIR_sensitivity/") +pl = SensitivityPlot(folder = "SIR_sensitivity/", scd_folder = "SIR_analysis/") pl$TrajS pl$TrajI @@ -54,7 +54,7 @@ model.calibration(parameters_fname = "Input/Functions_list_Calibration.csv", lb_v = c(0.01, 0.0001), ub_v = c(0.05, 0.002), max.time = 2 - ) +) end_time <- Sys.time()-start_time @@ -79,15 +79,17 @@ model.analysis(solver_fname = "Net/SIR.solver", solver_type = "LSODA", f_time = 7*10, # weeks s_time = 1 - ) +) source("Rfunction/ModelAnalysisPlot.R") AnalysisPlot = ModelAnalysisPlot(Stoch = F ,print = F, trace_path = "./SIR_analysis/SIR-analysis-1.trace") -AnalysisPlot$plI -model_analysis(solver_fname = "Net/SIR.solver", + +AnalysisPlot$plAll + +model.analysis(solver_fname = "Net/SIR.solver", parameters_fname = "Input/Functions_list_ModelAnalysis.csv", solver_type = "SSA", n_run = 500, @@ -98,6 +100,8 @@ model_analysis(solver_fname = "Net/SIR.solver", AnalysisPlot = ModelAnalysisPlot(Stoch = T ,print = F, trace_path = "./SIR_analysis/SIR-analysis-1.trace") -AnalysisPlot$plI -AnalysisPlot$HistI -plS \ No newline at end of file + +AnalysisPlot$plAll +AnalysisPlot$plAllMean + + diff --git a/Rfunction/FunctionSensitivity.R b/Rfunction/FunctionSensitivity.R index d228824..4e3c84f 100644 --- a/Rfunction/FunctionSensitivity.R +++ b/Rfunction/FunctionSensitivity.R @@ -25,4 +25,4 @@ mse<-function(reference, output) diff.Infect <- 1/length(times_ref)*sum(( Infect - I_ref )^2 ) return(diff.Infect) -} \ No newline at end of file +} diff --git a/Rfunction/SensitivityPlot.R b/Rfunction/SensitivityPlot.R index cc079ba..c2c9b8d 100644 --- a/Rfunction/SensitivityPlot.R +++ b/Rfunction/SensitivityPlot.R @@ -1,13 +1,14 @@ library(ggplot2) -SensitivityPlot <-function(rank=T,folder){ - load(paste0(folder,"SIR-sensitivity.RData")) +SensitivityPlot <-function(rank=T,folder, scd_folder){ + #Changed the folder in which is contained the .RData file + load(paste0(scd_folder,"SIR-analysis.RData")) # Then, we read all the trajectories generated saving them in a list called # ListTraces. List that will be rewritten as a data frame in order to use ggplot. # ConfigID represents the initial condition associated to each trajectory, # which was generated by using the function implemented in the file Functions.R . - listFile<-list.files(folder, + listFile<-list.files(scd_folder, pattern = ".trace") configID<-t(sapply(1:length(listFile), @@ -28,15 +29,15 @@ SensitivityPlot <-function(rank=T,folder){ sep = "")) - + #Corrected the names of the .trace file in accord to the new path ListTraces<-lapply(id.traces, function(x){ trace.tmp=read.csv(paste0( - folder,"/SIR-sensitivity-", + scd_folder,"SIR-analysis-", x, ".trace"), sep = "") trace.tmp=data.frame(trace.tmp,ID= x, - rank = rank[which(rank[,2]==paste0("SIR-sensitivity-", + rank = rank[which(rank[,2]==paste0("SIR-analysis-", x, ".trace")),1]) return(trace.tmp) @@ -46,7 +47,7 @@ SensitivityPlot <-function(rank=T,folder){ function(x){ recovery<-config[[4]][[x]][[3]] infection<-config[[5]][[x]][[3]] - rnk.tmp=data.frame(ID=x,distance = rank[which(rank[,2]==paste0("SIR-sensitivity-", + rnk.tmp=data.frame(ID=x,distance = rank[which(rank[,2]==paste0("SIR-analysis-", x, ".trace")),1], rec_rate=recovery, inf_rate=infection)