Skip to content
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

Precision setting improvement #446

Merged
merged 8 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions models/spike_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ nest::spike_detector::spike_detector()
// record time and gid
, device_( *this, RecordingDevice::SPIKE_DETECTOR, "gdf", true, true )
, user_set_precise_times_( false )
, user_set_precision_value( -1 )
, has_proxies_( false )
, local_receiver_( true )
{
Expand All @@ -55,6 +56,7 @@ nest::spike_detector::spike_detector( const spike_detector& n )
: Node( n )
, device_( *this, n.device_ )
, user_set_precise_times_( n.user_set_precise_times_ )
, user_set_precision_value( n.user_set_precision_value )
, has_proxies_( false )
, local_receiver_( true )
{
Expand All @@ -80,19 +82,37 @@ nest::spike_detector::init_buffers_()
void
nest::spike_detector::calibrate()
{
if ( !user_set_precise_times_
&& kernel().event_delivery_manager.get_off_grid_communication() )
if ( kernel().event_delivery_manager.get_off_grid_communication() )
{
device_.set_precise( true, 15 );

LOG( M_INFO,
"spike_detector::calibrate",
String::compose(
"Precise neuron models exist: the property precise_times "
"of the %1 with gid %2 has been set to true, precision has "
"been set to 15.",
get_name(),
get_gid() ) );
// If precise models exist, it is necessary to ensure that precise_times
// property
// is set to true and the precision should increase from the default value
// of 3.

// Default precision value for simulations involving precise models.
long precision = 15;

if ( user_set_precision_value != -1 )
{
// If precision is set to a value by the user, it must be used instead of
// the default.
precision = user_set_precision_value;
}

device_.set_precise( true, precision );

if ( user_set_precise_times_ != true )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One should not compare booleans to true or false, just if ( not user_set_precise_times_ ).

{
LOG( M_INFO,
"spike_detector::calibrate",
String::compose(
"Precise neuron models exist: the property precise_times "
"of the %1 with gid %2 has been set to true, precision has "
"been set to %3",
get_name(),
get_gid(),
precision ) );
}
}

device_.calibrate();
Expand Down Expand Up @@ -141,6 +161,9 @@ nest::spike_detector::set_status( const DictionaryDatum& d )
if ( d->known( names::precise_times ) )
user_set_precise_times_ = true;

if ( d->known( names::precision ) )
user_set_precision_value = getValue< long >( d, names::precision );

device_.set_status( d );
}

Expand Down
1 change: 1 addition & 0 deletions models/spike_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class spike_detector : public Node
Buffers_ B_;

bool user_set_precise_times_;
long user_set_precision_value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_set_precision_value is a private member. Therefore, the name should end in a _.

bool has_proxies_;
bool local_receiver_;
};
Expand Down