Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
a89e122c
Commit
a89e122c
authored
Apr 27, 2020
by
K-H-Ismail
Committed by
Gauthier Quesnel
Apr 28, 2020
Browse files
simulations: add default to generator attributes
minor changes in generator and cross minor minor
parent
f6d0a59f
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/include/irritator/core.hpp
View file @
a89e122c
...
...
@@ -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
befor
e_value
=
v
al
u
e
;
bool
have_messag
e_value
=
f
al
s
e
;
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
!=
befor
e_value
)
{
if
(
have_messag
e_value
)
{
else_value
=
value
>=
threshold
?
if_value
:
else_value
;
event
=
value
>=
threshold
?
1.0
:
0.0
;
}
...
...
@@ -5246,3 +5243,4 @@ public:
}
// namespace irt
#endif
lib/include/irritator/io.hpp
View file @
a89e122c
...
...
@@ -576,3 +576,4 @@ public:
}
// namespace irt
#endif
lib/test/public-api.cpp
View file @
a89e122c
...
...
@@ -1236,3 +1236,4 @@ main()
};
}
lib/test/simulations.cpp
View file @
a89e122c
...
...
@@ -377,13 +377,13 @@ struct synapse make_synapse(irt::simulation* sim, long unsigned int source, long
irt
::
status
::
success
);
expect
(
sim
->
connect
(
p
ost
synaptic
,
expect
(
sim
->
connect
(
p
re
synaptic
,
accumulator_syn
.
x
[
0
])
==
irt
::
status
::
success
);
expect
(
sim
->
connect
(
p
re
synaptic
,
expect
(
sim
->
connect
(
p
ost
synaptic
,
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()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment