/*
 *  test_divergent_connect.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 <http://www.gnu.org/licenses/>.
 *
 */


/* BeginDocumentation
   Name: testsuite::test_divergent_connect - sli script to test the DivergentConnect function.

   Synopsis: (test_divergent_connect) run -> compare response with reference data

   Description:
   Tests the use of the DivergentConnect function by using all variant
   of the function and comparing the result to the expected result.

   FirstVersion: 03/2009
   Author: Jochen Martin Eppler
   SeeAlso: DivergentConnect, testsuite::test_random_divergent_connect, testsuite::test_convergent_connect
 */

/unittest (8093) require
/unittest using

0.1 /h Set
0.1 /c Set
10 /n Set

ResetKernel

% Set settings for root network. These
% settings could be changed to test different
% aspects of simulation.
0 <<
      /local_num_threads 2
      /resolution h
    >> SetStatus

% Create some target neurons.
/iaf_neuron n Create ;

% Get list of neuron IDs.
[n] Range /t Set

% Create a different source node for each variant.
/dc_generator Create /dc1 Set
/dc_generator Create /dc2 Set
/dc_generator Create /dc3 Set
/dc_generator Create /dc4 Set

% test "source targets" variant
dc1 t DivergentConnect
<< /source dc1 /synapse_model /static_synapse >> FindConnections
{ GetStatus } Map { /target get } Map
Sort t eq assert_or_die

% test "source targets synmodel" variant
dc2 t /static_synapse DivergentConnect
<< /source dc2 /synapse_model /static_synapse >> FindConnections
{ GetStatus } Map { /target get } Map
Sort t eq assert_or_die

[n] Range {cvd} Map /w Set
n array 1 add {cvd} Map /d Set

% test "source targets weights delays" variant
dc3 t w d DivergentConnect
<< /source dc3 /synapse_model /static_synapse >> FindConnections
{ GetStatus } Map { /weight get } Map
Sort w eq assert_or_die

% test "source targets weights delays synmodel" variant
dc4 t w d /static_synapse DivergentConnect
<< /source dc4 /synapse_model /static_synapse >> FindConnections
{ GetStatus } Map { /weight get } Map
Sort w eq assert_or_die

endusing