From fadb592922278fb992f59994443fb44fa177db7d Mon Sep 17 00:00:00 2001
From: Mahmoud Bentriou <mahmoud.bentriou@centralesupelec.fr>
Date: Sun, 22 Nov 2020 23:20:27 +0100
Subject: [PATCH] Small restruction in Cosmos tests. Add of set_time_bound! Add
 of a first notebook example to explain the package.

---
 core/MarkovProcesses.jl                     |  1 +
 core/model.jl                               |  1 +
 tests/cosmos/distance_F/ER_1D.jl            |  2 +-
 tests/cosmos/{distance_F => models}/ER.gspn |  0
 tests/cosmos/models/SIR.gspn                | 33 +++++++++++++++++++++
 5 files changed, 36 insertions(+), 1 deletion(-)
 rename tests/cosmos/{distance_F => models}/ER.gspn (100%)
 create mode 100644 tests/cosmos/models/SIR.gspn

diff --git a/core/MarkovProcesses.jl b/core/MarkovProcesses.jl
index 946d155..5fb0ec4 100644
--- a/core/MarkovProcesses.jl
+++ b/core/MarkovProcesses.jl
@@ -22,6 +22,7 @@ export load_automaton, get_index, get_value, length_var, isaccepted
 
 # Model related methods
 export simulate, set_param!, get_param, set_observed_var!
+export set_time_bound!
 export isbounded, isaccepted, check_consistency
 export load_model, get_module_path
 
diff --git a/core/model.jl b/core/model.jl
index 03099d0..bbbf51d 100644
--- a/core/model.jl
+++ b/core/model.jl
@@ -139,4 +139,5 @@ end
 set_param!(m::ContinuousTimeModel, p::Vector{Float64}) = (m.p = p)
 set_param!(m::ContinuousTimeModel, name_p::String, p_i::Float64) = (m.p[m.map_param_idx[name_p]] = p_i)
 get_param(m::ContinuousTimeModel) = m.p
+set_time_bound!(m::ContinuousTimeModel, b::Float64) = (m.time_bound = b)
 
diff --git a/tests/cosmos/distance_F/ER_1D.jl b/tests/cosmos/distance_F/ER_1D.jl
index 4c7a502..96ce2bf 100644
--- a/tests/cosmos/distance_F/ER_1D.jl
+++ b/tests/cosmos/distance_F/ER_1D.jl
@@ -39,7 +39,7 @@ for exp in l_exp
     for i in 1:nb_param
         # Cosmos estimation
         k3 = l_k3[i]
-        command = `Cosmos $(absolute_path * "distance_F/" * str_model * ".gspn") 
+        command = `Cosmos $(absolute_path * "models/" * str_model * ".gspn") 
         $(absolute_path * "distance_F/dist_F_"  * str_model * ".lha") --njob $(ENV["JULIA_NUM_THREADS"]) 
         --const k_3=$(k3),x1=$x1,x2=$x2,t1=$t1,t2=$t2 
         --level $(level) --width $(width) 
diff --git a/tests/cosmos/distance_F/ER.gspn b/tests/cosmos/models/ER.gspn
similarity index 100%
rename from tests/cosmos/distance_F/ER.gspn
rename to tests/cosmos/models/ER.gspn
diff --git a/tests/cosmos/models/SIR.gspn b/tests/cosmos/models/SIR.gspn
new file mode 100644
index 0000000..9fc21ae
--- /dev/null
+++ b/tests/cosmos/models/SIR.gspn
@@ -0,0 +1,33 @@
+
+const double ki = 0.0012;
+const double kr = 0.05;
+
+NbPlaces = 3;
+NbTransitions = 2;
+
+PlacesList ={ S, I, R };
+
+TransitionsList ={ Infection, Recovery };
+
+Marking={
+    (S, 95);
+    (I, 5);
+    (R, 0);
+};
+
+Transitions ={
+    (Infection, EXPONENTIAL(ki*S*I), 1, 1, SINGLE);
+    (Recovery, EXPONENTIAL(kr*I), 1, 1, SINGLE);
+};
+
+InArcs ={
+    (S, Infection, 1);
+    (I, Infection, 1);
+    (I, Recovery, 1);
+};
+
+OutArcs ={
+    (Infection, I, 2);
+    (Recovery, R, 1);
+};
+
-- 
GitLab