diff --git a/.gitignore b/.gitignore index 1ead4785c0..05dcad0c5c 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ doc/normaldoc.conf lib/sli/rcsinfo.sli extras/emacs/sli.el extras/nest_vars.sh + diff --git a/nestkernel/conn_builder.cpp b/nestkernel/conn_builder.cpp index df91d0d651..530b7f323b 100644 --- a/nestkernel/conn_builder.cpp +++ b/nestkernel/conn_builder.cpp @@ -462,6 +462,13 @@ nest::ConnBuilder::single_connect_( index sgid, thread target_thread, librandom::RngPtr& rng ) { + if ( this->requires_proxies() and not target.has_proxies() ) + { + throw IllegalConnection( + "Cannot use this rule to connect to nodes" + " without proxies (usually devices)." ); + } + if ( param_dicts_.empty() ) // indicates we have no synapse params { if ( default_weight_and_delay_ ) diff --git a/nestkernel/conn_builder.h b/nestkernel/conn_builder.h index 9577aa04b7..c63a241890 100644 --- a/nestkernel/conn_builder.h +++ b/nestkernel/conn_builder.h @@ -119,6 +119,13 @@ class ConnBuilder return false; } + //! Return true if rule is applicable only to nodes with proxies + virtual bool + requires_proxies() const + { + return true; + } + protected: //! Implements the actual connection algorithm virtual void connect_() = 0; @@ -248,6 +255,12 @@ class OneToOneBuilder : public ConnBuilder return true; } + bool + requires_proxies() const + { + return false; + } + protected: void connect_(); void sp_connect_(); @@ -272,6 +285,12 @@ class AllToAllBuilder : public ConnBuilder return *sources_ == *targets_ && all_parameters_scalar_(); } + bool + requires_proxies() const + { + return false; + } + protected: void connect_(); void sp_connect_(); diff --git a/testsuite/regressiontests/issue-351.sli b/testsuite/regressiontests/issue-351.sli new file mode 100644 index 0000000000..ae40237a4e --- /dev/null +++ b/testsuite/regressiontests/issue-351.sli @@ -0,0 +1,82 @@ +/* + * issue-351.sli + * + * This file is part of NEST. + * + * Copyright (C) 2004 The NEST Initiative + * + * NEST is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * NEST is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NEST. If not, see . + * + */ + +/* BeginDocumentation + +Name: testsuite::issue-351 Ensure Connect raises exception if connecting to device with unusable rule + +Synopsis: (issue-351) run -> NEST exits if test fails + +Description: +This test makes sure that connections to devices without proxies are +prohibited for probabilistic connection rules. + +Author: Hans Ekkehard Plesser, 2016-11-22 + */ + +(unittest) run +/unittest using + +M_ERROR setverbosity + +/prob_rules +[ + << /rule /fixed_indegree /indegree 1 >> + << /rule /fixed_outdegree /outdegree 1 >> + << /rule /fixed_total_number /N 1 >> + << /rule /pairwise_bernoulli /p 1.0 >> +] def + +/skip_list [ /multimeter /voltmeter % inverse order + /weight_recorder % attaches to synapses + /correlation_detector % has proxies + /correlomatrix_detector % has proxies + /spin_detector % binary recorders + /correlospinmatrix_detector + ] def + +modeldict keys +{ + /model Set + model GetDefaults /element_type get /recorder eq + skip_list model MemberQ not and + { + prob_rules + { + /ruledict Set + (Testing ) =only model =only ( ) =only ruledict/rule :: = + { + ResetKernel + 1 /iaf_psc_alpha Create cvgidcollection + 2 model Create cvgidcollection + ruledict Connect + } + fail_or_die + clear + } + forall + } + if +} +forall + +endusing \ No newline at end of file