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/ReadME.md b/ReadME.md
index c710684..6e8b197 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",0] = 44
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)