-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding inhomogeneous poisson generator model #671
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
64b5921
Adding inhomogeneous poisson generator model (and required modificati…
zajzi 4519388
Updated authors.
zajzi f375dec
Fixed formatting issues.
zajzi 068343b
Merge branch 'master' of https://github.com/nest/nest-simulator into …
zajzi c889abf
Renamed to inhomogeneous_poisson_generator, and some other minor modi…
zajzi ca88909
Added snap-to-grid feature for rate times, along with the allow_offse…
zajzi 124c8ff
Removed unnecessary comment
zajzi 5af7508
Merge branch 'master' of https://github.com/nest/nest-simulator into …
zajzi 31183d4
Small update
zajzi bbf9560
Updates test with one simple scenario, currently fails with StackUnde…
zajzi 0d6d31c
Initializing variable in constructor.
zajzi 73fc2ac
Merge branch 'master' of https://github.com/nest/nest-simulator into …
zajzi db26b2c
Fixed allow_offgrid_times parameter. Extended unit test.
zajzi 11a895a
Merge branch 'master' of https://github.com/nest/nest-simulator into …
zajzi bfe4eaa
Enforcing rate times to be strictly in the future. Included a simple …
zajzi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* inh_poisson_generator.cpp | ||
* inhomogeneous_poisson_generator.cpp | ||
* | ||
* This file is part of NEST. | ||
* | ||
|
@@ -19,7 +19,7 @@ | |
* along with NEST. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#include "inh_poisson_generator.h" | ||
#include "inhomogeneous_poisson_generator.h" | ||
|
||
#include "event_delivery_manager_impl.h" | ||
#include "kernel_manager.h" | ||
|
@@ -41,7 +41,7 @@ | |
* Default constructors defining default parameter | ||
* ---------------------------------------------------------------- */ | ||
|
||
nest::inh_poisson_generator::Parameters_::Parameters_() | ||
nest::inhomogeneous_poisson_generator::Parameters_::Parameters_() | ||
: rate_times_() // ms | ||
, rate_values_() // spikes/ms | ||
{ | ||
|
@@ -52,7 +52,7 @@ nest::inh_poisson_generator::Parameters_::Parameters_() | |
* ---------------------------------------------------------------- */ | ||
|
||
void | ||
nest::inh_poisson_generator::Parameters_::get( DictionaryDatum& d ) const | ||
nest::inhomogeneous_poisson_generator::Parameters_::get( DictionaryDatum& d ) const | ||
{ | ||
( *d )[ names::rate_times ] = | ||
DoubleVectorDatum( new std::vector< double_t >( rate_times_ ) ); | ||
|
@@ -61,15 +61,15 @@ nest::inh_poisson_generator::Parameters_::get( DictionaryDatum& d ) const | |
} | ||
|
||
void | ||
nest::inh_poisson_generator::Parameters_::set( const DictionaryDatum& d, | ||
nest::inhomogeneous_poisson_generator::Parameters_::set( const DictionaryDatum& d, | ||
Buffers_& b ) | ||
{ | ||
const bool ut = | ||
const bool times = | ||
updateValue< std::vector< double_t > >( d, names::rate_times, rate_times_ ); | ||
const bool uv = updateValue< std::vector< double_t > >( | ||
const bool rates = updateValue< std::vector< double_t > >( | ||
d, names::rate_values, rate_values_ ); | ||
|
||
if ( ut xor uv ) | ||
if ( times xor rates ) | ||
{ | ||
throw BadProperty( "Rate times and values must be reset together." ); | ||
} | ||
|
@@ -80,7 +80,7 @@ nest::inh_poisson_generator::Parameters_::set( const DictionaryDatum& d, | |
} | ||
|
||
// ensure amp times are strictly monotonically increasing | ||
if ( rate_times_.empty() == false ) | ||
if ( not rate_times_.empty() ) | ||
{ | ||
std::vector< double_t >::const_iterator prev = rate_times_.begin(); | ||
std::vector< double_t >::const_iterator next = prev + 1; | ||
|
@@ -93,7 +93,7 @@ nest::inh_poisson_generator::Parameters_::set( const DictionaryDatum& d, | |
} | ||
} | ||
|
||
if ( ut && uv ) | ||
if ( times && rates ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
{ | ||
b.idx_ = 0; // reset if we got new data | ||
} | ||
|
@@ -103,43 +103,43 @@ nest::inh_poisson_generator::Parameters_::set( const DictionaryDatum& d, | |
* Default and copy constructor for node | ||
* ---------------------------------------------------------------- */ | ||
|
||
nest::inh_poisson_generator::inh_poisson_generator() | ||
nest::inhomogeneous_poisson_generator::inhomogeneous_poisson_generator() | ||
: Node() | ||
, device_() | ||
, P_() | ||
{ | ||
} | ||
|
||
nest::inh_poisson_generator::inh_poisson_generator( | ||
const inh_poisson_generator& n ) | ||
nest::inhomogeneous_poisson_generator::inhomogeneous_poisson_generator( | ||
const inhomogeneous_poisson_generator& n ) | ||
: Node( n ) | ||
, device_( n.device_ ) | ||
, P_( n.P_ ) | ||
{ | ||
} | ||
|
||
|
||
/* ---------------------------------------------------------------- | ||
* Node initialization functions | ||
* ---------------------------------------------------------------- */ | ||
void | ||
nest::inh_poisson_generator::init_state_( const Node& proto ) | ||
nest::inhomogeneous_poisson_generator::init_state_( const Node& proto ) | ||
{ | ||
const inh_poisson_generator& pr = downcast< inh_poisson_generator >( proto ); | ||
const inhomogeneous_poisson_generator& pr = | ||
downcast< inhomogeneous_poisson_generator >( proto ); | ||
|
||
device_.init_state( pr.device_ ); | ||
} | ||
|
||
void | ||
nest::inh_poisson_generator::init_buffers_() | ||
nest::inhomogeneous_poisson_generator::init_buffers_() | ||
{ | ||
device_.init_buffers(); | ||
B_.idx_ = 0; | ||
B_.rate_ = 0; | ||
} | ||
|
||
void | ||
nest::inh_poisson_generator::calibrate() | ||
nest::inhomogeneous_poisson_generator::calibrate() | ||
{ | ||
device_.calibrate(); | ||
V_.h_ = Time::get_resolution().get_ms(); | ||
|
@@ -150,7 +150,7 @@ nest::inh_poisson_generator::calibrate() | |
* ---------------------------------------------------------------- */ | ||
|
||
void | ||
nest::inh_poisson_generator::update( Time const& origin, | ||
nest::inhomogeneous_poisson_generator::update( Time const& origin, | ||
const long from, | ||
const long to ) | ||
{ | ||
|
@@ -164,7 +164,6 @@ nest::inh_poisson_generator::update( Time const& origin, | |
// random number generator | ||
librandom::RngPtr rng = kernel().rng_manager.get_rng( get_thread() ); | ||
|
||
|
||
// Skip any times in the past. Since we must send events proactively, | ||
// idx_ must point to times in the future. | ||
const long first = t0 + from; | ||
|
@@ -180,17 +179,16 @@ nest::inh_poisson_generator::update( Time const& origin, | |
|
||
// Keep the amplitude up-to-date at all times. | ||
// We need to change the amplitude one step ahead of time, see comment | ||
// on class SimulatingDevice. | ||
if ( B_.idx_ < P_.rate_times_.size() | ||
&& curr_time + 1 | ||
== Time( Time::ms( P_.rate_times_[ B_.idx_ ] ) ).get_steps() ) | ||
// on class StimulatingDevice. | ||
if ( B_.idx_ < P_.rate_times_.size() && curr_time + 1 | ||
== Time( Time::ms( P_.rate_times_[ B_.idx_ ] ) ).get_steps() ) | ||
{ | ||
B_.rate_ = P_.rate_values_[ B_.idx_ ] / 1000.0; // scale the rate to ms^-1 | ||
B_.idx_++; | ||
++B_.idx_; | ||
} | ||
|
||
// create spikes | ||
if ( B_.rate_ > 0 && device_.is_active( Time::step( t0 + offs ) ) ) | ||
if ( B_.rate_ > 0 && device_.is_active( Time::step( curr_time ) ) ) | ||
{ | ||
DSSpikeEvent se; | ||
kernel().event_delivery_manager.send( *this, se, offs ); | ||
|
@@ -199,7 +197,7 @@ nest::inh_poisson_generator::update( Time const& origin, | |
} | ||
|
||
void | ||
nest::inh_poisson_generator::event_hook( DSSpikeEvent& e ) | ||
nest::inhomogeneous_poisson_generator::event_hook( DSSpikeEvent& e ) | ||
{ | ||
librandom::RngPtr rng = kernel().rng_manager.get_rng( get_thread() ); | ||
V_.poisson_dev_.set_lambda( B_.rate_ * V_.h_ ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a spurious indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done