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) ...@@ -1573,6 +1573,13 @@ show_dynamics_values(const qss2_integrator& dyn)
ImGui::Text("dQ %.3f", dyn.default_dQ); 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 static void
show_dynamics_values(const qss1_sum_2& dyn) show_dynamics_values(const qss1_sum_2& dyn)
{ {
...@@ -1683,6 +1690,61 @@ show_dynamics_values(const qss2_wsum_4& dyn) ...@@ -1683,6 +1690,61 @@ show_dynamics_values(const qss2_wsum_4& dyn)
ImGui::Text("%.3f %.3f", dyn.values[3], dyn.values[7]); 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 static void
show_dynamics_values(const integrator& dyn) show_dynamics_values(const integrator& dyn)
{ {
...@@ -1778,6 +1840,14 @@ show_dynamics_values(const qss2_cross& dyn) ...@@ -1778,6 +1840,14 @@ show_dynamics_values(const qss2_cross& dyn)
ImGui::Text("else-value: %.3f", dyn.else_value); 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 static void
show_dynamics_values(const cross& dyn) show_dynamics_values(const cross& dyn)
{ {
...@@ -1824,6 +1894,13 @@ show_dynamics_inputs(qss2_integrator& dyn) ...@@ -1824,6 +1894,13 @@ show_dynamics_inputs(qss2_integrator& dyn)
ImGui::InputDouble("reset", &dyn.default_dQ); 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 static void
show_dynamics_inputs(qss1_multiplier& /*dyn*/) show_dynamics_inputs(qss1_multiplier& /*dyn*/)
{} {}
...@@ -1904,6 +1981,46 @@ show_dynamics_inputs(qss2_wsum_4& dyn) ...@@ -1904,6 +1981,46 @@ show_dynamics_inputs(qss2_wsum_4& dyn)
ImGui::InputDouble("coeff-3", &dyn.default_input_coeffs[3]); 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 static void
show_dynamics_inputs(integrator& dyn) show_dynamics_inputs(integrator& dyn)
{ {
...@@ -1996,6 +2113,12 @@ show_dynamics_inputs(qss2_cross& dyn) ...@@ -1996,6 +2113,12 @@ show_dynamics_inputs(qss2_cross& dyn)
ImGui::InputDouble("threshold", &dyn.default_threshold); ImGui::InputDouble("threshold", &dyn.default_threshold);
} }
static void
show_dynamics_inputs(qss3_cross& dyn)
{
ImGui::InputDouble("threshold", &dyn.default_threshold);
}
static void static void
show_dynamics_inputs(cross& dyn) show_dynamics_inputs(cross& dyn)
{ {
......
This diff is collapsed.
...@@ -113,6 +113,7 @@ private: ...@@ -113,6 +113,7 @@ private:
{ "counter", dynamics_type::counter }, { "counter", dynamics_type::counter },
{ "cross", dynamics_type::cross }, { "cross", dynamics_type::cross },
{ "generator", dynamics_type::generator }, { "generator", dynamics_type::generator },
{ "flow", dynamics_type::flow },
{ "integrator", dynamics_type::integrator }, { "integrator", dynamics_type::integrator },
{ "mult_2", dynamics_type::mult_2 }, { "mult_2", dynamics_type::mult_2 },
{ "mult_3", dynamics_type::mult_3 }, { "mult_3", dynamics_type::mult_3 },
...@@ -137,11 +138,19 @@ private: ...@@ -137,11 +138,19 @@ private:
{ "qss2_wsum_2", dynamics_type::qss2_wsum_2 }, { "qss2_wsum_2", dynamics_type::qss2_wsum_2 },
{ "qss2_wsum_3", dynamics_type::qss2_wsum_3 }, { "qss2_wsum_3", dynamics_type::qss2_wsum_3 },
{ "qss2_wsum_4", dynamics_type::qss2_wsum_4 }, { "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 } { "time_func", dynamics_type::time_func }
}; };
static_assert(std::size(table) == static_assert(std::size(table) == dynamics_type_size());
static_cast<size_t>(dynamics_type::accumulator_2) + 1);
const auto it = const auto it =
std::lower_bound(std::begin(table), std::lower_bound(std::begin(table),
...@@ -216,6 +225,14 @@ private: ...@@ -216,6 +225,14 @@ private:
return !!(is >> x1 >> x2); 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 bool read(qss1_multiplier& /*dyn*/) noexcept
{ {
return true; return true;
...@@ -262,6 +279,7 @@ private: ...@@ -262,6 +279,7 @@ private:
return !!(is >> x1 >> x2 >> x3 >> x4); return !!(is >> x1 >> x2 >> x3 >> x4);
} }
bool read(qss2_multiplier& /*dyn*/) noexcept bool read(qss2_multiplier& /*dyn*/) noexcept
{ {
return true; return true;
...@@ -309,6 +327,53 @@ private: ...@@ -309,6 +327,53 @@ private:
return !!(is >> x1 >> x2 >> x3 >> x4); 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 bool read(integrator& dyn) noexcept
{ {
return !!(is >> dyn.default_current_value >> dyn.default_reset_value); return !!(is >> dyn.default_current_value >> dyn.default_reset_value);
...@@ -407,6 +472,11 @@ private: ...@@ -407,6 +472,11 @@ private:
return !!(is >> dyn.default_threshold); return !!(is >> dyn.default_threshold);
} }
bool read(qss3_cross& dyn) noexcept
{
return !!(is >> dyn.default_threshold);
}
bool read(cross& dyn) noexcept bool read(cross& dyn) noexcept
{ {
return !!(is >> dyn.default_threshold); return !!(is >> dyn.default_threshold);
...@@ -523,6 +593,12 @@ private: ...@@ -523,6 +593,12 @@ private:
<< '\n'; << '\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 void write(const qss1_multiplier& /*dyn*/) noexcept
{ {
os << "qss1_multiplier\n"; os << "qss1_multiplier\n";
...@@ -558,10 +634,11 @@ private: ...@@ -558,10 +634,11 @@ private:
void write(const qss1_wsum_4& dyn) noexcept 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[1] << ' ' << dyn.default_input_coeffs[2]
<< ' ' << dyn.default_input_coeffs[3] << '\n'; << ' ' << dyn.default_input_coeffs[3] << '\n';
} }
void write(const qss2_multiplier& /*dyn*/) noexcept void write(const qss2_multiplier& /*dyn*/) noexcept
{ {
os << "qss2_multiplier\n"; os << "qss2_multiplier\n";
...@@ -597,7 +674,47 @@ private: ...@@ -597,7 +674,47 @@ private:
void write(const qss2_wsum_4& dyn) noexcept 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[1] << ' ' << dyn.default_input_coeffs[2]
<< ' ' << dyn.default_input_coeffs[3] << '\n'; << ' ' << dyn.default_input_coeffs[3] << '\n';
} }
...@@ -696,6 +813,11 @@ private: ...@@ -696,6 +813,11 @@ private:
os << "qss2_cross " << dyn.default_threshold << '\n'; 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 void write(const cross& dyn) noexcept
{ {
os << "cross " << dyn.default_threshold << '\n'; os << "cross " << dyn.default_threshold << '\n';
......
...@@ -889,8 +889,8 @@ main() ...@@ -889,8 +889,8 @@ main()
expect(sim.connect(integrator_b.y[0], quantifier_b.x[0]) == expect(sim.connect(integrator_b.y[0], quantifier_b.x[0]) ==
irt::status::success); irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("lotka-volterra_a.csv"); file_output fo_a("lotka-volterra_a.csv");
file_output fo_b("lotka-volterra_b.csv"); file_output fo_b("lotka-volterra_b.csv");
...@@ -1076,8 +1076,8 @@ main() ...@@ -1076,8 +1076,8 @@ main()
irt::status::success); irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success); expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("izhikevitch_a.csv"); file_output fo_a("izhikevitch_a.csv");
expect(fo_a.os != nullptr); expect(fo_a.os != nullptr);
...@@ -1175,8 +1175,8 @@ main() ...@@ -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_a.x[1]) == irt::status::success);
expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success); expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("lotka-volterra-qss1_a.csv"); file_output fo_a("lotka-volterra-qss1_a.csv");
file_output fo_b("lotka-volterra-qss1_b.csv"); file_output fo_b("lotka-volterra-qss1_b.csv");
...@@ -1273,8 +1273,8 @@ main() ...@@ -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_a.x[1]) == irt::status::success);
expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success); expect(sim.connect(product.y[0], sum_b.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("lotka-volterra-qss2_a.csv"); file_output fo_a("lotka-volterra-qss2_a.csv");
file_output fo_b("lotka-volterra-qss2_b.csv"); file_output fo_b("lotka-volterra-qss2_b.csv");
...@@ -1380,8 +1380,8 @@ main() ...@@ -1380,8 +1380,8 @@ main()
irt::status::success); irt::status::success);
expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success); expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("lif-qss.csv"); file_output fo_a("lif-qss.csv");
expect(fo_a.os != nullptr); expect(fo_a.os != nullptr);
...@@ -1467,8 +1467,8 @@ main() ...@@ -1467,8 +1467,8 @@ main()
expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success); expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success);
expect(sim.connect(sum.y[0], integrator.x[0]) == irt::status::success); expect(sim.connect(sum.y[0], integrator.x[0]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("lif-qss1.csv"); file_output fo_a("lif-qss1.csv");
expect(fo_a.os != nullptr); expect(fo_a.os != nullptr);
...@@ -1554,8 +1554,8 @@ main() ...@@ -1554,8 +1554,8 @@ main()
expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success); expect(sim.connect(constant.y[0], sum.x[1]) == irt::status::success);
expect(sim.connect(sum.y[0], integrator.x[0]) == irt::status::success); expect(sim.connect(sum.y[0], integrator.x[0]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("lif-qss2.csv"); file_output fo_a("lif-qss2.csv");
expect(fo_a.os != nullptr); expect(fo_a.os != nullptr);
...@@ -1653,8 +1653,8 @@ main() ...@@ -1653,8 +1653,8 @@ main()
!expect(irt::is_success( !expect(irt::is_success(
sim.alloc(sum_d, sim.qss1_wsum_2_models.get_id(sum_d), "sum_d"))); sim.alloc(sum_d, sim.qss1_wsum_2_models.get_id(sum_d), "sum_d")));
!expect(irt::is_success( !expect(irt::is_success(sim.alloc(
sim.alloc(product, sim.qss1_multiplier_models.get_id(product), "prod"))); product, sim.qss1_multiplier_models.get_id(product), "prod")));
!expect(irt::is_success( !expect(irt::is_success(
sim.alloc(integrator_a, sim.alloc(integrator_a,
sim.qss1_integrator_models.get_id(integrator_a), sim.qss1_integrator_models.get_id(integrator_a),
...@@ -1709,8 +1709,8 @@ main() ...@@ -1709,8 +1709,8 @@ main()
irt::status::success); irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success); expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("izhikevitch-qss1_a.csv"); file_output fo_a("izhikevitch-qss1_a.csv");
expect(fo_a.os != nullptr); expect(fo_a.os != nullptr);
...@@ -1872,8 +1872,8 @@ main() ...@@ -1872,8 +1872,8 @@ main()
irt::status::success); irt::status::success);
expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success); expect(sim.connect(constant.y[0], sum_d.x[1]) == irt::status::success);
//irt::dot_writer dw(std::cout); // irt::dot_writer dw(std::cout);
//dw(sim); // dw(sim);
file_output fo_a("izhikevitch-qss2_a.csv"); file_output fo_a("izhikevitch-qss2_a.csv");
expect(fo_a.os != nullptr); expect(fo_a.os != nullptr);
...@@ -1907,4 +1907,102 @@ main() ...@@ -1907,4 +1907,102 @@ main()
expect(st == irt::status::success); expect(st == irt::status::success);
} while (t < 100); } while (t < 100);
}; };