Maintenance - Mise à jour mensuelle Lundi 7 Décembre 2021 entre 7h00 et 9h00

Commit ffce287d authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

core: add Qss3 layer

parent f77391f3
Pipeline #15377 failed with stage
in 59 seconds
......@@ -1573,6 +1573,13 @@ show_dynamics_values(const qss2_integrator& dyn)
ImGui::Text("dQ %.3f", dyn.default_dQ);
}
static void
show_dynamics_values(const qss3_integrator& dyn)
{
ImGui::Text("X %.3f", dyn.X);
ImGui::Text("dQ %.3f", dyn.default_dQ);
}
static void
show_dynamics_values(const qss1_sum_2& dyn)
{
......@@ -1683,6 +1690,61 @@ show_dynamics_values(const qss2_wsum_4& dyn)
ImGui::Text("%.3f %.3f", dyn.values[3], dyn.values[7]);
}
static void
show_dynamics_values(const qss3_sum_2& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[2]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[3]);
}
static void
show_dynamics_values(const qss3_sum_3& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[3]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[4]);
ImGui::Text("%.3f %.3f", dyn.values[2], dyn.values[5]);
}
static void
show_dynamics_values(const qss3_sum_4& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[4]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[5]);
ImGui::Text("%.3f %.3f", dyn.values[2], dyn.values[6]);
ImGui::Text("%.3f %.3f", dyn.values[3], dyn.values[7]);
}
static void
show_dynamics_values(const qss3_multiplier& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[2]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[3]);
}
static void
show_dynamics_values(const qss3_wsum_2& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[2]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[3]);
}
static void
show_dynamics_values(const qss3_wsum_3& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[3]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[4]);
ImGui::Text("%.3f %.3f", dyn.values[2], dyn.values[5]);
}
static void
show_dynamics_values(const qss3_wsum_4& dyn)
{
ImGui::Text("%.3f %.3f", dyn.values[0], dyn.values[4]);
ImGui::Text("%.3f %.3f", dyn.values[1], dyn.values[5]);
ImGui::Text("%.3f %.3f", dyn.values[2], dyn.values[6]);
ImGui::Text("%.3f %.3f", dyn.values[3], dyn.values[7]);
}
static void
show_dynamics_values(const integrator& dyn)
{
......@@ -1778,6 +1840,14 @@ show_dynamics_values(const qss2_cross& dyn)
ImGui::Text("else-value: %.3f", dyn.else_value);
}
static void
show_dynamics_values(const qss3_cross& dyn)
{
ImGui::Text("value: %.3f", dyn.value[0]);
ImGui::Text("if-value: %.3f", dyn.if_value);
ImGui::Text("else-value: %.3f", dyn.else_value);
}
static void
show_dynamics_values(const cross& dyn)
{
......@@ -1824,6 +1894,13 @@ show_dynamics_inputs(qss2_integrator& dyn)
ImGui::InputDouble("reset", &dyn.default_dQ);
}
static void
show_dynamics_inputs(qss3_integrator& dyn)
{
ImGui::InputDouble("value", &dyn.default_X);
ImGui::InputDouble("reset", &dyn.default_dQ);
}
static void
show_dynamics_inputs(qss1_multiplier& /*dyn*/)
{}
......@@ -1904,6 +1981,46 @@ show_dynamics_inputs(qss2_wsum_4& dyn)
ImGui::InputDouble("coeff-3", &dyn.default_input_coeffs[3]);
}
static void
show_dynamics_inputs(qss3_multiplier& /*dyn*/)
{}
static void
show_dynamics_inputs(qss3_sum_2& /*dyn*/)
{}
static void
show_dynamics_inputs(qss3_sum_3& /*dyn*/)
{}
static void
show_dynamics_inputs(qss3_sum_4& /*dyn*/)
{}
static void
show_dynamics_inputs(qss3_wsum_2& dyn)
{
ImGui::InputDouble("coeff-0", &dyn.default_input_coeffs[0]);
ImGui::InputDouble("coeff-1", &dyn.default_input_coeffs[1]);
}
static void
show_dynamics_inputs(qss3_wsum_3& dyn)
{
ImGui::InputDouble("coeff-0", &dyn.default_input_coeffs[0]);
ImGui::InputDouble("coeff-1", &dyn.default_input_coeffs[1]);
ImGui::InputDouble("coeff-2", &dyn.default_input_coeffs[2]);
}
static void
show_dynamics_inputs(qss3_wsum_4& dyn)
{
ImGui::InputDouble("coeff-0", &dyn.default_input_coeffs[0]);
ImGui::InputDouble("coeff-1", &dyn.default_input_coeffs[1]);
ImGui::InputDouble("coeff-2", &dyn.default_input_coeffs[2]);
ImGui::InputDouble("coeff-3", &dyn.default_input_coeffs[3]);
}
static void
show_dynamics_inputs(integrator& dyn)
{
......@@ -1996,6 +2113,12 @@ show_dynamics_inputs(qss2_cross& dyn)
ImGui::InputDouble("threshold", &dyn.default_threshold);
}
static void
show_dynamics_inputs(qss3_cross& dyn)
{
ImGui::InputDouble("threshold", &dyn.default_threshold);
}
static void
show_dynamics_inputs(cross& dyn)
{
......
This diff is collapsed.
......@@ -113,6 +113,7 @@ private:
{ "counter", dynamics_type::counter },
{ "cross", dynamics_type::cross },
{ "generator", dynamics_type::generator },
{ "flow", dynamics_type::flow },
{ "integrator", dynamics_type::integrator },
{ "mult_2", dynamics_type::mult_2 },
{ "mult_3", dynamics_type::mult_3 },
......@@ -137,11 +138,19 @@ private:
{ "qss2_wsum_2", dynamics_type::qss2_wsum_2 },
{ "qss2_wsum_3", dynamics_type::qss2_wsum_3 },
{ "qss2_wsum_4", dynamics_type::qss2_wsum_4 },
{ "qss3_integrator", dynamics_type::qss3_integrator },
{ "qss3_multiplier", dynamics_type::qss3_multiplier },
{ "qss3_cross", dynamics_type::qss3_cross },
{ "qss3_sum_2", dynamics_type::qss3_sum_2 },
{ "qss3_sum_3", dynamics_type::qss3_sum_3 },
{ "qss3_sum_4", dynamics_type::qss3_sum_4 },
{ "qss3_wsum_2", dynamics_type::qss3_wsum_2 },
{ "qss3_wsum_3", dynamics_type::qss3_wsum_3 },
{ "qss3_wsum_4", dynamics_type::qss3_wsum_4 },
{ "time_func", dynamics_type::time_func }
};
static_assert(std::size(table) ==
static_cast<size_t>(dynamics_type::accumulator_2) + 1);
static_assert(std::size(table) == dynamics_type_size());
const auto it =
std::lower_bound(std::begin(table),
......@@ -216,6 +225,14 @@ private:
return !!(is >> x1 >> x2);
}
bool read(qss3_integrator& dyn) noexcept
{
double& x1 = *(const_cast<double*>(&dyn.default_X));
double& x2 = *(const_cast<double*>(&dyn.default_dQ));
return !!(is >> x1 >> x2);
}
bool read(qss1_multiplier& /*dyn*/) noexcept
{
return true;
......@@ -262,6 +279,7 @@ private:
return !!(is >> x1 >> x2 >> x3 >> x4);
}
bool read(qss2_multiplier& /*dyn*/) noexcept
{
return true;
......@@ -309,6 +327,53 @@ private:
return !!(is >> x1 >> x2 >> x3 >> x4);
}
bool read(qss3_multiplier& /*dyn*/) noexcept
{
return true;
}
bool read(qss3_sum_2& /*dyn*/) noexcept
{
return true;
}
bool read(qss3_sum_3& /*dyn*/) noexcept
{
return true;
}
bool read(qss3_sum_4& /*dyn*/) noexcept
{
return true;
}
bool read(qss3_wsum_2& dyn) noexcept
{
double& x1 = *(const_cast<double*>(&dyn.default_input_coeffs[0]));
double& x2 = *(const_cast<double*>(&dyn.default_input_coeffs[1]));
return !!(is >> x1 >> x2);
}
bool read(qss3_wsum_3& dyn) noexcept
{
double& x1 = *(const_cast<double*>(&dyn.default_input_coeffs[0]));
double& x2 = *(const_cast<double*>(&dyn.default_input_coeffs[1]));
double& x3 = *(const_cast<double*>(&dyn.default_input_coeffs[2]));
return !!(is >> x1 >> x2 >> x3);
}
bool read(qss3_wsum_4& dyn) noexcept
{
double& x1 = *(const_cast<double*>(&dyn.default_input_coeffs[0]));
double& x2 = *(const_cast<double*>(&dyn.default_input_coeffs[1]));
double& x3 = *(const_cast<double*>(&dyn.default_input_coeffs[2]));
double& x4 = *(const_cast<double*>(&dyn.default_input_coeffs[2]));
return !!(is >> x1 >> x2 >> x3 >> x4);
}
bool read(integrator& dyn) noexcept
{
return !!(is >> dyn.default_current_value >> dyn.default_reset_value);
......@@ -407,6 +472,11 @@ private:
return !!(is >> dyn.default_threshold);
}
bool read(qss3_cross& dyn) noexcept
{
return !!(is >> dyn.default_threshold);
}
bool read(cross& dyn) noexcept
{
return !!(is >> dyn.default_threshold);
......@@ -523,6 +593,12 @@ private:
<< '\n';
}
void write(const qss3_integrator& dyn) noexcept
{
os << "qss3_integrator " << dyn.default_X << ' ' << dyn.default_dQ
<< '\n';
}
void write(const qss1_multiplier& /*dyn*/) noexcept
{
os << "qss1_multiplier\n";
......@@ -558,10 +634,11 @@ private:
void write(const qss1_wsum_4& dyn) noexcept
{
os << "qss1_wsum_3 " << dyn.default_input_coeffs[0] << ' '
os << "qss1_wsum_4 " << dyn.default_input_coeffs[0] << ' '
<< dyn.default_input_coeffs[1] << ' ' << dyn.default_input_coeffs[2]
<< ' ' << dyn.default_input_coeffs[3] << '\n';
}
void write(const qss2_multiplier& /*dyn*/) noexcept
{
os << "qss2_multiplier\n";
......@@ -597,7 +674,47 @@ private:
void write(const qss2_wsum_4& dyn) noexcept
{
os << "qss2_wsum_3 " << dyn.default_input_coeffs[0] << ' '
os << "qss2_wsum_4 " << dyn.default_input_coeffs[0] << ' '
<< dyn.default_input_coeffs[1] << ' ' << dyn.default_input_coeffs[2]
<< ' ' << dyn.default_input_coeffs[3] << '\n';
}
void write(const qss3_multiplier& /*dyn*/) noexcept
{
os << "qss3_multiplier\n";
}
void write(const qss3_sum_2& /*dyn*/) noexcept
{
os << "qss3_sum_2\n";
}
void write(const qss3_sum_3& /*dyn*/) noexcept
{
os << "qss3_sum_3\n";
}
void write(const qss3_sum_4& /*dyn*/) noexcept
{
os << "qss3_sum_4\n";
}
void write(const qss3_wsum_2& dyn) noexcept
{
os << "qss3_wsum_2 " << dyn.default_input_coeffs[0] << ' '
<< dyn.default_input_coeffs[1] << '\n';
}
void write(const qss3_wsum_3& dyn) noexcept
{
os << "qss3_wsum_3 " << dyn.default_input_coeffs[0] << ' '
<< dyn.default_input_coeffs[1] << ' ' << dyn.default_input_coeffs[2]
<< '\n';
}
void write(const qss3_wsum_4& dyn) noexcept
{
os << "qss3_wsum_4 " << dyn.default_input_coeffs[0] << ' '
<< dyn.default_input_coeffs[1] << ' ' << dyn.default_input_coeffs[2]
<< ' ' << dyn.default_input_coeffs[3] << '\n';
}
......@@ -696,6 +813,11 @@ private:
os << "qss2_cross " << dyn.default_threshold << '\n';
}
void write(const qss3_cross& dyn) noexcept
{
os << "qss3_cross " << dyn.default_threshold << '\n';
}
void write(const cross& dyn) noexcept
{
os << "cross " << dyn.default_threshold << '\n';
......
......@@ -889,8 +889,8 @@ main()
expect(sim.connect(integrator_b.y[0], quantifier_b.x[0]) ==
irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lotka-volterra_a.csv");
file_output fo_b("lotka-volterra_b.csv");
......@@ -1076,8 +1076,8 @@ main()
irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("izhikevitch_a.csv");
expect(fo_a.os != nullptr);
......@@ -1175,8 +1175,8 @@ main()
expect(sim.connect(product.y[0], sum_a.x[1]) == irt::status::success);
expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lotka-volterra-qss1_a.csv");
file_output fo_b("lotka-volterra-qss1_b.csv");
......@@ -1273,8 +1273,8 @@ main()
expect(sim.connect(product.y[0], sum_a.x[1]) == irt::status::success);
expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lotka-volterra-qss2_a.csv");
file_output fo_b("lotka-volterra-qss2_b.csv");
......@@ -1380,8 +1380,8 @@ main()
irt::status::success);
expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lif-qss.csv");
expect(fo_a.os != nullptr);
......@@ -1467,8 +1467,8 @@ main()
expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success);
expect(sim.connect(sum.y[0], integrator.x[0]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lif-qss1.csv");
expect(fo_a.os != nullptr);
......@@ -1554,8 +1554,8 @@ main()
expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success);
expect(sim.connect(sum.y[0], integrator.x[0]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lif-qss2.csv");
expect(fo_a.os != nullptr);
......@@ -1653,8 +1653,8 @@ main()
!expect(irt::is_success(
sim.alloc(sum_d, sim.qss1_wsum_2_models.get_id(sum_d), "sum_d")));
!expect(irt::is_success(
sim.alloc(product, sim.qss1_multiplier_models.get_id(product), "prod")));
!expect(irt::is_success(sim.alloc(
product, sim.qss1_multiplier_models.get_id(product), "prod")));
!expect(irt::is_success(
sim.alloc(integrator_a,
sim.qss1_integrator_models.get_id(integrator_a),
......@@ -1709,8 +1709,8 @@ main()
irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("izhikevitch-qss1_a.csv");
expect(fo_a.os != nullptr);
......@@ -1872,8 +1872,8 @@ main()
irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout);
//dw(sim);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("izhikevitch-qss2_a.csv");
expect(fo_a.os != nullptr);
......@@ -1907,4 +1907,102 @@ main()
expect(st == irt::status::success);
} while (t < 100);
};
"lotka_volterra_simulation_qss3"_test = [] {
irt::simulation sim;
expect(irt::is_success(sim.init(32lu, 512lu)));
expect(sim.qss3_wsum_2_models.can_alloc(2));
expect(sim.qss3_multiplier_models.can_alloc(2));
expect(sim.qss3_integrator_models.can_alloc(2));
auto& sum_a = sim.qss3_wsum_2_models.alloc();
auto& sum_b = sim.qss3_wsum_2_models.alloc();
auto& product = sim.qss3_multiplier_models.alloc();
auto& integrator_a = sim.qss3_integrator_models.alloc();
auto& integrator_b = sim.qss3_integrator_models.alloc();
integrator_a.default_X = 18.0;
integrator_a.default_dQ = 0.1;
integrator_b.default_X = 7.0;
integrator_b.default_dQ = 0.1;
// product.default_input_coeffs[0] = 1.0;
// product.default_input_coeffs[1] = 1.0;
sum_a.default_input_coeffs[0] = 2.0;
sum_a.default_input_coeffs[1] = -0.4;
sum_b.default_input_coeffs[0] = -1.0;
sum_b.default_input_coeffs[1] = 0.1;
expect(sim.models.can_alloc(10));
!expect(irt::is_success(
sim.alloc(sum_a, sim.qss3_wsum_2_models.get_id(sum_a), "sum_a")));
!expect(irt::is_success(
sim.alloc(sum_b, sim.qss3_wsum_2_models.get_id(sum_b), "sum_b")));
!expect(irt::is_success(sim.alloc(
product, sim.qss3_multiplier_models.get_id(product), "prod")));
!expect(irt::is_success(
sim.alloc(integrator_a,
sim.qss3_integrator_models.get_id(integrator_a),
"int_a")));
!expect(irt::is_success(
sim.alloc(integrator_b,
sim.qss3_integrator_models.get_id(integrator_b),
"int_b")));
!expect(sim.models.size() == 5_ul);
expect(sim.connect(sum_a.y[0], integrator_a.x[0]) ==
irt::status::success);
expect(sim.connect(sum_b.y[0], integrator_b.x[0]) ==
irt::status::success);
expect(sim.connect(integrator_a.y[0], sum_a.x[0]) ==
irt::status::success);
expect(sim.connect(integrator_b.y[0], sum_b.x[0]) ==
irt::status::success);
expect(sim.connect(integrator_a.y[0], product.x[0]) ==
irt::status::success);
expect(sim.connect(integrator_b.y[0], product.x[1]) ==
irt::status::success);
expect(sim.connect(product.y[0], sum_a.x[1]) == irt::status::success);
expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success);
// irt::dot_writer dw(std::cout);
// dw(sim);
file_output fo_a("lotka-volterra-qss3_a.csv");
file_output fo_b("lotka-volterra-qss3_b.csv");
expect(fo_a.os != nullptr);
expect(fo_b.os != nullptr);
auto& obs_a = sim.observers.alloc(0.01,
"A",
static_cast<void*>(&fo_a),
file_output_initialize,
&file_output_observe,
nullptr);
auto& obs_b = sim.observers.alloc(0.01,
"B",
static_cast<void*>(&fo_b),
file_output_initialize,
&file_output_observe,
nullptr);
sim.observe(sim.models.get(integrator_a.id), obs_a);
sim.observe(sim.models.get(integrator_b.id), obs_b);
irt::time t = 0.0;
expect(sim.initialize(t) == irt::status::success);
!expect(sim.sched.size() == 5_ul);
do {
auto st = sim.run(t);
expect(st == irt::status::success);
} while (t < 15.0);
};
}
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