Commit a89e122c authored by K-H-Ismail's avatar K-H-Ismail Committed by Gauthier Quesnel
Browse files

simulations: add default to generator attributes

minor changes in generator and cross

minor

minor
parent f6d0a59f
......@@ -3211,7 +3211,7 @@ struct accumulator
status::model_accumulator_bad_external_message);
irt_return_if_fail(msg.size() == 1,
status::model_accumulator_bad_external_message);
numbers[i] = i%2 == 0 ? msg.to_real_64(0) - 0.0001575: msg.to_real_64(0) + 0.000150;
numbers[i] = msg.to_real_64(0);
}
}
}
......@@ -3224,7 +3224,7 @@ struct accumulator
status::model_accumulator_bad_external_message);
if(static_cast<bool>(msg.to_real_64(0))) {
number = i%2 == 0 ? number + numbers[i] + 0.000150 : number + numbers[i] - 0.0001575;
number += numbers[i];
}
}
}
......@@ -3301,8 +3301,6 @@ struct generator
double value = 0.0;
double period = 1.0;
double offset = 1.0;
double counter;
status initialize(
data_array<message, message_id>& /*init_messages*/) noexcept
......@@ -3312,7 +3310,6 @@ struct generator
offset = default_offset;
sigma = offset;
counter = value;
return status::success;
}
......@@ -3322,7 +3319,6 @@ struct generator
time /*r*/) noexcept
{
sigma = period;
counter++;
return status::success;
}
......@@ -3330,7 +3326,7 @@ struct generator
data_array<output_port, output_port_id>& output_ports) noexcept
{
if (auto* port = output_ports.try_to_get(y[0]); port)
port->messages.emplace_front(counter);
port->messages.emplace_front(value);
return status::success;
}
......@@ -3482,7 +3478,7 @@ struct cross
time /*r*/) noexcept
{
bool have_message = false;
double before_value = value;
bool have_message_value = false;
if (auto* port = input_ports.try_to_get(x[port_value]); port) {
for (const auto& msg : port->messages) {
......@@ -3493,6 +3489,7 @@ struct cross
status::model_cross_bad_external_message);
value = msg.to_real_64(0);
have_message_value = true;
have_message = true;
}
......@@ -3525,7 +3522,7 @@ struct cross
}
}
if (value != before_value) {
if (have_message_value) {
else_value = value >= threshold ? if_value : else_value;
event = value >= threshold ? 1.0 : 0.0;
}
......@@ -5246,3 +5243,4 @@ public:
} // namespace irt
#endif
......@@ -576,3 +576,4 @@ public:
} // namespace irt
#endif
......@@ -1236,3 +1236,4 @@ main()
};
}
......@@ -377,13 +377,13 @@ struct synapse make_synapse(irt::simulation* sim, long unsigned int source, long
irt::status::success);
expect(sim->connect(postsynaptic,
expect(sim->connect(presynaptic,
accumulator_syn.x[0]) ==
irt::status::success);
expect(sim->connect(presynaptic,
expect(sim->connect(postsynaptic,
accumulator_syn.x[1]) ==
irt::status::success);
expect(sim->connect(int_post.y[0],
expect(sim->connect(cross_post.y[0],
accumulator_syn.x[2]) ==
irt::status::success);
expect(sim->connect(cross_pre.y[0],
......@@ -402,17 +402,17 @@ main()
"song_1_simulation"_test = [] {
irt::simulation sim;
// Neuron constants
long unsigned int N = 2;
double F = 15.0;
long unsigned int N = 4;
/*double F = 15.0;
double Eex = 0.0;
double Ein = -70*0.001;
double tauex = 5*0.001;
double tauin = tauex;
double tauin = tauex;*/
// Synapse constants
double ginbar = 0.05;
//double ginbar = 0.05;
expect(irt::is_success(sim.init(512lu, 8192lu)));
......@@ -431,9 +431,9 @@ main()
std::vector<irt::dynamics_id> generators;
for (long unsigned int i = 0 ; i < N; i++) {
auto& gen = sim.generator_models.alloc();
gen.value = 3.0;
gen.offset = i+1;
gen.period = 10.0;
gen.default_value = 3.0;
gen.default_offset = i+1;
gen.default_period = 10.0;
char genstr[5];
snprintf(genstr, 5,"gen%ld", i);
......@@ -496,3 +496,4 @@ main()
}
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