Commit 57967863 authored by ese ovie's avatar ese ovie Committed by Gauthier Quesnel
Browse files

model: replacing QSS1 linear with QSS2 non linear seir

parent 610dca44
......@@ -3088,21 +3088,6 @@ editor::show_window() noexcept
3,
"Fail to initialize example_qss_izhikevich<1>: %s\n",
status_string(ret));
if (ImGui::MenuItem("Insert example QSS1 seir_lineaire"))
if (auto ret = example_qss_seir_lineaire<1>(sim, empty_fun);
is_bad(ret))
log_w.log(
3,
"Fail to initialize example_qss_seir_lineaire<1>: %s\n",
status_string(ret));
if (ImGui::MenuItem("Insert example QSS1 seir_nonlineaire"))
if (auto ret = example_qss_seir_nonlineaire<1>(sim, empty_fun);
is_bad(ret))
log_w.log(
3,
"Fail to initialize "
"example_qss_seir_nonlineaire<1>: %s\n",
status_string(ret));
if (ImGui::MenuItem("Insert example QSS2 lotka_volterra"))
if (auto ret = example_qss_lotka_volterra<2>(sim, empty_fun);
......@@ -3137,6 +3122,13 @@ editor::show_window() noexcept
3,
"Fail to initialize example_qss_izhikevich<2>: %s\n",
status_string(ret));
if (ImGui::MenuItem("Insert example QSS2 seir_nonlinear"))
if (auto ret = example_qss_seir_nonlinear<2>(sim, empty_fun);
is_bad(ret))
log_w.log(
3,
"Fail to initialize example_qss_seir_nonlinear<2>: %s\n",
status_string(ret));
if (ImGui::MenuItem("Insert example QSS3 lotka_volterra"))
if (auto ret = example_qss_lotka_volterra<3>(sim, empty_fun);
......
......@@ -304,98 +304,34 @@ example_qss_negative_lif(simulation& sim, F f) noexcept
template<int QssLevel, typename F>
status
example_qss_seir_lineaire(simulation& sim, F f) noexcept
example_qss_seir_nonlinear(simulation& sim, F f) noexcept
{
bool success = sim.can_alloc(10) && sim.can_connect(12);
irt_return_if_fail(success, status::simulation_not_enough_model);
auto& sum_a = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_a.default_input_coeffs[0] = -0.005;
sum_a.default_input_coeffs[1] = -0.4;
auto& sum_b = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_b.default_input_coeffs[0] = -0.135;
sum_b.default_input_coeffs[1] = 0.1;
auto& product_a = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_b = sim.alloc<abstract_multiplier<QssLevel>>();
auto& integrator_a = sim.alloc<abstract_integrator<QssLevel>>();
integrator_a.default_X = 10.0;
integrator_a.default_dQ = 0.01;
auto& integrator_b = sim.alloc<abstract_integrator<QssLevel>>();
integrator_b.default_X = 15.0;
integrator_b.default_dQ = 0.01;
auto& integrator_c = sim.alloc<abstract_integrator<QssLevel>>();
integrator_c.default_X = 10.0;
integrator_c.default_dQ = 0.01;
auto& integrator_d = sim.alloc<abstract_integrator<QssLevel>>();
integrator_d.default_X = 18.0;
integrator_d.default_dQ = 0.01;
auto& constant_a = sim.alloc<constant>();
constant_a.default_value = -0.005;
auto& constant_b = sim.alloc<constant>();
constant_b.default_value = -0.135;
sim.connect(constant_a, 0, product_a, 0);
sim.connect(constant_b, 0, product_b, 0);
sim.connect(sum_a, 0, integrator_c, 0);
sim.connect(sum_b, 0, integrator_d, 0);
sim.connect(integrator_b, 0, sum_a, 0);
sim.connect(integrator_c, 0, sum_a, 1);
sim.connect(integrator_c, 0, sum_b, 0);
sim.connect(integrator_d, 0, sum_b, 1);
sim.connect(integrator_a, 0, product_a, 1);
sim.connect(integrator_b, 0, product_b, 1);
sim.connect(product_a, 0, sum_a, 1);
sim.connect(product_b, 0, sum_b, 1);
f(sim.get_id(integrator_a));
f(sim.get_id(integrator_b));
f(sim.get_id(integrator_c));
f(sim.get_id(integrator_d));
f(sim.get_id(product_a));
f(sim.get_id(product_b));
f(sim.get_id(sum_a));
f(sim.get_id(sum_b));
f(sim.get_id(constant_a));
f(sim.get_id(constant_b));
return status::success;
}
template<int QssLevel, typename F>
status
example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
{
bool success = sim.can_alloc(27) && sim.can_connect(32);
bool success = sim.can_alloc(29) && sim.can_connect(38);
irt_return_if_fail(success, status::simulation_not_enough_model);
auto& sum_a = sim.alloc<abstract_wsum<QssLevel, 3>>();
sum_a.default_input_coeffs[0] = 0.5;
sum_a.default_input_coeffs[1] = 1.0;
sum_a.default_input_coeffs[2] = 1.0;
sum_a.default_input_coeffs[0] = 1.0;
sum_a.default_input_coeffs[1] = -1.0;
sum_a.default_input_coeffs[2] = -1.0;
auto& sum_b = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_b.default_input_coeffs[0] = 1.0;
sum_b.default_input_coeffs[1] = 1.0;
sum_b.default_input_coeffs[1] = -1.0;
auto& sum_c = sim.alloc<abstract_wsum<QssLevel, 3>>();
sum_c.default_input_coeffs[0] = 1.5;
sum_c.default_input_coeffs[1] = 0.698;
sum_c.default_input_coeffs[2] = 0.387;
sum_c.default_input_coeffs[0] = 1.0;
sum_c.default_input_coeffs[1] = -1.0;
auto& sum_d = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_d.default_input_coeffs[0] = 1.0;
sum_d.default_input_coeffs[1] = 1.5;
sum_d.default_input_coeffs[1] = -1.0;
auto& sum_e = sim.alloc<abstract_wsum<QssLevel, 2>>();
sum_e.default_input_coeffs[0] = 1.0;
sum_e.default_input_coeffs[1] = 1.0;
sum_e.default_input_coeffs[2] = 1.0;
sum_e.default_input_coeffs[3] = 1.0;
auto& product_a = sim.alloc<abstract_multiplier<QssLevel>>();
......@@ -415,56 +351,55 @@ example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
auto& product_i = sim.alloc<abstract_multiplier<QssLevel>>();
auto& product_j = sim.alloc<abstract_multiplier<QssLevel>>();
auto& integrator_a = sim.alloc<abstract_integrator<QssLevel>>();
integrator_a.default_X = 10.0;
integrator_a.default_X = 999.0;
integrator_a.default_dQ = 0.01;
auto& integrator_b = sim.alloc<abstract_integrator<QssLevel>>();
integrator_b.default_X = 12.0;
integrator_b.default_X = 750.0;
integrator_b.default_dQ = 0.01;
auto& integrator_c = sim.alloc<abstract_integrator<QssLevel>>();
integrator_c.default_X = 13.50;
integrator_c.default_X = 650.0;
integrator_c.default_dQ = 0.01;
auto& integrator_d = sim.alloc<abstract_integrator<QssLevel>>();
integrator_d.default_X = 15.0;
integrator_d.default_X = 1.0;
integrator_d.default_dQ = 0.01;
// The values used here are from Singh et al., 2017
auto& constant_a = sim.alloc<constant>();
constant_a.default_value = 0.005;
constant_a.default_value = 16.6667;
auto& constant_b = sim.alloc<constant>();
constant_b.default_value = -0.0057;
constant_b.default_value = 0.3;
auto& constant_c = sim.alloc<constant>();
constant_c.default_value = -0.005;
constant_c.default_value = 0.016667;
auto& constant_d = sim.alloc<constant>();
constant_d.default_value = 0.0057;
constant_d.default_value = 0.3;
auto& constant_e = sim.alloc<constant>();
constant_e.default_value = -0.135;
constant_e.default_value = 0.004052;
auto& constant_f = sim.alloc<constant>();
constant_f.default_value = 0.135;
constant_f.default_value = 0.004052;
auto& constant_g = sim.alloc<constant>();
constant_g.default_value = -0.072;
constant_g.default_value = 0.11667;
auto& constant_h = sim.alloc<constant>();
constant_h.default_value = 0.005;
constant_h.default_value = 0.1;
auto& constant_i = sim.alloc<constant>();
constant_i.default_value = 0.067;
constant_i.default_value = 0.016667;
auto& constant_j = sim.alloc<constant>();
constant_j.default_value = -0.005;
auto& pow_n = sim.alloc<qss2_power>();
pow_n.default_n = -1.0;
sim.connect(constant_a, 0, sum_a, 0);
sim.connect(constant_h, 0, sum_c, 2);
sim.connect(constant_b, 0, product_a, 0);
sim.connect(constant_c, 0, product_b, 0);
sim.connect(constant_d, 0, product_c, 0);
......@@ -473,12 +408,6 @@ example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
sim.connect(constant_g, 0, product_f, 0);
sim.connect(constant_h, 0, product_g, 0);
sim.connect(constant_i, 0, product_h, 0);
sim.connect(product_i, 0, product_a, 1);
sim.connect(product_i, 0, product_c, 1);
sim.connect(sum_a, 0, integrator_a, 0);
sim.connect(sum_b, 0, integrator_b, 0);
sim.connect(sum_c, 0, integrator_c, 0);
sim.connect(sum_d, 0, integrator_d, 0);
sim.connect(product_a, 0, sum_a, 1);
sim.connect(product_b, 0, sum_a, 2);
sim.connect(product_c, 0, sum_b, 0);
......@@ -487,14 +416,27 @@ example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
sim.connect(product_f, 0, sum_c, 1);
sim.connect(product_g, 0, sum_d, 0);
sim.connect(product_h, 0, sum_d, 1);
sim.connect(sum_a, 0, integrator_a, 0);
sim.connect(sum_b, 0, integrator_b, 0);
sim.connect(sum_c, 0, integrator_c, 0);
sim.connect(sum_d, 0, integrator_d, 0);
sim.connect(sum_e, 0, pow_n, 0);
sim.connect(integrator_a, 0, product_b, 1);
sim.connect(integrator_a, 0, product_i, 0);
sim.connect(integrator_a, 0, sum_e, 0);
sim.connect(integrator_b, 0, product_d, 1);
sim.connect(integrator_b, 0, product_e, 1);
sim.connect(integrator_b, 0, sum_e, 1);
sim.connect(integrator_c, 0, product_f, 1);
sim.connect(integrator_c, 0, product_g, 1);
sim.connect(integrator_d, 0, product_h, 1);
sim.connect(integrator_a, 0, product_i, 0);
sim.connect(integrator_c, 0, product_i, 1);
sim.connect(integrator_c, 0, sum_e, 2);
sim.connect(integrator_d, 0, product_h, 1);
sim.connect(integrator_d, 0, sum_e, 3);
sim.connect(product_i, 0, product_j, 1);
sim.connect(product_j, 0, product_a, 1);
sim.connect(product_j, 0, product_c, 1);
sim.connect(pow_n, 0, product_j, 1);
f(sim.get_id(integrator_a));
f(sim.get_id(integrator_b));
......@@ -509,10 +451,12 @@ example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
f(sim.get_id(product_g));
f(sim.get_id(product_h));
f(sim.get_id(product_i));
f(sim.get_id(product_j));
f(sim.get_id(sum_a));
f(sim.get_id(sum_b));
f(sim.get_id(sum_c));
f(sim.get_id(sum_d));
f(sim.get_id(sum_e));
f(sim.get_id(constant_a));
f(sim.get_id(constant_b));
f(sim.get_id(constant_c));
......@@ -522,7 +466,7 @@ example_qss_seir_nonlineaire(simulation& sim, F f) noexcept
f(sim.get_id(constant_g));
f(sim.get_id(constant_h));
f(sim.get_id(constant_i));
f(sim.get_id(constant_j));
f(sim.get_id(pow_n));
return status::success;
}
......
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