diff --git a/.travis.yml b/.travis.yml index e5aec152..7c849bcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,6 @@ script: notifications: email: recipients: - - friedemann.zenke@cncb.ox.ac.uk + - fzenke@gmail.com on_success: change on_failure: always diff --git a/AUTHORS b/AUTHORS index 3b33aff3..7bae4ae9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,17 +1,17 @@ -Auryn package created by Friedemann Zenke +Auryn package created by Friedemann Zenke Contributors: Lorric Ziegler Ankur Sinha Emre Neftci +Anders Lansner +Alexandre Payeur - - -Copyright 2014-2018 Friedemann Zenke. +Copyright 2014-2023 Friedemann Zenke. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. diff --git a/CMakeLists.txt b/CMakeLists.txt index a01fef80..eb9a49cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) PROJECT(Auryn) # The version number. -SET(Auryn_VERSION_MAJOR 0) +SET(Auryn_VERSION_MAJOR 1) SET(Auryn_VERSION_MINOR 8) # Important GCC Compiler flags for Auryn's performance diff --git a/README.md b/README.md index a2058956..cbe9a6d4 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Bibtex: License & Copyright ------------------- -Copyright 2014-2018 Friedemann Zenke +Copyright 2014-2023 Friedemann Zenke Auryn is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/build/release/run_benchmark.sh b/build/release/run_benchmark.sh index 686a9556..ce268329 100755 --- a/build/release/run_benchmark.sh +++ b/build/release/run_benchmark.sh @@ -13,6 +13,8 @@ DATE=`date +"%Y-%m-%d"` # REVISION=`git log --pretty=oneline -1 | cut -d " " -f 1` REVISION=`git describe` TMPDIR=`mktemp -d` +echo "temp dir= $TMPDIR" +trap "{ rm -rf $TMPDIR; }" EXIT # Function declaration function fun_benchmark() @@ -39,12 +41,12 @@ fun_benchmark "$CMD_BENCHMARK1" RESULT_BENCHMARK1=$FUNCTION_RESULT # Zenke plasticity benchmark, single core -CMD_BENCHMARK2="examples/sim_background --fast --tau 10 --simtime $SIMTIME --dir $TMPDIR" +CMD_BENCHMARK2="examples/plasticity/sim_background --fast --tau 10 --simtime $SIMTIME --dir $TMPDIR" fun_benchmark "$CMD_BENCHMARK2" RESULT_BENCHMARK2=$FUNCTION_RESULT # Zenke plasticity benchmark, two cores -CMD_BENCHMARK3="mpirun -n 2 examples/sim_background --fast --tau 10 --simtime $SIMTIME --dir $TMPDIR" +CMD_BENCHMARK3="mpirun -n 2 examples/plasticity/sim_background --fast --tau 10 --simtime $SIMTIME --dir $TMPDIR" fun_benchmark "$CMD_BENCHMARK3" RESULT_BENCHMARK3=$FUNCTION_RESULT @@ -52,5 +54,3 @@ RESULT_BENCHMARK3=$FUNCTION_RESULT # Writ result to file echo "$HOSTNAME $REVISION $RESULT_BENCHMARK1 $RESULT_BENCHMARK2 $RESULT_BENCHMARK3 $DATE" >> benchmark_results.dat -# Clean up -rm -r $TMPDIR diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f947fb77..04740030 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,10 @@ +ADD_SUBDIRECTORY(currents) +ADD_SUBDIRECTORY(misc) +ADD_SUBDIRECTORY(plasticity) +ADD_SUBDIRECTORY(poisson) +ADD_SUBDIRECTORY(tutorials) +ADD_SUBDIRECTORY(monitoring) + FILE( GLOB SIM_SOURCES *.cpp ) FOREACH( sourcepath ${SIM_SOURCES} ) GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) diff --git a/examples/currents/CMakeLists.txt b/examples/currents/CMakeLists.txt new file mode 100644 index 00000000..7da8591a --- /dev/null +++ b/examples/currents/CMakeLists.txt @@ -0,0 +1,9 @@ +FILE( GLOB SIM_SOURCES *.cpp ) +FOREACH( sourcepath ${SIM_SOURCES} ) + GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) + STRING( REPLACE ".cpp" "" simname ${sourcefile} ) + ADD_EXECUTABLE( ${simname} ${sourcefile} ) + TARGET_LINK_LIBRARIES( ${simname} auryn ${AURYN_EXT_LINKLIBS} ) +ENDFOREACH( sourcepath ${SIM_SOURCES} ) + +CONFIGURE_FILE(inject_current.txt inject_current.txt COPYONLY) diff --git a/examples/currents/inject_current.txt b/examples/currents/inject_current.txt new file mode 100644 index 00000000..d1e98be7 --- /dev/null +++ b/examples/currents/inject_current.txt @@ -0,0 +1,100 @@ +0.000000 0.000000 +0.050000 0.125333 +0.100000 0.248690 +0.150000 0.368125 +0.200000 0.481754 +0.250000 0.587785 +0.300000 0.684547 +0.350000 0.770513 +0.400000 0.844328 +0.450000 0.904827 +0.500000 0.951057 +0.550000 0.982287 +0.600000 0.998027 +0.650000 0.998027 +0.700000 0.982287 +0.750000 0.951057 +0.800000 0.904827 +0.850000 0.844328 +0.900000 0.770513 +0.950000 0.684547 +1.000000 0.587785 +1.050000 0.481754 +1.100000 0.368125 +1.150000 0.248690 +1.200000 0.125333 +1.250000 0.000000 +1.300000 -0.125333 +1.350000 -0.248690 +1.400000 -0.368125 +1.450000 -0.481754 +1.500000 -0.587785 +1.550000 -0.684547 +1.600000 -0.770513 +1.650000 -0.844328 +1.700000 -0.904827 +1.750000 -0.951057 +1.800000 -0.982287 +1.850000 -0.998027 +1.900000 -0.998027 +1.950000 -0.982287 +2.000000 -0.951057 +2.050000 -0.904827 +2.100000 -0.844328 +2.150000 -0.770513 +2.200000 -0.684547 +2.250000 -0.587785 +2.300000 -0.481754 +2.350000 -0.368125 +2.400000 -0.248690 +2.450000 -0.125333 +2.500000 -0.000000 +2.550000 0.125333 +2.600000 0.248690 +2.650000 0.368125 +2.700000 0.481754 +2.750000 0.587785 +2.800000 0.684547 +2.850000 0.770513 +2.900000 0.844328 +2.950000 0.904827 +3.000000 0.951057 +3.050000 0.982287 +3.100000 0.998027 +3.150000 0.998027 +3.200000 0.982287 +3.250000 0.951057 +3.300000 0.904827 +3.350000 0.844328 +3.400000 0.770513 +3.450000 0.684547 +3.500000 0.587785 +3.550000 0.481754 +3.600000 0.368125 +3.650000 0.248690 +3.700000 0.125333 +3.750000 0.000000 +3.800000 -0.125333 +3.850000 -0.248690 +3.900000 -0.368125 +3.950000 -0.481754 +4.000000 -0.587785 +4.050000 -0.684547 +4.100000 -0.770513 +4.150000 -0.844328 +4.200000 -0.904827 +4.250000 -0.951057 +4.300000 -0.982287 +4.350000 -0.998027 +4.400000 -0.998027 +4.450000 -0.982287 +4.500000 -0.951057 +4.550000 -0.904827 +4.600000 -0.844328 +4.650000 -0.770513 +4.700000 -0.684547 +4.750000 -0.587785 +4.800000 -0.481754 +4.850000 -0.368125 +4.900000 -0.248690 +4.950000 -0.125333 diff --git a/examples/sim_current_inject.cpp b/examples/currents/sim_current_inject.cpp similarity index 97% rename from examples/sim_current_inject.cpp rename to examples/currents/sim_current_inject.cpp index 3a477cc8..7bafaf70 100644 --- a/examples/sim_current_inject.cpp +++ b/examples/currents/sim_current_inject.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_current_steps.cpp b/examples/currents/sim_current_steps.cpp similarity index 98% rename from examples/sim_current_steps.cpp rename to examples/currents/sim_current_steps.cpp index d23d36e7..046ba841 100644 --- a/examples/sim_current_steps.cpp +++ b/examples/currents/sim_current_steps.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_current_stim.cpp b/examples/currents/sim_current_stim.cpp similarity index 98% rename from examples/sim_current_stim.cpp rename to examples/currents/sim_current_stim.cpp index 6eea5c1b..39b3c2d0 100644 --- a/examples/sim_current_stim.cpp +++ b/examples/currents/sim_current_stim.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/currents/sim_file_current_inject.cpp b/examples/currents/sim_file_current_inject.cpp new file mode 100644 index 00000000..244d6b6a --- /dev/null +++ b/examples/currents/sim_file_current_inject.cpp @@ -0,0 +1,77 @@ +/* +* Copyright 2014-2020 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +*/ + +#include "auryn.h" + +#define N 1 + +/*!\file + * + * \brief Example simulation which demonstrates the use of FileCurrentInjector + * */ + +using namespace auryn; + +namespace po = boost::program_options; + +int main(int ac, char* av[]) +{ + + int errcode = 0; + string simname = "fcur_inject"; + string logfile = simname; + string tmpstr; + + // BEGIN Global definitions + auryn_init( ac, av ); + sys->set_simulation_name(simname); + // END Global definitions + + // define receiving group + IFGroup * neurons = new IFGroup(3); + + // define monitors + VoltageMonitor * vmon0 = new VoltageMonitor( neurons, 0, sys->fn("neuron",0,"mem"), 1e-3 ); + VoltageMonitor * vmon1 = new VoltageMonitor( neurons, 1, sys->fn("neuron",1,"mem"), 1e-3 ); + + // define FileCurrentInjector + FileCurrentInjector * injector = new FileCurrentInjector( neurons, "inject_current.txt", "mem" ); + injector->set_scale(1.2); // Scales all current values by this factor + + // To repeat the input current enable looping by uncommenting the following lines + // injector->loop = true; + // injector->set_loop_grid(10.0); // align time series to 1s grid (should be larger or equal to the input time series) + + // To only inject current in some neurons uncomment the following code + // injector->mode = LIST; + // injector->target_neuron_ids->push_back(0); + // injector->target_neuron_ids->push_back(2); + + // run simulation + logger->msg("Running ...",PROGRESS); + sys->run(15.0); + + if (errcode) + auryn_abort(errcode); + + logger->msg("Freeing ...",PROGRESS,true); + auryn_free(); + return errcode; +} diff --git a/examples/misc/CMakeLists.txt b/examples/misc/CMakeLists.txt new file mode 100644 index 00000000..f947fb77 --- /dev/null +++ b/examples/misc/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE( GLOB SIM_SOURCES *.cpp ) +FOREACH( sourcepath ${SIM_SOURCES} ) + GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) + STRING( REPLACE ".cpp" "" simname ${sourcefile} ) + ADD_EXECUTABLE( ${simname} ${sourcefile} ) + TARGET_LINK_LIBRARIES( ${simname} auryn ${AURYN_EXT_LINKLIBS} ) +ENDFOREACH( sourcepath ${SIM_SOURCES} ) + diff --git a/examples/misc/sim_delay_connection.cpp b/examples/misc/sim_delay_connection.cpp new file mode 100644 index 00000000..5d283747 --- /dev/null +++ b/examples/misc/sim_delay_connection.cpp @@ -0,0 +1,78 @@ +/* +* Copyright 2014-2020 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +*/ + +#include "auryn.h" + +#define N 1 + +/*!\file + * + * \brief Example simulation illustrating the effect of delay connection. + * + * The simulation sets up a single input neuron and connects it to a single output neuron via a SparseConnection + * (which only has the axonal delay from IFGroup) and via a DelayConnection which has both the axonal delay plus + * an added 10ms dendritic delay. The latter connection is GABAergic to make it easily differntiable in the + * membrane trace. + * */ + +using namespace auryn; + +int main(int ac, char* av[]) +{ + + int errcode = 0; + string simname = "delay_connection"; + string logfile = simname; + string tmpstr; + AurynWeight w = 1.0; + + // BEGIN Global definitions + auryn_init( ac, av ); + sys->set_simulation_name(simname); + // END Global definitions + + // define input group + PoissonGroup * poisson = new PoissonGroup(N,1.); + + // define receiving group + IFGroup * neuron = new IFGroup(1); + + // define connections + SparseConnection * con = new SparseConnection(poisson, neuron, w, 1.0, GLUT); + DelayConnection * dly_con = new DelayConnection(poisson, neuron, w, 1.0, GABA); + dly_con->set_delay(10e-3); // 10ms delay added + + // define monitors + SpikeMonitor * smon = new SpikeMonitor( neuron, sys->fn("ras") ); + VoltageMonitor * vmon = new VoltageMonitor( neuron, 0, sys->fn("mem"), 1e-3 ); + StateMonitor * amon = new StateMonitor( neuron, 0, "g_ampa", sys->fn("ampa") ); + StateMonitor * nmon = new StateMonitor( neuron, 0, "g_gaba", sys->fn("gaba") ); + + // run simulation + logger->msg("Running ...",PROGRESS); + sys->run(10); + + if (errcode) + auryn_abort(errcode); + + logger->msg("Freeing ...",PROGRESS,true); + auryn_free(); + return errcode; +} diff --git a/examples/sim_epsp.cpp b/examples/misc/sim_epsp.cpp similarity index 98% rename from examples/sim_epsp.cpp rename to examples/misc/sim_epsp.cpp index 56fa86f9..9a58bc62 100644 --- a/examples/sim_epsp.cpp +++ b/examples/misc/sim_epsp.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_epsp_binmon.cpp b/examples/misc/sim_epsp_binmon.cpp similarity index 98% rename from examples/sim_epsp_binmon.cpp rename to examples/misc/sim_epsp_binmon.cpp index 2c2cdb1b..a878989d 100644 --- a/examples/sim_epsp_binmon.cpp +++ b/examples/misc/sim_epsp_binmon.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_epsp_stp.cpp b/examples/misc/sim_epsp_stp.cpp similarity index 98% rename from examples/sim_epsp_stp.cpp rename to examples/misc/sim_epsp_stp.cpp index da23da28..680c6f7e 100644 --- a/examples/sim_epsp_stp.cpp +++ b/examples/misc/sim_epsp_stp.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_parrot.cpp b/examples/misc/sim_parrot.cpp similarity index 99% rename from examples/sim_parrot.cpp rename to examples/misc/sim_parrot.cpp index f1da8ccb..dbb2ffcd 100644 --- a/examples/sim_parrot.cpp +++ b/examples/misc/sim_parrot.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2019 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/monitoring/CMakeLists.txt b/examples/monitoring/CMakeLists.txt new file mode 100644 index 00000000..f947fb77 --- /dev/null +++ b/examples/monitoring/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE( GLOB SIM_SOURCES *.cpp ) +FOREACH( sourcepath ${SIM_SOURCES} ) + GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) + STRING( REPLACE ".cpp" "" simname ${sourcefile} ) + ADD_EXECUTABLE( ${simname} ${sourcefile} ) + TARGET_LINK_LIBRARIES( ${simname} auryn ${AURYN_EXT_LINKLIBS} ) +ENDFOREACH( sourcepath ${SIM_SOURCES} ) + diff --git a/examples/monitoring/sim_multi_state_monitor.cpp b/examples/monitoring/sim_multi_state_monitor.cpp new file mode 100644 index 00000000..c6d8999a --- /dev/null +++ b/examples/monitoring/sim_multi_state_monitor.cpp @@ -0,0 +1,217 @@ +/* +* Copyright 2014-2020 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +*/ + +/*!\file + * + * \brief Simulation code for the Vogels Abbott benchmark following Brette et al. (2007) + * + * This simulation implements the Vogels Abbott benchmark as suggested by + * Brette et al. (2007) Journal of Computational Neuroscience 23: 349-398. + * + * The network is based on a network by Vogels and Abbott as described in + * Vogels, T.P., and Abbott, L.F. (2005). Signal propagation and logic gating + * in networks of integrate-and-fire neurons. J Neurosci 25, 10786. + * + * We used this network for benchmarking Auryn against other simulators in + * Zenke, F., and Gerstner, W. (2014). Limits to high-speed simulations of + * spiking neural networks using general-purpose computers. Front Neuroinform + * 8, 76. + * + * See build/release/run_benchmark.sh for automatically run benchmarks to + * compare the performance of different Auryn builds. + * + * */ + +#include "auryn.h" + +using namespace auryn; + +namespace po = boost::program_options; + +int main(int ac,char *av[]) { + string dir = "/tmp"; + + string fwmat_ee = ""; + string fwmat_ei = ""; + string fwmat_ie = ""; + string fwmat_ii = ""; + + std::stringstream oss; + string strbuf ; + string msg; + + double w = 0.4; // [g_leak] + double wi = 5.1; // [g_leak] + + + + double sparseness = 0.02; + double simtime = 5.; + + NeuronID ne = 3200; + NeuronID ni = 800; + + bool fast = false; + + int errcode = 0; + + + try { + + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + ("simtime", po::value(), "simulation time") + ("dir", po::value(), "load/save directory") + ("fee", po::value(), "file with EE connections") + ("fei", po::value(), "file with EI connections") + ("fie", po::value(), "file with IE connections") + ("fii", po::value(), "file with II connections") + ; + + po::variables_map vm; + po::store(po::parse_command_line(ac, av, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + if (vm.count("simtime")) { + simtime = vm["simtime"].as(); + } + + if (vm.count("dir")) { + dir = vm["dir"].as(); + } + + if (vm.count("fee")) { + fwmat_ee = vm["fee"].as(); + } + + if (vm.count("fie")) { + fwmat_ie = vm["fie"].as(); + } + + if (vm.count("fei")) { + fwmat_ei = vm["fei"].as(); + } + + if (vm.count("fii")) { + fwmat_ii = vm["fii"].as(); + } + + } + catch(std::exception& e) { + std::cerr << "error: " << e.what() << "\n"; + return 1; + } + catch(...) { + std::cerr << "Exception of unknown type!\n"; + } + + + auryn_init( ac, av, dir ); + oss << dir << "/coba." << sys->mpi_rank() << "."; + string outputfile = oss.str(); + + logger->set_logfile_loglevel(INFO); + + + logger->msg("Setting up neuron groups ...",PROGRESS,true); + + TIFGroup * neurons_e = new TIFGroup( ne); + TIFGroup * neurons_i = new TIFGroup( ni); + + neurons_e->set_refractory_period(5.0e-3); // minimal ISI 5.1ms + neurons_i->set_refractory_period(5.0e-3); + + neurons_e->set_state("bg_current",2e-2); // corresponding to 200pF for C=200pF and tau=20ms + neurons_i->set_state("bg_current",2e-2); + + + logger->msg("Setting up E connections ...",PROGRESS,true); + + SparseConnection * con_ee + = new SparseConnection( neurons_e,neurons_e, w, sparseness, GLUT); + + SparseConnection * con_ei + = new SparseConnection( neurons_e,neurons_i, w,sparseness,GLUT); + + + + logger->msg("Setting up I connections ...",PROGRESS,true); + SparseConnection * con_ie + = new SparseConnection( neurons_i,neurons_e,wi,sparseness,GABA); + + SparseConnection * con_ii + = new SparseConnection( neurons_i,neurons_i,wi,sparseness,GABA); + + if ( !fwmat_ee.empty() ) con_ee->load_from_complete_file(fwmat_ee); + if ( !fwmat_ei.empty() ) con_ei->load_from_complete_file(fwmat_ei); + if ( !fwmat_ie.empty() ) con_ie->load_from_complete_file(fwmat_ie); + if ( !fwmat_ii.empty() ) con_ii->load_from_complete_file(fwmat_ii); + + + + + msg = "Setting up monitors ..."; + logger->msg(msg,PROGRESS,true); + + std::stringstream filename; + filename << outputfile << "e.ras"; + SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, filename.str().c_str() ); + + filename.str(""); + filename.clear(); + filename << outputfile << "i.ras"; + SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, filename.str().c_str() ); + + filename.str(""); + filename.clear(); + filename << outputfile << "e.mems"; + MultiStateMonitor * msmon = new MultiStateMonitor( filename.str() ); + msmon->add_neuron_range(neurons_e, "mem"); // Monitors the membrane potentials of all excitatory neurons + + + // RateChecker * chk = new RateChecker( neurons_e , -0.1 , 1000. , 100e-3); + + logger->msg("Simulating ..." ,PROGRESS,true); + if (!sys->run(simtime,true)) + errcode = 1; + + if ( sys->mpi_rank() == 0 ) { + logger->msg("Saving elapsed time ..." ,PROGRESS,true); + char filenamebuf [255]; + sprintf(filenamebuf, "%s/elapsed.dat", dir.c_str()); + std::ofstream timefile; + timefile.open(filenamebuf); + timefile << sys->get_last_elapsed_time() << std::endl; + timefile.close(); + } + + if (errcode) + auryn_abort(errcode); + + logger->msg("Freeing ..." ,PROGRESS,true); + auryn_free(); + return errcode; +} diff --git a/examples/plasticity/CMakeLists.txt b/examples/plasticity/CMakeLists.txt new file mode 100644 index 00000000..f947fb77 --- /dev/null +++ b/examples/plasticity/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE( GLOB SIM_SOURCES *.cpp ) +FOREACH( sourcepath ${SIM_SOURCES} ) + GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) + STRING( REPLACE ".cpp" "" simname ${sourcefile} ) + ADD_EXECUTABLE( ${simname} ${sourcefile} ) + TARGET_LINK_LIBRARIES( ${simname} auryn ${AURYN_EXT_LINKLIBS} ) +ENDFOREACH( sourcepath ${SIM_SOURCES} ) + diff --git a/examples/sim_background.cpp b/examples/plasticity/sim_background.cpp similarity index 99% rename from examples/sim_background.cpp rename to examples/plasticity/sim_background.cpp index f0c6582f..811fb911 100644 --- a/examples/sim_background.cpp +++ b/examples/plasticity/sim_background.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -491,7 +491,7 @@ int main(int ac, char* av[]) auryn_init(ac, av, dir, "sim_background", logfile_prefix); - logger->set_logfile_loglevel( PROGRESS ); + logger->set_logfile_loglevel( INFO ); if ( verbose ) logger->set_logfile_loglevel( EVERYTHING ); diff --git a/examples/sim_bg_lowpass.cpp b/examples/plasticity/sim_bg_lowpass.cpp similarity index 99% rename from examples/sim_bg_lowpass.cpp rename to examples/plasticity/sim_bg_lowpass.cpp index b57bb83e..8440f582 100644 --- a/examples/sim_bg_lowpass.cpp +++ b/examples/plasticity/sim_bg_lowpass.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_bg_scaling.cpp b/examples/plasticity/sim_bg_scaling.cpp similarity index 99% rename from examples/sim_bg_scaling.cpp rename to examples/plasticity/sim_bg_scaling.cpp index 1bed58a3..8d9bc06a 100644 --- a/examples/sim_bg_scaling.cpp +++ b/examples/plasticity/sim_bg_scaling.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_bg_scaling2.cpp b/examples/plasticity/sim_bg_scaling2.cpp similarity index 99% rename from examples/sim_bg_scaling2.cpp rename to examples/plasticity/sim_bg_scaling2.cpp index d104765b..6dba152f 100644 --- a/examples/sim_bg_scaling2.cpp +++ b/examples/plasticity/sim_bg_scaling2.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_bg_static.cpp b/examples/plasticity/sim_bg_static.cpp similarity index 99% rename from examples/sim_bg_static.cpp rename to examples/plasticity/sim_bg_static.cpp index dc743106..734a1673 100644 --- a/examples/sim_bg_static.cpp +++ b/examples/plasticity/sim_bg_static.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_isp_big.cpp b/examples/plasticity/sim_isp_big.cpp similarity index 99% rename from examples/sim_isp_big.cpp rename to examples/plasticity/sim_isp_big.cpp index f1cd78a5..94530add 100644 --- a/examples/sim_isp_big.cpp +++ b/examples/plasticity/sim_isp_big.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_isp_orig.cpp b/examples/plasticity/sim_isp_orig.cpp similarity index 99% rename from examples/sim_isp_orig.cpp rename to examples/plasticity/sim_isp_orig.cpp index f1ce54e9..6d71c7c3 100644 --- a/examples/sim_isp_orig.cpp +++ b/examples/plasticity/sim_isp_orig.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_stdp.cpp b/examples/plasticity/sim_stdp.cpp similarity index 99% rename from examples/sim_stdp.cpp rename to examples/plasticity/sim_stdp.cpp index 6b850262..d9279885 100644 --- a/examples/sim_stdp.cpp +++ b/examples/plasticity/sim_stdp.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_stim_homtriplet.cpp b/examples/plasticity/sim_stim_homtriplet.cpp similarity index 99% rename from examples/sim_stim_homtriplet.cpp rename to examples/plasticity/sim_stim_homtriplet.cpp index 20f67fe8..aca3ec72 100644 --- a/examples/sim_stim_homtriplet.cpp +++ b/examples/plasticity/sim_stim_homtriplet.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_stim_scaling.cpp b/examples/plasticity/sim_stim_scaling.cpp similarity index 99% rename from examples/sim_stim_scaling.cpp rename to examples/plasticity/sim_stim_scaling.cpp index 7b2a7150..b6d9a5fd 100644 --- a/examples/sim_stim_scaling.cpp +++ b/examples/plasticity/sim_stim_scaling.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/poisson/CMakeLists.txt b/examples/poisson/CMakeLists.txt new file mode 100644 index 00000000..f947fb77 --- /dev/null +++ b/examples/poisson/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE( GLOB SIM_SOURCES *.cpp ) +FOREACH( sourcepath ${SIM_SOURCES} ) + GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) + STRING( REPLACE ".cpp" "" simname ${sourcefile} ) + ADD_EXECUTABLE( ${simname} ${sourcefile} ) + TARGET_LINK_LIBRARIES( ${simname} auryn ${AURYN_EXT_LINKLIBS} ) +ENDFOREACH( sourcepath ${SIM_SOURCES} ) + diff --git a/examples/sim_poisson.cpp b/examples/poisson/sim_poisson.cpp similarity index 98% rename from examples/sim_poisson.cpp rename to examples/poisson/sim_poisson.cpp index c8fb6442..6f5bf4f3 100644 --- a/examples/sim_poisson.cpp +++ b/examples/poisson/sim_poisson.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/poisson/sim_poisson_bump.cpp b/examples/poisson/sim_poisson_bump.cpp new file mode 100644 index 00000000..91aa5fbc --- /dev/null +++ b/examples/poisson/sim_poisson_bump.cpp @@ -0,0 +1,145 @@ +/* +* Copyright 2014-2020 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +*/ + + +/*!\file + * + * \brief Example simulation which simulates a Poisson moving bump input + */ + +#include "auryn.h" + +using namespace auryn; + +namespace po = boost::program_options; + +int main(int ac, char* av[]) +{ + + string dir = "./"; + string file_prefix = "poisson"; + + char strbuf [255]; + string msg; + + NeuronID size = 1000; + unsigned int seed = 1; + double width = 0.05; + double duration = 0.1; + double kappa = 5.; + double simtime = 1.; + + int errcode = 0; + + try { + + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + ("simtime", po::value(), "simulation time") + ("duration", po::value(), "bump duration in s") + ("width", po::value(), "bump width as stdev in relative units of population size") + ("kappa", po::value(), "poisson group rate") + ("dir", po::value(), "output directory") + ("size", po::value(), "poisson group size") + ("seed", po::value(), "random seed") + ; + + po::variables_map vm; + po::store(po::parse_command_line(ac, av, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + if (vm.count("kappa")) { + std::cout << "kappa set to " + << vm["kappa"].as() << ".\n"; + kappa = vm["kappa"].as(); + } + + if (vm.count("duration")) { + std::cout << "duration set to " + << vm["duration"].as() << ".\n"; + duration = vm["duration"].as(); + } + + if (vm.count("width")) { + std::cout << "width set to " + << vm["width"].as() << ".\n"; + width = vm["width"].as(); + } + + if (vm.count("dir")) { + std::cout << "dir set to " + << vm["dir"].as() << ".\n"; + dir = vm["dir"].as(); + } + + if (vm.count("simtime")) { + std::cout << "simtime set to " + << vm["simtime"].as() << ".\n"; + simtime = vm["simtime"].as(); + } + + if (vm.count("size")) { + std::cout << "size set to " + << vm["size"].as() << ".\n"; + size = vm["size"].as(); + } + + if (vm.count("seed")) { + std::cout << "seed set to " + << vm["seed"].as() << ".\n"; + seed = vm["seed"].as(); + } + } + catch(std::exception& e) { + std::cerr << "error: " << e.what() << "\n"; + return 1; + } + catch(...) { + std::cerr << "Exception of unknown type!\n"; + } + + auryn_init(ac, av); + sys->set_master_seed(seed); + + MovingBumpGroup * input_group = new MovingBumpGroup(size, duration, width, kappa); + + sprintf(strbuf, "%s/%s.%d.ras", dir.c_str(), file_prefix.c_str(), sys->mpi_rank() ); + SpikeMonitor * smon_e = new SpikeMonitor( input_group, strbuf, size); + + sprintf(strbuf, "%s/%s.%d.prate", dir.c_str(), file_prefix.c_str(), sys->mpi_rank() ); + PopulationRateMonitor * pmon_e = new PopulationRateMonitor( input_group, strbuf, 1.0 ); + + RateChecker * chk = new RateChecker( input_group , -1 , 20.*kappa , 10); + if (!sys->run(simtime,false)) + errcode = 1; + + + if (errcode) + auryn_abort(errcode); + logger->msg("Freeing ...",PROGRESS,true); + auryn_free(); + return errcode; +} diff --git a/examples/sim_poisson_input.cpp b/examples/poisson/sim_poisson_input.cpp similarity index 98% rename from examples/sim_poisson_input.cpp rename to examples/poisson/sim_poisson_input.cpp index 35067daf..32553b3e 100644 --- a/examples/sim_poisson_input.cpp +++ b/examples/poisson/sim_poisson_input.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_2comp_input.cpp b/examples/sim_2comp_input.cpp index ae543f7c..93889792 100644 --- a/examples/sim_2comp_input.cpp +++ b/examples/sim_2comp_input.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_2comp_neuron.cpp b/examples/sim_2comp_neuron.cpp index 0e22b97d..fce30d27 100644 --- a/examples/sim_2comp_neuron.cpp +++ b/examples/sim_2comp_neuron.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_brunel2k.cpp b/examples/sim_brunel2k.cpp index 2460578e..c10e49b8 100644 --- a/examples/sim_brunel2k.cpp +++ b/examples/sim_brunel2k.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_brunel2k_pl.cpp b/examples/sim_brunel2k_pl.cpp index 9a45a4b0..d7905d10 100644 --- a/examples/sim_brunel2k_pl.cpp +++ b/examples/sim_brunel2k_pl.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_coba_benchmark.cpp b/examples/sim_coba_benchmark.cpp index 2e6e0ad4..0d16215f 100644 --- a/examples/sim_coba_benchmark.cpp +++ b/examples/sim_coba_benchmark.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -139,6 +139,8 @@ int main(int ac,char *av[]) { string outputfile = oss.str(); if ( fast ) sys->quiet = true; + logger->set_logfile_loglevel(INFO); + logger->msg("Setting up neuron groups ...",PROGRESS,true); diff --git a/examples/sim_coba_binmon.cpp b/examples/sim_coba_binmon.cpp index 8b125385..2fd9bcb6 100644 --- a/examples/sim_coba_binmon.cpp +++ b/examples/sim_coba_binmon.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_dense.cpp b/examples/sim_dense.cpp index a71ce881..1cc5d930 100644 --- a/examples/sim_dense.cpp +++ b/examples/sim_dense.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_inputchannels.cpp b/examples/sim_inputchannels.cpp index c9d3de23..64517bcb 100644 --- a/examples/sim_inputchannels.cpp +++ b/examples/sim_inputchannels.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_srm0_steps.cpp b/examples/sim_srm0_steps.cpp index 340e5f3d..ebc62cea 100644 --- a/examples/sim_srm0_steps.cpp +++ b/examples/sim_srm0_steps.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_step_current.cpp b/examples/sim_step_current.cpp index 97aaa334..c3cdaded 100644 --- a/examples/sim_step_current.cpp +++ b/examples/sim_step_current.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/tutorials/CMakeLists.txt b/examples/tutorials/CMakeLists.txt new file mode 100644 index 00000000..f947fb77 --- /dev/null +++ b/examples/tutorials/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE( GLOB SIM_SOURCES *.cpp ) +FOREACH( sourcepath ${SIM_SOURCES} ) + GET_FILENAME_COMPONENT( sourcefile ${sourcepath} NAME ) + STRING( REPLACE ".cpp" "" simname ${sourcefile} ) + ADD_EXECUTABLE( ${simname} ${sourcefile} ) + TARGET_LINK_LIBRARIES( ${simname} auryn ${AURYN_EXT_LINKLIBS} ) +ENDFOREACH( sourcepath ${SIM_SOURCES} ) + diff --git a/examples/sim_tutorial1.cpp b/examples/tutorials/sim_tutorial1.cpp similarity index 98% rename from examples/sim_tutorial1.cpp rename to examples/tutorials/sim_tutorial1.cpp index d40e13cf..7f14a277 100644 --- a/examples/sim_tutorial1.cpp +++ b/examples/tutorials/sim_tutorial1.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_tutorial2.cpp b/examples/tutorials/sim_tutorial2.cpp similarity index 98% rename from examples/sim_tutorial2.cpp rename to examples/tutorials/sim_tutorial2.cpp index 7a9f406e..b7230a7a 100644 --- a/examples/sim_tutorial2.cpp +++ b/examples/tutorials/sim_tutorial2.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/examples/sim_tutorial3.cpp b/examples/tutorials/sim_tutorial3.cpp similarity index 98% rename from examples/sim_tutorial3.cpp rename to examples/tutorials/sim_tutorial3.cpp index 563fb060..405a3372 100644 --- a/examples/sim_tutorial3.cpp +++ b/examples/tutorials/sim_tutorial3.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2020 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn.h b/src/auryn.h index a345ed79..48466cac 100644 --- a/src/auryn.h +++ b/src/auryn.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -59,6 +59,7 @@ // Connection definitions #include "auryn/Connection.h" #include "auryn/SparseConnection.h" +#include "auryn/DelayConnection.h" #include "auryn/RateModulatedConnection.h" #include "auryn/STDPConnection.h" #include "auryn/PairInteractionConnection.h" @@ -77,10 +78,12 @@ // Spiking and input group definitions #include "auryn/SpikingGroup.h" +#include "auryn/ConcatGroup.h" #include "auryn/NeuronGroup.h" #include "auryn/PoissonGroup.h" #include "auryn/PoissonSpikeInjector.h" #include "auryn/FileInputGroup.h" +#include "auryn/FileStimGroup.h" #include "auryn/FileModulatedPoissonGroup.h" #include "auryn/ParrotGroup.h" #include "auryn/StimulusGroup.h" @@ -130,6 +133,7 @@ #include "auryn/PopulationRateMonitor.h" #include "auryn/BurstRateMonitor.h" #include "auryn/StateMonitor.h" +#include "auryn/MultiStateMonitor.h" #include "auryn/WeightSumMonitor.h" #include "auryn/PatternMonitor.h" #include "auryn/WeightPatternMonitor.h" @@ -140,6 +144,8 @@ #include "auryn/NormalStimulator.h" #include "auryn/PatternStimulator.h" #include "auryn/CurrentInjector.h" +#include "auryn/FileCurrentInjector.h" +#include "auryn/VoltageClamp.h" #endif /*AURYN_H__*/ diff --git a/src/auryn/ABSConnection.cpp b/src/auryn/ABSConnection.cpp index b162ae86..d3c1894a 100644 --- a/src/auryn/ABSConnection.cpp +++ b/src/auryn/ABSConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ABSConnection.h b/src/auryn/ABSConnection.h index 74c1b33b..8a35ee60 100644 --- a/src/auryn/ABSConnection.h +++ b/src/auryn/ABSConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AIF2Group.cpp b/src/auryn/AIF2Group.cpp index 3ee537f8..b2d68140 100644 --- a/src/auryn/AIF2Group.cpp +++ b/src/auryn/AIF2Group.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -54,9 +54,7 @@ void AIF2Group::init() void AIF2Group::clear() { AIFGroup::clear(); - for (NeuronID i = 0; i < get_rank_size(); i++) { - auryn_vector_float_set (g_adapt2, i, 0.); - } + g_adapt2->set_all(0.); } diff --git a/src/auryn/AIF2Group.h b/src/auryn/AIF2Group.h index c7f52fea..d7e4f947 100644 --- a/src/auryn/AIF2Group.h +++ b/src/auryn/AIF2Group.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -49,7 +49,7 @@ class AIF2Group : public AIFGroup void free(); protected: - auryn_vector_float * g_adapt2; + AurynStateVector * g_adapt2; void calculate_scale_constants(); void integrate_linear_nmda_synapses(); diff --git a/src/auryn/AIFGroup.cpp b/src/auryn/AIFGroup.cpp index dd6419ba..6e1526d8 100644 --- a/src/auryn/AIFGroup.cpp +++ b/src/auryn/AIFGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AIFGroup.h b/src/auryn/AIFGroup.h index 13e797a9..d5d2a515 100644 --- a/src/auryn/AIFGroup.h +++ b/src/auryn/AIFGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AdExGroup.cpp b/src/auryn/AdExGroup.cpp index 5b674f32..e1b61d30 100644 --- a/src/auryn/AdExGroup.cpp +++ b/src/auryn/AdExGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Ankur Sinha and Friedemann Zenke +* Copyright 2014-2023 Ankur Sinha and Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -203,7 +203,7 @@ void AdExGroup::set_b(AurynFloat _b) void AdExGroup::set_delta_t(AurynFloat d) { - deltat = d/g_leak; + deltat = d; } void AdExGroup::set_g_leak(AurynFloat g) diff --git a/src/auryn/AdExGroup.h b/src/auryn/AdExGroup.h index 02b84f02..5e1259e8 100644 --- a/src/auryn/AdExGroup.h +++ b/src/auryn/AdExGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Ankur Sinha and Friedemann Zenke +* Copyright 2014-2023 Ankur Sinha and Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AllToAllConnection.cpp b/src/auryn/AllToAllConnection.cpp index 141ccf60..a05a2758 100644 --- a/src/auryn/AllToAllConnection.cpp +++ b/src/auryn/AllToAllConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AllToAllConnection.h b/src/auryn/AllToAllConnection.h index 5c45a080..6d851417 100644 --- a/src/auryn/AllToAllConnection.h +++ b/src/auryn/AllToAllConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AuditoryBeepGroup.cpp b/src/auryn/AuditoryBeepGroup.cpp index 67dead6a..43abf2c0 100644 --- a/src/auryn/AuditoryBeepGroup.cpp +++ b/src/auryn/AuditoryBeepGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AuditoryBeepGroup.h b/src/auryn/AuditoryBeepGroup.h index b69041a1..da97c1b0 100644 --- a/src/auryn/AuditoryBeepGroup.h +++ b/src/auryn/AuditoryBeepGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AurynDelayVector.cpp b/src/auryn/AurynDelayVector.cpp index c1905dfd..52961e10 100644 --- a/src/auryn/AurynDelayVector.cpp +++ b/src/auryn/AurynDelayVector.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AurynDelayVector.h b/src/auryn/AurynDelayVector.h index 17b5e63b..e9bb30ad 100644 --- a/src/auryn/AurynDelayVector.h +++ b/src/auryn/AurynDelayVector.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/AurynVector.cpp b/src/auryn/AurynVector.cpp index 99ad1f0e..dddcab92 100644 --- a/src/auryn/AurynVector.cpp +++ b/src/auryn/AurynVector.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -49,7 +49,7 @@ inline void sse_store( float * i, __m128 d ) #endif /* CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY */ -AurynVectorFloat::AurynVectorFloat(NeuronID n) : AurynVector(n) +AurynVectorFloat::AurynVectorFloat(NeuronID n) : AurynVector(n) { #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY // check that size is a multiple of SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS @@ -71,14 +71,14 @@ void AurynVectorFloat::resize(NeuronID new_size) super::resize(new_size); } -void AurynVectorFloat::scale(float a) +void AurynVectorFloat::scale(AurynFloat a) { #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS data[0:size:1] = a * data[0:size:1]; #else const __m128 scalar = _mm_set1_ps(a); - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk = sse_load( i ); __m128 result = _mm_mul_ps(chunk, scalar); @@ -93,16 +93,16 @@ void AurynVectorFloat::scale(float a) } -void AurynVectorFloat::saxpy(float a, AurynVectorFloat * x) +void AurynVectorFloat::saxpy(AurynFloat a, AurynVectorFloat * x) { check_size(x); #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS data[0:size:1] = a * x->data[0:x->size:1] + data[0:size:1]; #else - float * xp = x->data; + AurynFloat * xp = x->data; const __m128 alpha = _mm_set1_ps(a); - for ( float * i = data ; i < data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + for ( AurynFloat * i = data ; i < data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk = sse_load( xp ); xp += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; __m128 result = _mm_mul_ps( alpha, chunk ); @@ -120,7 +120,7 @@ void AurynVectorFloat::saxpy(float a, AurynVectorFloat * x) } -void AurynVectorFloat::clip(float min, float max) +void AurynVectorFloat::clip(AurynFloat min, AurynFloat max) { #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS @@ -134,7 +134,7 @@ void AurynVectorFloat::clip(float min, float max) #else const __m128 lo = _mm_set1_ps(min); const __m128 hi = _mm_set1_ps(max); - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk = sse_load( i ); __m128 result = _mm_min_ps(chunk, hi); @@ -160,8 +160,8 @@ void AurynVectorFloat::mul(AurynVectorFloat * v) #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS data[0:size:1] = data[0:size:1] * v->data[0:v->size:1]; #else - float * bd = v->data; - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + AurynFloat * bd = v->data; + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk_a = sse_load( i ); __m128 chunk_b = sse_load( bd ); bd+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; @@ -177,14 +177,14 @@ void AurynVectorFloat::mul(AurynVectorFloat * v) } -void AurynVectorFloat::add(float a) +void AurynVectorFloat::add(AurynFloat a) { #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS data[0:size:1] = a + data[0:size:1]; #else const __m128 scalar = _mm_set1_ps(a); - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { // _mm_prefetch((i + SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS), _MM_HINT_NTA); __m128 chunk = sse_load( i ); @@ -207,8 +207,8 @@ void AurynVectorFloat::add(AurynVectorFloat * v) #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS data[0:size:1] = data[0:size:1] + v->data[0:v->size:1]; #else - float * bd = v->data; - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + AurynFloat * bd = v->data; + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk_a = sse_load( i ); __m128 chunk_b = sse_load( bd ); bd+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; @@ -228,9 +228,9 @@ void AurynVectorFloat::sum(AurynVectorFloat * a, AurynVectorFloat * b) check_size(a); check_size(b); #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY - float * ea = a->data; - float * eb = b->data; - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + AurynFloat * ea = a->data; + AurynFloat * eb = b->data; + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk_a = sse_load( ea ); ea+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; __m128 chunk_b = sse_load( eb ); eb+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; @@ -242,13 +242,13 @@ void AurynVectorFloat::sum(AurynVectorFloat * a, AurynVectorFloat * b) #endif } -void AurynVectorFloat::sum(AurynVectorFloat * a, const float b) +void AurynVectorFloat::sum(AurynVectorFloat * a, const AurynFloat b) { check_size(a); #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY - float * ea = a->data; + AurynFloat * ea = a->data; const __m128 scalar = _mm_set1_ps(b); - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { __m128 chunk_a = sse_load( ea ); ea+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; __m128 result = _mm_add_ps(chunk_a, scalar); @@ -264,9 +264,9 @@ void AurynVectorFloat::diff(AurynVectorFloat * a, AurynVectorFloat * b) check_size(a); check_size(b); #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY - float * ea = a->data; - float * eb = b->data; - for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) + AurynFloat * ea = a->data; + AurynFloat * eb = b->data; + for ( AurynFloat * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) { const __m128 chunk_a = sse_load( ea ); ea+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; const __m128 chunk_b = sse_load( eb ); eb+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; @@ -278,20 +278,20 @@ void AurynVectorFloat::diff(AurynVectorFloat * a, AurynVectorFloat * b) #endif } -void AurynVectorFloat::diff(AurynVectorFloat * a, const float b) +void AurynVectorFloat::diff(AurynVectorFloat * a, const AurynFloat b) { check_size(a); sum(a,-b); } -void AurynVectorFloat::diff(const float a, AurynVectorFloat * b ) +void AurynVectorFloat::diff(const AurynFloat a, AurynVectorFloat * b ) { check_size(b); sum(b,-a); neg(); } -void AurynVectorFloat::follow(AurynVectorFloat * v, const float rate) +void AurynVectorFloat::follow(AurynVectorFloat * v, const AurynFloat rate) { #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY for ( NeuronID i = 0 ; i < size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS ) diff --git a/src/auryn/AurynVector.h b/src/auryn/AurynVector.h index c9923d60..3193e3f9 100644 --- a/src/auryn/AurynVector.h +++ b/src/auryn/AurynVector.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -793,10 +793,10 @@ namespace auryn { * some performance critical member functions defined in the template * with SIMD intrinsics for higher performance. */ - class AurynVectorFloat : public AurynVector + class AurynVectorFloat : public AurynVector { private: - typedef AurynVector super; + typedef AurynVector super; public: /*! \brief Default constructor */ @@ -809,19 +809,19 @@ namespace auryn { virtual void resize(NeuronID new_size); - void scale(const float a); - void saxpy(const float a, AurynVectorFloat * x); - void clip(const float min, const float max); - void add(const float c); + void scale(const AurynFloat a); + void saxpy(const AurynFloat a, AurynVectorFloat * x); + void clip(const AurynFloat min, const AurynFloat max); + void add(const AurynFloat c); void add(AurynVectorFloat * v); void sum(AurynVectorFloat * a, AurynVectorFloat * b); - void sum(AurynVectorFloat * a, const float b); - void mul(const float a) { scale(a); }; + void sum(AurynVectorFloat * a, const AurynFloat b); + void mul(const AurynFloat a) { scale(a); }; void mul(AurynVectorFloat * v); void diff(AurynVectorFloat * a, AurynVectorFloat * b); - void diff(AurynVectorFloat * a, const float b); - void diff(const float a, AurynVectorFloat * b ); - void follow(AurynVectorFloat * v, const float rate); + void diff(AurynVectorFloat * a, const AurynFloat b); + void diff(const AurynFloat a, AurynVectorFloat * b ); + void follow(AurynVectorFloat * v, const AurynFloat rate); // TODO add pow function with intrinsics _mm_pow_ps diff --git a/src/auryn/AurynVersion.cpp b/src/auryn/AurynVersion.cpp index 74ee2f20..1f04cc8b 100644 --- a/src/auryn/AurynVersion.cpp +++ b/src/auryn/AurynVersion.cpp @@ -6,11 +6,11 @@ namespace auryn { int AurynVersion::version = 0; int AurynVersion::subversion = 8; - int AurynVersion::revision_number = 2; - NeuronID AurynVersion::tag_binary_spike_monitor = 287960000+100*0+10*8+1*2; //!< file signature for BinarySpikeMonitor files - AurynState AurynVersion::tag_binary_state_monitor = 61000+100*0+10*8+1*2; //!< file signature for BinaryStateMonitor files - std::string AurynVersion::revision_suffix = "dev-1610e83"; - std::string AurynVersion::git_describe = "v0.8.1-136-g1610e83"; + int AurynVersion::revision_number = 3; + NeuronID AurynVersion::tag_binary_spike_monitor = 287960000+100*0+10*8+1*3; //!< file signature for BinarySpikeMonitor files + AurynState AurynVersion::tag_binary_state_monitor = 61000+100*0+10*8+1*3; //!< file signature for BinaryStateMonitor files + std::string AurynVersion::revision_suffix = "-c21be2c"; + std::string AurynVersion::git_describe = "v0.8.1-265-gc21be2c"; } diff --git a/src/auryn/AurynVersion.h b/src/auryn/AurynVersion.h index a77e9046..dac8944b 100644 --- a/src/auryn/AurynVersion.h +++ b/src/auryn/AurynVersion.h @@ -1,6 +1,6 @@ /* * -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/BinarySpikeMonitor.cpp b/src/auryn/BinarySpikeMonitor.cpp index 38457169..f1324587 100644 --- a/src/auryn/BinarySpikeMonitor.cpp +++ b/src/auryn/BinarySpikeMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * Contributed by Ankur Sinha * * This file is part of Auryn, a simulation package for plastic @@ -62,6 +62,7 @@ void BinarySpikeMonitor::init(SpikingGroup * source, std::string filename, Neuro src = source; offset = 0; + // write file header // per convention the first entry contains // the number of timesteps per second // the neuronID field contains a tag @@ -70,6 +71,7 @@ void BinarySpikeMonitor::init(SpikingGroup * source, std::string filename, Neuro spikeData.time = (AurynTime)(1.0/auryn_timestep); spikeData.neuronID = sys->build.tag_binary_spike_monitor; outfile.write((char*)&spikeData, sizeof(SpikeEvent_type)); + flush(); // make sure this is written right away for online processing } void BinarySpikeMonitor::free() diff --git a/src/auryn/BinarySpikeMonitor.h b/src/auryn/BinarySpikeMonitor.h index a03c0833..0091cb73 100644 --- a/src/auryn/BinarySpikeMonitor.h +++ b/src/auryn/BinarySpikeMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * Contributed by Ankur Sinha * * This file is part of Auryn, a simulation package for plastic diff --git a/src/auryn/BinaryStateMonitor.cpp b/src/auryn/BinaryStateMonitor.cpp index 7b33f8ac..2b5cde52 100644 --- a/src/auryn/BinaryStateMonitor.cpp +++ b/src/auryn/BinaryStateMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/BinaryStateMonitor.h b/src/auryn/BinaryStateMonitor.h index 6c60f18f..c35fdc54 100644 --- a/src/auryn/BinaryStateMonitor.h +++ b/src/auryn/BinaryStateMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/BurstRateMonitor.cpp b/src/auryn/BurstRateMonitor.cpp index c4202e8c..23c7189b 100644 --- a/src/auryn/BurstRateMonitor.cpp +++ b/src/auryn/BurstRateMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -48,7 +48,7 @@ void BurstRateMonitor::init(SpikingGroup * source, std::string filename, AurynDo burst_state = src->get_state_vector("_burst_state"); set_tau(default_tau); - thr = std::exp(-1.0); + thr = 1.0+std::exp(-1.0); std::stringstream oss; diff --git a/src/auryn/BurstRateMonitor.h b/src/auryn/BurstRateMonitor.h index 7c443eaf..2bfb52a1 100644 --- a/src/auryn/BurstRateMonitor.h +++ b/src/auryn/BurstRateMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Checker.cpp b/src/auryn/Checker.cpp index f8ae44cd..90512f0b 100644 --- a/src/auryn/Checker.cpp +++ b/src/auryn/Checker.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Checker.h b/src/auryn/Checker.h index aeb97266..0417e76c 100644 --- a/src/auryn/Checker.h +++ b/src/auryn/Checker.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ComplexMatrix.h b/src/auryn/ComplexMatrix.h index 2b996cd4..ce4fa879 100644 --- a/src/auryn/ComplexMatrix.h +++ b/src/auryn/ComplexMatrix.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ConcatGroup.cpp b/src/auryn/ConcatGroup.cpp new file mode 100644 index 00000000..1b23e4cc --- /dev/null +++ b/src/auryn/ConcatGroup.cpp @@ -0,0 +1,84 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#include "ConcatGroup.h" + +using namespace auryn; + + +ConcatGroup::ConcatGroup( ) : SpikingGroup( 0, ROUNDROBIN ) +{ + sys->register_spiking_group(this); + evolve_locally_bool = true; + active = true; + // FIXME make sure this runs under all conditions + // mode = ROUNDROBIN; +} + +ConcatGroup::~ConcatGroup() +{ + if ( evolve_locally() ) { + } +} + +void ConcatGroup::add_parent_group(SpikingGroup * group) +{ + parents.push_back(group); + size += group->get_size(); + rank_size += group->get_post_size(); +} + +void ConcatGroup::copy_spikes(SpikeContainer * src, NeuronID group_offset) +{ + // std::cout << "copy_spikes" << std::endl; + for (SpikeContainer::const_iterator spike = src->begin() ; + spike != src->end() ; + ++spike ) { + spikes->push_back(*spike+group_offset); + } +} + +void ConcatGroup::copy_attributes(AttributeContainer * src) +{ + for (AttributeContainer::const_iterator attrib = src->begin() ; + attrib != src->end() ; + ++attrib ) { + attribs->push_back(*attrib); + } +} + +void ConcatGroup::evolve() +{ + NeuronID offset = 0; + for (unsigned int i = 0 ; i < parents.size() ; ++i) { + SpikingGroup * g = parents.at(i); + copy_spikes(g->get_spikes_immediate(), offset); + copy_attributes(g->get_attributes_immediate()); + offset += g->get_size(); + } +} + + + diff --git a/src/auryn/ConcatGroup.h b/src/auryn/ConcatGroup.h new file mode 100644 index 00000000..05061d32 --- /dev/null +++ b/src/auryn/ConcatGroup.h @@ -0,0 +1,82 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#ifndef CONCATGROUP_H_ +#define CONCATGROUP_H_ + +#include "auryn_definitions.h" +#include "AurynVector.h" +#include "System.h" +#include "SpikingGroup.h" + +#include +#include +#include +#include + +namespace auryn { + +/*! \brief ConcatGroup is a meta SpikingGroup which concatenates neurons from several parent groups. + * + * This is an EXPERIMENTAL group which has not undergone extensive testing yet. + * + * When initialized the group does not have any own neurons. + * Add parent groups using the add_parent_group function. + * The group will emit spikes from all the neurons in the parent groups in a concatenated way. + */ +class ConcatGroup : public SpikingGroup +{ +private: + std::vector parents; + + + void init(AurynDouble rate); + void update_parameters(); + +protected: + /*! \brief Copy spikes from container to local delay */ + void copy_spikes(SpikeContainer * src, NeuronID group_offset); + + /*! \brief Copy spike attributes from group container to local delay */ + void copy_attributes(AttributeContainer * group); + +public: + /*! Standard constructor. + */ + ConcatGroup( ); + + /*! Default destructor */ + virtual ~ConcatGroup(); + + /*! Add parent group */ + void add_parent_group(SpikingGroup * group); + + /*! Evolve function for internal use by System */ + virtual void evolve(); +}; + +} + +#endif /*CONCATGROUP_H_*/ diff --git a/src/auryn/Connection.cpp b/src/auryn/Connection.cpp index 94b0ca5c..3e36a4b8 100644 --- a/src/auryn/Connection.cpp +++ b/src/auryn/Connection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Connection.h b/src/auryn/Connection.h index 85f9dbf2..406a7562 100644 --- a/src/auryn/Connection.h +++ b/src/auryn/Connection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/CorrelatedPoissonGroup.cpp b/src/auryn/CorrelatedPoissonGroup.cpp index 1bce9bf6..912e8e22 100644 --- a/src/auryn/CorrelatedPoissonGroup.cpp +++ b/src/auryn/CorrelatedPoissonGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -30,15 +30,16 @@ using namespace auryn; boost::mt19937 CorrelatedPoissonGroup::shared_noise_gen = boost::mt19937(); boost::mt19937 CorrelatedPoissonGroup::rank_noise_gen = boost::mt19937(); -void CorrelatedPoissonGroup::init(AurynDouble rate, NeuronID gsize, AurynDouble timedelay ) +void CorrelatedPoissonGroup::init(AurynDouble rate, NeuronID gsize, AurynDouble timedelay, unsigned int max_groups ) { auryn::sys->register_spiking_group(this); if ( evolve_locally() ) { lambda = rate; + lambda_remainder = 1.0; groupsize = global2rank(gsize); - ngroups = size/gsize; - remainersize = get_rank_size()-ngroups*groupsize; + ngroups = std::min(size/gsize,max_groups); + remaindersize = get_rank_size()-ngroups*groupsize; delay = timedelay/auryn_timestep; offset = 0; @@ -73,8 +74,8 @@ void CorrelatedPoissonGroup::init(AurynDouble rate, NeuronID gsize, AurynDouble shared_noise = new boost::variate_generator > ( shared_noise_gen, boost::uniform_01<> () ); // should have the same state on all ranks rank_noise = new boost::variate_generator > ( rank_noise_gen, boost::exponential_distribution<>(1.0) ); // should have a different state on each rank - x = new NeuronID [ngroups]; - for ( unsigned int i = 0 ; i < ngroups ; ++i ) { + x = new NeuronID [ngroups+1]; + for ( unsigned int i = 0 ; i < ngroups+1 ; ++i ) { AurynDouble r = (*rank_noise)()/lambda; x[i] += (NeuronID)(r/auryn_timestep); } @@ -88,18 +89,19 @@ void CorrelatedPoissonGroup::init(AurynDouble rate, NeuronID gsize, AurynDouble CorrelatedPoissonGroup::CorrelatedPoissonGroup(NeuronID n, AurynDouble rate, NeuronID gsize, - AurynDouble timedelay ) : SpikingGroup( n ) + AurynDouble timedelay, + unsigned int max_groups) : SpikingGroup( n ) { - init(rate, gsize, timedelay); + init(rate, gsize, timedelay, max_groups); } CorrelatedPoissonGroup::~CorrelatedPoissonGroup() { if ( evolve_locally() ) { - delete dist; + // delete dist; delete shared_noise; delete rank_noise; - delete delay_o; + delete [] delay_o; } } @@ -108,6 +110,11 @@ void CorrelatedPoissonGroup::set_rate(AurynDouble rate) lambda = rate; } +void CorrelatedPoissonGroup::set_remainder_rate(AurynDouble rate) +{ + lambda_remainder = rate; +} + void CorrelatedPoissonGroup::set_threshold(AurynDouble threshold) { thr = std::max(1e-6,threshold); @@ -144,7 +151,7 @@ void CorrelatedPoissonGroup::evolve() for ( unsigned int g = 0 ; g < ngroups ; ++g ) { AurynDouble grouprate = delay_o[(auryn::sys->get_clock()-(g+offset)*delay)%len]; AurynDouble r = (*rank_noise)()/(auryn_timestep*grouprate); // think before tempering with this! - // I already broke the corde here once! + // I already broke the code here once! x[g] = (NeuronID)(r); while ( x[g] < groupsize ) { push_spike ( g*groupsize + x[g] ); @@ -152,6 +159,15 @@ void CorrelatedPoissonGroup::evolve() x[g] += (NeuronID)(r); } } + + // remainder neurons not in any group + AurynDouble r = (*rank_noise)()/(auryn_timestep*lambda_remainder); + x[ngroups] = (NeuronID)(r); + while ( x[ngroups] < remaindersize ) { + push_spike ( ngroups*groupsize + x[ngroups] ); + r = (*rank_noise)()/(auryn_timestep*lambda); + x[ngroups] += (NeuronID)(r); + } } void CorrelatedPoissonGroup::seed() diff --git a/src/auryn/CorrelatedPoissonGroup.h b/src/auryn/CorrelatedPoissonGroup.h index 3b9cb86b..cc3aa480 100644 --- a/src/auryn/CorrelatedPoissonGroup.h +++ b/src/auryn/CorrelatedPoissonGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -56,15 +56,16 @@ class CorrelatedPoissonGroup : public SpikingGroup boost::variate_generator > * shared_noise; boost::variate_generator > * rank_noise; - void init(AurynDouble rate, NeuronID gsize, AurynDouble timedelay ); + void init(AurynDouble rate, NeuronID gsize, AurynDouble timedelay, unsigned int max_groups=5 ); protected: AurynDouble lambda; + AurynDouble lambda_remainder; AurynTime tstop; NeuronID groupsize; - NeuronID remainersize; + NeuronID remaindersize; NeuronID ngroups; AurynDouble timescale; @@ -96,10 +97,13 @@ class CorrelatedPoissonGroup : public SpikingGroup CorrelatedPoissonGroup(NeuronID n, AurynDouble rate=5., NeuronID gsize=100, - AurynDouble timedelay=50e-3 ); + AurynDouble timedelay=50e-3, + unsigned int max_groups=5 + ); virtual ~CorrelatedPoissonGroup(); virtual void evolve(); void set_rate(AurynDouble rate); + void set_remainder_rate(AurynDouble rate); void set_amplitude(AurynDouble ampl); void set_target_amplitude(AurynDouble ampl); void set_tau_amplitude(AurynDouble scale); diff --git a/src/auryn/CubaIFGroup.cpp b/src/auryn/CubaIFGroup.cpp index 6e7faba9..587e73e9 100644 --- a/src/auryn/CubaIFGroup.cpp +++ b/src/auryn/CubaIFGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/CubaIFGroup.h b/src/auryn/CubaIFGroup.h index 10ffd99e..814e0b0b 100644 --- a/src/auryn/CubaIFGroup.h +++ b/src/auryn/CubaIFGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/CurrentInjector.cpp b/src/auryn/CurrentInjector.cpp index f347f409..ce461577 100644 --- a/src/auryn/CurrentInjector.cpp +++ b/src/auryn/CurrentInjector.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -36,7 +36,7 @@ CurrentInjector::CurrentInjector(NeuronGroup * target, std::string neuron_state_ currents = new AurynVectorFloat(dst->get_vector_size()); currents->set_all( initial_current ); - alpha = auryn_timestep; + set_scale(1.0); } @@ -71,3 +71,7 @@ void CurrentInjector::set_target_state(std::string state_name) { target_vector = dst->get_state_vector(state_name); } + +void CurrentInjector::set_scale(AurynState scale) { + alpha = scale*auryn_timestep; +} diff --git a/src/auryn/CurrentInjector.h b/src/auryn/CurrentInjector.h index fb2f970c..6b02ccb2 100644 --- a/src/auryn/CurrentInjector.h +++ b/src/auryn/CurrentInjector.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -50,23 +50,25 @@ class CurrentInjector : protected Device { private: - /*! Vector storing all the current values */ - AurynVectorFloat * currents; - /*! Target membrane */ - AurynVectorFloat * target_vector; void free(); - /*! Returns the lambda parameter of the pmf for Current. */ + /*! \brief Returns the lambda parameter of the pmf for Current. */ AurynFloat get_lambda(); - /*! Scale factor which should include auryn_timestep and any respective resistance. */ + /*! \brief Scale factor which should include auryn_timestep and any respective resistance. */ AurynFloat alpha; protected: - /*! The target NeuronGroup */ + /*! \brief Target membrane */ + AurynVectorFloat * target_vector; + + /*! \brief Vector storing all the current values */ + AurynVectorFloat * currents; + + /*! \brief The target NeuronGroup */ NeuronGroup * dst; @@ -100,9 +102,21 @@ class CurrentInjector : protected Device * \param current Current value to set*/ void set_all_currents( AurynFloat current ); + /*! \brief Sets scale + * + * \param scale The scale value to set + * + * This sets a scaling factor or "unit" with which all current values are + * multiplied. Internally this value is multiplied by auryn time step to + * make it invariant to timestep changes. + * */ + void set_scale( AurynFloat scale ); + /*! Implementation of necessary propagate() function. */ void execute(); + + }; } diff --git a/src/auryn/DelayConnection.cpp b/src/auryn/DelayConnection.cpp new file mode 100644 index 00000000..340f37d8 --- /dev/null +++ b/src/auryn/DelayConnection.cpp @@ -0,0 +1,97 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#include "DelayConnection.h" + +using namespace auryn; + + +DelayConnection::DelayConnection(NeuronID rows, NeuronID cols) +: SparseConnection(rows, cols) +{ + init(); +} + +DelayConnection::DelayConnection( SpikingGroup * source, NeuronGroup * destination, + AurynWeight weight, AurynFloat sparseness, + TransmitterType transmitter, std::string name) +: SparseConnection(source,destination,weight,sparseness,transmitter, name) +{ + init(); +} + + +DelayConnection::~DelayConnection() +{ + free(); +} + + +void DelayConnection::init() +{ + if ( dst->get_post_size() == 0 ) return; // if there are no target neurons on this rank + + src_dly = new SpikeDelay( 1 ); + src_dly->set_clock_ptr( sys->get_clock_ptr() ); // assign clock for ring buffer +} + + +void DelayConnection::free() +{ + delete src_dly; +} + + +void DelayConnection::propagate() +{ + // pop buffer from delay and push spikes from src to back + src_dly->get_spikes_immediate()->clear(); + src_dly->push_back(src->get_spikes()); + + + // do normal forward propagation as in SparseConnection + for (SpikeContainer::const_iterator spike = src_dly->get_spikes()->begin() ; + spike != src_dly->get_spikes()->end() ; + ++spike ) { + for ( AurynLong c = w->get_row_begin_index(*spike) ; + c < w->get_row_end_index(*spike) ; + ++c ) { + transmit( w->get_colind(c) , w->get_value(c) ); + } + } +} + + +void DelayConnection::set_delay_steps(unsigned int delay) +{ + delay = std::max((unsigned int)1,delay); + src_dly->set_delay(delay); +} + + +void DelayConnection::set_delay(double delay) +{ + set_delay_steps( delay/auryn_timestep ); +} diff --git a/src/auryn/DelayConnection.h b/src/auryn/DelayConnection.h new file mode 100644 index 00000000..3c7e1948 --- /dev/null +++ b/src/auryn/DelayConnection.h @@ -0,0 +1,114 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#ifndef DELAYCONNECTION_H_ +#define DELAYCONNECTION_H_ + +#include "auryn_definitions.h" +#include "AurynVector.h" +#include "SparseConnection.h" +#include "SpikeDelay.h" + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace auryn { + +/*! \brief DelayConnection implements a SparseConnection with adjustable delays. + * + * DelayConnection adds a delay to spikes from the src group. The delays of + * DelayConnection are added to the delays already present in SpikingGroup. + * Moreover, the delays are connection specific and can be interpreted as + * dendritic delays. + * The minimum possible delay is one timestep. + * + * \todo This is a prototype connection which needs testing. + * */ + +class DelayConnection : public SparseConnection +{ +private: + SpikeDelay * src_dly; + + void init(); + void free(); + +protected: + void virtual_serialize(boost::archive::binary_oarchive & ar, const unsigned int version ) + { + SparseConnection::virtual_serialize(ar,version); + ar & *src_dly; + } + + void virtual_serialize(boost::archive::binary_iarchive & ar, const unsigned int version ) + { + SparseConnection::virtual_serialize(ar,version); + ar & *src_dly; + } + +public: + /*! \brief The bare constructor for manual filling and constructing DelayConnection objects. + * + * You should only use this if you know what you are doing. */ + DelayConnection(NeuronID rows, NeuronID cols); + + /*! \brief The default constructor for DelayConnection */ + DelayConnection( + SpikingGroup * source, + NeuronGroup * destination, + AurynWeight weight, + AurynFloat sparseness=0.05, + TransmitterType transmitter=GLUT, + string name="DelayConnection"); + + /*! \brief The default destructor */ + virtual ~DelayConnection(); + + + /*! \brief The required virtual propagate function for propagating spikes */ + virtual void propagate(); + + /*! \brief Sets the delay in in units of auryn_timestep which is added + * to all spikes from the src group. */ + void set_delay_steps(unsigned int delay); //!< Set delay in time steps + + /*! \brief Sets the delay in in units of seconds which + * is added to all spikes from the src group. */ + void set_delay(double delay=1e-3); //!< Set delay in seconds +}; + +} + +#endif /*DELAYCONNECTION_H_*/ diff --git a/src/auryn/DelayedSpikeMonitor.cpp b/src/auryn/DelayedSpikeMonitor.cpp index 2c462271..a2e808ec 100644 --- a/src/auryn/DelayedSpikeMonitor.cpp +++ b/src/auryn/DelayedSpikeMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -55,12 +55,13 @@ void DelayedSpikeMonitor::init(SpikingGroup * source, std::string filename, Neur auryn::sys->register_device(this); // sys = system; + active = true; n_from = from; n_to = to; src = source; offset = 0; outfile.setf(std::ios::fixed); - outfile.precision(5); + outfile.precision(log(auryn_timestep)/log(10)+1 ); } void DelayedSpikeMonitor::free() @@ -74,6 +75,8 @@ void DelayedSpikeMonitor::set_offset(NeuronID of) void DelayedSpikeMonitor::execute() { + if ( !active ) return; + for (it = src->get_spikes()->begin() ; it != src->get_spikes()->end() ; ++it ) { if (*it >= n_from ) { if ( *it < n_to ) diff --git a/src/auryn/DelayedSpikeMonitor.h b/src/auryn/DelayedSpikeMonitor.h index 7c6dd818..86c2ec11 100644 --- a/src/auryn/DelayedSpikeMonitor.h +++ b/src/auryn/DelayedSpikeMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -46,7 +46,7 @@ namespace auryn { * It records all * the spikes on each node (which effectively multiplies spikes). */ -class DelayedSpikeMonitor : Monitor +class DelayedSpikeMonitor : public Monitor { private: NeuronID n_from; diff --git a/src/auryn/Device.cpp b/src/auryn/Device.cpp index a67a72b5..6820f6d3 100644 --- a/src/auryn/Device.cpp +++ b/src/auryn/Device.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Device.h b/src/auryn/Device.h index 3bc4905c..8193fa86 100644 --- a/src/auryn/Device.h +++ b/src/auryn/Device.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/DuplexConnection.cpp b/src/auryn/DuplexConnection.cpp index fb4f7d99..fc98b29c 100644 --- a/src/auryn/DuplexConnection.cpp +++ b/src/auryn/DuplexConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/DuplexConnection.h b/src/auryn/DuplexConnection.h index d6b228e3..4376eb84 100644 --- a/src/auryn/DuplexConnection.h +++ b/src/auryn/DuplexConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/EulerTrace.cpp b/src/auryn/EulerTrace.cpp index a0d23f97..98c0fe94 100644 --- a/src/auryn/EulerTrace.cpp +++ b/src/auryn/EulerTrace.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/EulerTrace.h b/src/auryn/EulerTrace.h index 967152b9..fbc367e8 100644 --- a/src/auryn/EulerTrace.h +++ b/src/auryn/EulerTrace.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ExpCobaSynapse.cpp b/src/auryn/ExpCobaSynapse.cpp index f9a12ed4..be724ad5 100644 --- a/src/auryn/ExpCobaSynapse.cpp +++ b/src/auryn/ExpCobaSynapse.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ExpCobaSynapse.h b/src/auryn/ExpCobaSynapse.h index b71a4d6e..a7833396 100644 --- a/src/auryn/ExpCobaSynapse.h +++ b/src/auryn/ExpCobaSynapse.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ExpCubaSynapse.cpp b/src/auryn/ExpCubaSynapse.cpp index 3633afc7..c96fadc9 100644 --- a/src/auryn/ExpCubaSynapse.cpp +++ b/src/auryn/ExpCubaSynapse.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ExpCubaSynapse.h b/src/auryn/ExpCubaSynapse.h index 8e27357e..54668a92 100644 --- a/src/auryn/ExpCubaSynapse.h +++ b/src/auryn/ExpCubaSynapse.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/FileCurrentInjector.cpp b/src/auryn/FileCurrentInjector.cpp new file mode 100644 index 00000000..2d3f6330 --- /dev/null +++ b/src/auryn/FileCurrentInjector.cpp @@ -0,0 +1,140 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#include "FileCurrentInjector.h" + +using namespace auryn; + +FileCurrentInjector::FileCurrentInjector(NeuronGroup * target, std::string time_series_file, std::string neuron_state_name ) : CurrentInjector(target, neuron_state_name, 0.0 ) +{ + target_neuron_ids = new std::vector; + current_time_series = new std::vector; + + mode = ALL; + loop = false; + set_loop_grid(1.0); + load_time_series_file(time_series_file); +} + + + +void FileCurrentInjector::free( ) +{ + delete target_neuron_ids; + delete current_time_series; +} + + +FileCurrentInjector::~FileCurrentInjector() +{ + free(); +} + + +AurynState FileCurrentInjector::get_current_current_value() +{ + + AurynTime index = sys->get_clock(); + if ( loop ) { + index = sys->get_clock()%loop_grid; + } + + if ( index < current_time_series->size() ) { + return current_time_series->at( index ); + } else { + return 0.0; + } +} + +void FileCurrentInjector::execute() +{ + if ( dst->evolve_locally() ) { + AurynState cur = get_current_current_value(); + switch ( mode ) { + case LIST: + currents->set_all(0.0); + for ( int i = 0 ; i < target_neuron_ids->size() ; ++i ) { + currents->set(target_neuron_ids->at(i),cur); + } + break; + case ALL: + default: + currents->set_all(cur); + } + CurrentInjector::execute(); + } +} + +void FileCurrentInjector::set_loop_grid(double grid) +{ + if (grid<=0.0) { + logger->error("FileCurrentInjector:: Cannot set non-positive loop grid. Loop grid unchanged!"); + } else { + loop_grid = grid/auryn_timestep; + } +} + +void FileCurrentInjector::load_time_series_file(std::string filename) +{ + std::ifstream inputfile; + inputfile.open(filename.c_str(),std::ifstream::in); + if (!inputfile) { + std::cerr << "Can't open input file " << filename << std::endl; + throw AurynOpenFileException(); + } + + current_time_series->clear(); + + // read the time series file and interpolate missing time points linearly + AurynTime curtime = 0; + AurynTime ltime = 0; + AurynTime ntime = 0; + double lc = 0.0; + double nc = 0.0; + char buffer[255]; + while ( inputfile.getline(buffer, 256) ) { + std::stringstream line ( buffer ); + + // store last data point + ltime = ntime; + lc = nc; + + // read new data point + double t; + line >> t; + ntime = (AurynTime) (t/auryn_timestep+0.5); + line >> nc; + + while ( curtime < ntime || inputfile.eof() ) { + double inter_current = lc + 1.0*(curtime-ltime)/(ntime-ltime)*(nc-lc); + // std::cout << curtime << " " << inter_current << std::endl; + current_time_series->push_back(inter_current); + curtime++; + } + } + current_time_series->push_back(lc); // terminates with last value + + inputfile.close(); +} diff --git a/src/auryn/FileCurrentInjector.h b/src/auryn/FileCurrentInjector.h new file mode 100644 index 00000000..65bc46fa --- /dev/null +++ b/src/auryn/FileCurrentInjector.h @@ -0,0 +1,141 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#ifndef FILECURRENTINJECTOR_H_ +#define FILECURRENTINJECTOR_H_ + +#include "auryn_definitions.h" +#include "AurynVector.h" +#include "System.h" +#include "Logger.h" +#include "Device.h" +#include "NeuronGroup.h" +#include "CurrentInjector.h" + + +namespace auryn { + +/*! \brief Stimulator class which reads "currents" from a file and applies them to arbitrary neuronal states. + * + * Most commonly used to inject "currents" to arbitraty neuronal states. Maintains an internal vector with + * numbers which are added (times auryn_timestep) in each timestep to the neuronal target vector + * (per default that is the membrane voltage and hence the operation corresponds to injecting a current). + * Note that because of this current units of FileCurrentInjector are in a sense arbitrary because they depend + * on the neuron model. The scale of inputs can be with the set_scale runction. + * + * Upon construction the FileCurrentInjector accepts a human readable file in + * two-column format which stores the current time series. The first column + * should contain the time in s and the second column the corresponding current + * values. Missing current values are interpolated linearly. + * Here is an example for a valid time series file: + * + * 0.000000 0.000000 + * 0.050000 0.125333 + * 0.100000 0.248690 + * 0.150000 0.368125 + * 0.200000 0.481754 + * 0.250000 0.587785 + * 0.300000 0.684547 + * + * + */ + +enum FileCurrentInjectorMode { + LIST, + ALL +}; + +class FileCurrentInjector : public CurrentInjector +{ +private: + void free(); + + /*! \brief compute current current value from sys clock */ + AurynState get_current_current_value(); + +protected: + + + /*! \brief Current time series */ + std::vector * current_time_series; + + /*! \brief The loop grid variable */ + AurynTime loop_grid; + + + +public: + + /*! \brief Default Constructor + * @param[target] The target group + * @param[time_series_file] The path to the file holding the time series to inject + * @param[neuron_state_name] The state to manipulate + */ + FileCurrentInjector(NeuronGroup * target, std::string time_series_file, std::string neuron_state_name="mem" ); + + /*! \brief Default Destructor */ + virtual ~FileCurrentInjector(); + + /*! \brief Loads time series file + * + * @param[filename] The path and filename of the ASCII two-column file to load. + * This functions loads the time series to inject from a human readable + * ASCII file in two column format. The first column should be time in s. + * The second column should include the current value in arbitrary units + * (which may depend on the neuron model and the state variable the + * current is injected to. */ + void load_time_series_file(std::string filename); + + /*! \brief Mode of operation + * + * Determines whether the current should be injected to a list of neurons or all neurons. */ + FileCurrentInjectorMode mode; + + /*! \brief The array holding the target neuron ids */ + std::vector * target_neuron_ids; + + /*! \brief Loop switch + * + * Switches looping on/off. + **/ + bool loop; + + /*! \brief Set loop grid in units of s + * + * Sets the the loop grid variable. This variable determines whether + * consecutive replays in loop mode are aligned to this temporal grid. + * This should be larger or equal to the length of the input time series + * otherwise it may be truncated. Per default it is set to 1.0s. + **/ + void set_loop_grid(double grid); + + /*! Implementation of necessary propagate() function. */ + void execute(); + +}; + +} + +#endif /*FILECURRENTINJECTOR_H_*/ diff --git a/src/auryn/FileInputGroup.cpp b/src/auryn/FileInputGroup.cpp index 49f21d34..2b724a82 100644 --- a/src/auryn/FileInputGroup.cpp +++ b/src/auryn/FileInputGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -81,11 +81,10 @@ void FileInputGroup::load_spikes(std::string filename) std::stringstream line ( buffer ) ; double t_tmp; line >> t_tmp; - event.time = t_tmp/auryn_timestep; + event.time = round(t_tmp/auryn_timestep); line >> event.neuronID; if ( localrank(event.neuronID) ) { input_spikes.push_back(event); - // std::cout << event.time << std::endl; } } spkfile.close(); diff --git a/src/auryn/FileInputGroup.h b/src/auryn/FileInputGroup.h index 3461d283..47140e88 100644 --- a/src/auryn/FileInputGroup.h +++ b/src/auryn/FileInputGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -29,6 +29,9 @@ #include #include +#include +#include + #include "auryn_definitions.h" #include "AurynVector.h" #include "System.h" diff --git a/src/auryn/FileModulatedPoissonGroup.cpp b/src/auryn/FileModulatedPoissonGroup.cpp index 0c2feebf..bde0ab54 100644 --- a/src/auryn/FileModulatedPoissonGroup.cpp +++ b/src/auryn/FileModulatedPoissonGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -38,12 +38,14 @@ void FileModulatedPoissonGroup::init ( std::string filename ) } ftime = 0; + ftime_offset = 0; } FileModulatedPoissonGroup::FileModulatedPoissonGroup(NeuronID n, - std::string filename ) : PoissonGroup( n , 0.0 ) + std::string filename, bool loop_mode ) : PoissonGroup( n , 0.0 ) { init(filename); + loop = loop_mode; } FileModulatedPoissonGroup::~FileModulatedPoissonGroup() @@ -65,10 +67,10 @@ void FileModulatedPoissonGroup::evolve() rate_n = get_rate(); line >> t; - ftime = (AurynTime) (t/auryn_timestep+0.5); + ftime = (AurynTime) (t/auryn_timestep+0.5) + ftime_offset; line >> r; - if ( ftime < auryn::sys->get_clock() || inputfile.eof() ) { // if the recently read point is already in the past -> reinit interpolation + if ( ftime < auryn::sys->get_clock() || ( inputfile.eof() && not loop ) ) { // if the recently read point is already in the past -> reinit interpolation rate_m = 0.0; rate_n = r; set_rate(r); @@ -77,6 +79,12 @@ void FileModulatedPoissonGroup::evolve() } } + if ( inputfile.eof() && loop ) { // go back to the beginning of the file if in loop mode + ftime_offset = ftime; + inputfile.clear(); + inputfile.seekg(0, std::ios::beg); + } + AurynDouble rate = rate_m*(auryn::sys->get_clock()-ltime)+rate_n; if ( last_rate != rate ) { // only redraw when rate changes diff --git a/src/auryn/FileModulatedPoissonGroup.h b/src/auryn/FileModulatedPoissonGroup.h index e6a1a92a..df516932 100644 --- a/src/auryn/FileModulatedPoissonGroup.h +++ b/src/auryn/FileModulatedPoissonGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -47,6 +47,7 @@ class FileModulatedPoissonGroup : public PoissonGroup { private: AurynTime ftime; + AurynTime ftime_offset; AurynTime ltime; AurynDouble rate_m; AurynDouble rate_n; @@ -58,9 +59,14 @@ class FileModulatedPoissonGroup : public PoissonGroup std::ifstream inputfile; void init ( string filename ); + +protected: public: - FileModulatedPoissonGroup(NeuronID n, string filename ); + /*! Switch that decides whether to start at the beginning of the file when reaching eof */ + bool loop; + + FileModulatedPoissonGroup(NeuronID n, string filename, bool loop_mode = true ); virtual ~FileModulatedPoissonGroup(); virtual void evolve(); }; diff --git a/src/auryn/FileStimGroup.cpp b/src/auryn/FileStimGroup.cpp new file mode 100644 index 00000000..35abd2e9 --- /dev/null +++ b/src/auryn/FileStimGroup.cpp @@ -0,0 +1,249 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#include "FileStimGroup.h" + +using namespace auryn; + +boost::mt19937 FileStimGroup::order_gen = boost::mt19937(); +boost::uniform_01 FileStimGroup::order_die = boost::uniform_01 (order_gen); + +void FileStimGroup::init() +{ + auryn::sys->register_spiking_group(this); + active = true; + loop_grid_size = 1; + reset_time = 0; + + seed(42); + + + set_stimulation_mode(RANDOM); // TODO make adjustable +} + +void FileStimGroup::set_stimulation_mode( StimulusGroupModeType mode ) { + stimulus_order = mode ; +} + +FileStimGroup::FileStimGroup( NeuronID n ) : SpikingGroup(n, RANKLOCK ) +{ + playinloop = false; + time_delay = 0; + time_offset = 0; + current_pattern_index = 0; + init(); +} + +FileStimGroup::FileStimGroup(NeuronID n, std::string filename, + bool loop, AurynFloat delay) +: SpikingGroup( n , RANKLOCK ) +{ + init(); + playinloop = loop; + if ( playinloop ) set_loop_grid(auryn_timestep); + time_delay = (AurynTime) (delay/auryn_timestep); + time_offset = 0; + load_spikes(filename); +} + +FileStimGroup::~FileStimGroup() +{ + clear_input_patterns(); +} + +bool time_compare (SpikeEvent_type a,SpikeEvent_type b) { return (a.time; + char buffer[255]; + std::string line_; + while ( spkfile.getline(buffer, 256) ) { + line_.clear(); // TODO make this less hacky + line_ = buffer; + if ( line_[0] == '#' ) continue; // skip comments + if ( line_ == "" and current_pattern->size()>0 ) { // empty line triggers new pattern + sort_spikes(current_pattern); + input_patterns.push_back(current_pattern); + current_pattern = new std::vector< SpikeEvent_type >; + continue; + } + + // assume we have a line with an event + SpikeEvent_type event; + std::stringstream line ( buffer ) ; + double t_tmp; + line >> t_tmp; + event.time = round(t_tmp/auryn_timestep); + line >> event.neuronID; + if ( localrank(event.neuronID) ) current_pattern->push_back(event); + } + spkfile.close(); + + // store last pattern if any + if ( current_pattern->size()>0 ) { + sort_spikes(current_pattern); + input_patterns.push_back(current_pattern); + } + + + std::stringstream oss; + oss << get_log_name() << ":: Finished loading " << input_patterns.size() + << " input patterns"; + logger->info(oss.str()); + + current_pattern = input_patterns.at(0); + spike_iter = current_pattern->end(); + } +} + +void FileStimGroup::sort_spikes( std::vector< SpikeEvent_type > * pattern ) +{ + std::sort (pattern->begin(), pattern->end(), time_compare); +} + + +AurynTime FileStimGroup::get_offset_clock() +{ + return sys->get_clock() - time_offset; +} + +AurynTime FileStimGroup::get_next_grid_point( AurynTime time ) +{ + AurynTime result = time+time_delay; + if ( result%loop_grid_size ) { // align to temporal grid + result = (result/loop_grid_size+1)*loop_grid_size; + } + return result+1; +} + +void FileStimGroup::evolve() +{ + if ( active && input_patterns.size() ) { + // when reset_time is reached reset the spike_iterator to The beginning and update time offset + if ( sys->get_clock() == reset_time ) { + spike_iter = current_pattern->begin(); + time_offset = sys->get_clock(); + // std::cout << "set to" << reset_time*auryn_timestep << " " << time_offset << std::endl; + } + + while ( spike_iter != current_pattern->end() && (*spike_iter).time <= get_offset_clock() ) { + spikes->push_back((*spike_iter).neuronID); + ++spike_iter; + // std::cout << "spike " << sys->get_time() << std::endl; + } + + if ( spike_iter==current_pattern->end() && reset_time < sys->get_clock() && playinloop ) { // at last spike on file set new reset time + + // chooses stimulus according to schema specified in stimulusmode + switch ( stimulus_order ) { + case RANDOM: + double draw; + draw = order_die(); + current_pattern_index = draw*input_patterns.size(); + break; + case SEQUENTIAL: + current_pattern_index = (current_pattern_index+1)%input_patterns.size(); + break; + case SEQUENTIAL_REV: + if ( current_pattern_index == 0 ) + current_pattern_index = input_patterns.size() - 1 ; + else + --current_pattern_index; + break; + case MANUAL: + default: + break; + } + + + // std::cout << "new pattern " << current_pattern_index << std::endl; + current_pattern = input_patterns.at(current_pattern_index); + reset_time = get_next_grid_point(sys->get_clock()); + + std::stringstream oss; + oss << get_log_name() << ":: Selected next pattern " << current_pattern_index << " at " << sys->get_time() + << "s. Current grid point " << sys->get_clock() + << ", next grid point " << reset_time; + logger->debug(oss.str()); + } + } +} + +void FileStimGroup::seed(int rndseed) +{ + unsigned int rnd = rndseed + sys->get_synced_seed(); // most be same on all ranks + order_gen.seed(rnd); + + // this is here because the seeding above alone does not seem to do anything + // also need to overwrite the dist operator because it makes of copy of the + // generator + // see http://www.bnikolic.co.uk/blog/cpp-boost-uniform01.html + order_die = boost::uniform_01 (order_gen); +} + +void FileStimGroup::set_loop_grid(AurynDouble grid_size) +{ + playinloop = true; + if ( grid_size > 0.0 ) { + loop_grid_size = 1.0/auryn_timestep*grid_size; + if ( loop_grid_size == 0 ) loop_grid_size = 1; + } +} + +void FileStimGroup::add_spike(double spiketime, NeuronID neuron_id) +{ + SpikeEvent_type event; + event.time = spiketime/auryn_timestep; + event.neuronID = neuron_id; + current_pattern->push_back(event); + sort_spikes(current_pattern); +} + diff --git a/src/auryn/FileStimGroup.h b/src/auryn/FileStimGroup.h new file mode 100644 index 00000000..b1698d2e --- /dev/null +++ b/src/auryn/FileStimGroup.h @@ -0,0 +1,149 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#ifndef FILEISTIMROUP_H_ +#define FILESTIMGROUP_H_ + +#include +#include + +#include +#include + +#include "auryn_definitions.h" +#include "AurynVector.h" +#include "System.h" +#include "SpikingGroup.h" + +namespace auryn { + +/*! \brief Reads spikes from a ras file and emits them as SpikingGroup in a simulation. + * + * FileStimGroup first reads the entire ras file into memory and emits the spikes then during the simulation + * without file access. It supports looping over the input spikes by setting the loop argument with the constructor + * to true. + * + */ +class FileStimGroup : public SpikingGroup +{ +private: + AurynTime next_event_time; + NeuronID next_event_spike; + unsigned int current_pattern_index; + + /*! \brief Aligns looped file input to a grid of this size */ + AurynTime loop_grid_size; + + AurynTime time_offset; + AurynTime reset_time; + + + std::vector< std::vector * > input_patterns; + std::vector< SpikeEvent_type > * current_pattern; + std::vector< SpikeEvent_type >::const_iterator spike_iter; + + void init(); + + void clear_input_patterns(); + + AurynTime get_offset_clock(); + AurynTime get_next_grid_point( AurynTime time ); + + +protected: + + /*! \brief Seeds the random number generator for all stimulus groups of the simulation. */ + void seed( int rndseed ); + + /*! generates info for what stimulus is active. Is supposed to give the same result on all nodes (hence same seed required) */ + static boost::mt19937 order_gen; + static boost::uniform_01 order_die; + + +public: + + /*! \brief Switch that activates the loop mode of FileStimGroup when set to true */ + bool playinloop; + + /*! \brief Stimulus order */ + StimulusGroupModeType stimulus_order ; + + /*! \brief Time delay after each replay of the input pattern in loop mode (default 0s) */ + AurynTime time_delay; + + /*! \brief Default constructor */ + FileStimGroup( NeuronID n, string filename , bool loop=false, AurynFloat delay=0.0 ); + + /*! \brief Constructor which does not load spikes. + * + * Use this constructor if you want to init the group without a filename containing spikes. + * Spikes can be added after initialization by calling load_spikes(filename) or by adding + * spikes one by one using add_spike(spiketime, neuron_id). */ + FileStimGroup( NeuronID n ); + + virtual ~FileStimGroup(); + virtual void evolve(); + + + /*! \brief Sets the stimulation mode. Can be any of StimulusGroupModeType (MANUAL,RANDOM,SEQUENTIAL,SEQUENTIAL_REV). */ + void set_stimulation_mode(StimulusGroupModeType mode); + + /*!\brief Aligned loop blocks to a temporal grid of this size + * + * The grid is applied after the delay. It's mostly there to facilitate the + * synchronization of certain events or readouts. If no grid is defined + * the last input spike time will define the end of the loop window (which + * often could be a fractional time). + * */ + void set_loop_grid(AurynDouble grid_size); + + /*!\brief Load spike patterns from file + * + * */ + void load_spikes(std::string filename); + + + /*!\brief Load spikes from file without erasing existing buffers. + * + * */ + void add_spikes(std::string filename); + + /*!\brief Adds a spike to the buffer manually and then temporally sorts the buffer + * + * \param spiketime the spike time + * \param neuron_id the neuron you want to spike with neuron_id < size of the group + * */ + void add_spike(double spiketime, NeuronID neuron_id=0); + + /*!\brief Sorts spikes by time + * + * Spikes need to be sorted befure a run otherwise the behavior of this SpikingGroup is undefined + * */ + void sort_spikes( std::vector< SpikeEvent_type > * pattern ); +}; + +} + +#endif /*FILESTIMROUP_H_*/ diff --git a/src/auryn/IFGroup.cpp b/src/auryn/IFGroup.cpp index 76ddbef5..79b1468b 100644 --- a/src/auryn/IFGroup.cpp +++ b/src/auryn/IFGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IFGroup.h b/src/auryn/IFGroup.h index 63a68294..c734a7b1 100644 --- a/src/auryn/IFGroup.h +++ b/src/auryn/IFGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IafPscDeltaGroup.cpp b/src/auryn/IafPscDeltaGroup.cpp index 3ebafe82..ab9ce47c 100644 --- a/src/auryn/IafPscDeltaGroup.cpp +++ b/src/auryn/IafPscDeltaGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IafPscDeltaGroup.h b/src/auryn/IafPscDeltaGroup.h index a390b205..c3d7c1cb 100644 --- a/src/auryn/IafPscDeltaGroup.h +++ b/src/auryn/IafPscDeltaGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IafPscExpGroup.cpp b/src/auryn/IafPscExpGroup.cpp index e15a6cfe..2b2d1148 100644 --- a/src/auryn/IafPscExpGroup.cpp +++ b/src/auryn/IafPscExpGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IafPscExpGroup.h b/src/auryn/IafPscExpGroup.h index c5d82d5c..7e326806 100644 --- a/src/auryn/IafPscExpGroup.h +++ b/src/auryn/IafPscExpGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IdentityConnection.cpp b/src/auryn/IdentityConnection.cpp index 20fb8678..97a54651 100644 --- a/src/auryn/IdentityConnection.cpp +++ b/src/auryn/IdentityConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IdentityConnection.h b/src/auryn/IdentityConnection.h index 0f1201bc..71e47e49 100644 --- a/src/auryn/IdentityConnection.h +++ b/src/auryn/IdentityConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/InputChannelGroup.cpp b/src/auryn/InputChannelGroup.cpp index 5a43ec5f..1ed86ce8 100644 --- a/src/auryn/InputChannelGroup.cpp +++ b/src/auryn/InputChannelGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -49,6 +49,8 @@ void InputChannelGroup::init(AurynDouble rate, NeuronID chsize ) timescale = 50e-3; set_stoptime(0); + scale_by_channel = false; + std::stringstream oss; oss << "InputChannelGroup:: Initializing with " << nb_channels << " of size " @@ -126,6 +128,7 @@ void InputChannelGroup::evolve() // group rate AurynDouble grouprate = amplitudes[g]*o[g]; if ( grouprate <= 0 ) grouprate = 0.0; + if ( scale_by_channel ) grouprate *= (1.0+g)/nb_channels; const AurynFloat epsilon = 1e-3; AurynDouble r = (*rank_noise)()/(auryn_timestep*(grouprate+epsilon)); // think before tempering with this! diff --git a/src/auryn/InputChannelGroup.h b/src/auryn/InputChannelGroup.h index 635fab40..a6f5d1cd 100644 --- a/src/auryn/InputChannelGroup.h +++ b/src/auryn/InputChannelGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -66,6 +66,7 @@ class InputChannelGroup : public SpikingGroup NeuronID channelsize; NeuronID nb_channels; + AurynDouble timescale; int offset; AurynTime delay; @@ -82,6 +83,9 @@ class InputChannelGroup : public SpikingGroup /*! \brief Array for OU process means */ AurynDouble * means; + /*! \brief Scale amplitude by channel number when set to True */ + bool scale_by_channel; + /*! Default constructor. * * @param n the size of the group which will be devided by the size of one subgroup to give the number of groups. diff --git a/src/auryn/IzhikevichGroup.cpp b/src/auryn/IzhikevichGroup.cpp index 186a28eb..36dcab3c 100644 --- a/src/auryn/IzhikevichGroup.cpp +++ b/src/auryn/IzhikevichGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/IzhikevichGroup.h b/src/auryn/IzhikevichGroup.h index d6cadfcd..76c0eddf 100644 --- a/src/auryn/IzhikevichGroup.h +++ b/src/auryn/IzhikevichGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/LPTripletConnection.cpp b/src/auryn/LPTripletConnection.cpp index e892e911..6a0b432b 100644 --- a/src/auryn/LPTripletConnection.cpp +++ b/src/auryn/LPTripletConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/LPTripletConnection.h b/src/auryn/LPTripletConnection.h index e1ef5e77..d5031c37 100644 --- a/src/auryn/LPTripletConnection.h +++ b/src/auryn/LPTripletConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/LinearComboSynapse.cpp b/src/auryn/LinearComboSynapse.cpp index c9d56874..4dfe8d06 100644 --- a/src/auryn/LinearComboSynapse.cpp +++ b/src/auryn/LinearComboSynapse.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/LinearComboSynapse.h b/src/auryn/LinearComboSynapse.h index ef7f3849..61887142 100644 --- a/src/auryn/LinearComboSynapse.h +++ b/src/auryn/LinearComboSynapse.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/LinearTrace.cpp b/src/auryn/LinearTrace.cpp index bd072985..c8b53f5e 100644 --- a/src/auryn/LinearTrace.cpp +++ b/src/auryn/LinearTrace.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/LinearTrace.h b/src/auryn/LinearTrace.h index 5d8a268d..f015b057 100644 --- a/src/auryn/LinearTrace.h +++ b/src/auryn/LinearTrace.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Logger.cpp b/src/auryn/Logger.cpp index 36a7eded..b5d38b7d 100644 --- a/src/auryn/Logger.cpp +++ b/src/auryn/Logger.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Logger.h b/src/auryn/Logger.h index f6e7108e..fc0e0831 100644 --- a/src/auryn/Logger.h +++ b/src/auryn/Logger.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/MinimalTripletConnection.cpp b/src/auryn/MinimalTripletConnection.cpp index 58cfed71..326649af 100644 --- a/src/auryn/MinimalTripletConnection.cpp +++ b/src/auryn/MinimalTripletConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/MinimalTripletConnection.h b/src/auryn/MinimalTripletConnection.h index 5e35bb37..d05b7d25 100644 --- a/src/auryn/MinimalTripletConnection.h +++ b/src/auryn/MinimalTripletConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ModSynIFGroup.cpp b/src/auryn/ModSynIFGroup.cpp index 0ed14658..961b24b7 100644 --- a/src/auryn/ModSynIFGroup.cpp +++ b/src/auryn/ModSynIFGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ModSynIFGroup.h b/src/auryn/ModSynIFGroup.h index 3d226d2e..0284eca1 100644 --- a/src/auryn/ModSynIFGroup.h +++ b/src/auryn/ModSynIFGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Monitor.cpp b/src/auryn/Monitor.cpp index 6a5c1992..2a450e92 100644 --- a/src/auryn/Monitor.cpp +++ b/src/auryn/Monitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Monitor.h b/src/auryn/Monitor.h index 92e08fef..363a166d 100644 --- a/src/auryn/Monitor.h +++ b/src/auryn/Monitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/MovingBumpGroup.cpp b/src/auryn/MovingBumpGroup.cpp index 90dace1e..9dd3ec0d 100644 --- a/src/auryn/MovingBumpGroup.cpp +++ b/src/auryn/MovingBumpGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/MovingBumpGroup.h b/src/auryn/MovingBumpGroup.h index dd115aeb..edcb83c1 100644 --- a/src/auryn/MovingBumpGroup.h +++ b/src/auryn/MovingBumpGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/MultiStateMonitor.cpp b/src/auryn/MultiStateMonitor.cpp new file mode 100644 index 00000000..05ffce24 --- /dev/null +++ b/src/auryn/MultiStateMonitor.cpp @@ -0,0 +1,82 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#include "MultiStateMonitor.h" + +using namespace auryn; + +MultiStateMonitor::MultiStateMonitor(std::string filename, AurynDouble stepsize) : StateMonitor(filename, stepsize) +{ +} + +MultiStateMonitor::~MultiStateMonitor() +{ +} + + +void MultiStateMonitor::add_target(AurynState * target) +{ + state_list.push_back(target); +} + +void MultiStateMonitor::add_neuron_range(AurynStateVector * source, NeuronID from, NeuronID to) +{ + for ( unsigned int i = from ; i < to ; ++i ) { + add_target(source->ptr(i)); + } +} + +void MultiStateMonitor::add_neuron_range(AurynStateVector * source) +{ + add_neuron_range(source,0,source->size); +} + +void MultiStateMonitor::add_neuron_range(NeuronGroup * source, std::string statename) +{ + add_neuron_range(source->get_state_vector(statename)); +} + +void MultiStateMonitor::add_neuron_range(NeuronGroup * source, std::string statename, NeuronID from, NeuronID to) +{ + add_neuron_range(source->get_state_vector(statename), from, to); +} + + +void MultiStateMonitor::execute() +{ + if ( auryn::sys->get_clock() < t_stop ) { + if ( (auryn::sys->get_clock())%ssize==0 ) { + outfile << (auryn::sys->get_time()) << " "; + for (std::vector::const_iterator iter = state_list.begin() ; + iter != state_list.end(); + ++iter ) { + outfile << **iter << " "; + } + outfile << "\n"; + } + } +} + + diff --git a/src/auryn/MultiStateMonitor.h b/src/auryn/MultiStateMonitor.h new file mode 100644 index 00000000..a4a485d8 --- /dev/null +++ b/src/auryn/MultiStateMonitor.h @@ -0,0 +1,82 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#ifndef MULTISTATEMONITOR_H_ +#define MULTISTATEMONITOR_H_ + +#define VOLTAGEMONITOR_PASTED_SPIKE_HEIGHT 20e-3 + +#include "auryn_definitions.h" +#include "AurynVector.h" +#include "StateMonitor.h" +#include "System.h" +#include "Connection.h" +#include +#include + +namespace auryn { + +/*! \brief Records a number of state variables from one or more groups to a single file + * + * This Monitor allows to record a number of state variables from a single or several NeuronGroups + * and to write them in a ASCII file that is organized column-wise. Note that this Monitor produces + * huge amounts of data and slows down simulations considerably. It should only be used when you know + * what you ware doing.*/ +class MultiStateMonitor : public StateMonitor +{ +private: + NeuronID gid; + +protected: + + +public: + /*! \brief List to holds pointers to the state variables to record from */ + std::vector state_list; + + MultiStateMonitor(std::string filename, AurynDouble stepsize=auryn_timestep); + virtual ~MultiStateMonitor(); + + /*! \brief Add single target variable to state list */ + void add_target(AurynState * target); + + /*! \brief Adds all elements of a given state vector to the list of monitored variables. */ + void add_neuron_range(AurynStateVector * source); + + /*! \brief Adds a range of elements to the list of monitored variables. */ + void add_neuron_range(AurynStateVector * source, NeuronID from, NeuronID to); + + /*! \brief Adds all elements of the source NeuronGroup and corresponding statename to the list of monitored variables. */ + void add_neuron_range(NeuronGroup * source, std::string statename="mem"); + + /*! \brief Adds a range of elements of the source NeuronGroup and corresponding statename to the list of monitored variables. */ + void add_neuron_range(NeuronGroup * source, std::string statename, NeuronID from, NeuronID to); + + void execute(); +}; + +} + +#endif /*MULTISTATEMONITOR_H_*/ diff --git a/src/auryn/NaudGroup.cpp b/src/auryn/NaudGroup.cpp index a9ef878a..77a1970a 100644 --- a/src/auryn/NaudGroup.cpp +++ b/src/auryn/NaudGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/NaudGroup.h b/src/auryn/NaudGroup.h index 20557a42..0abd9aa8 100644 --- a/src/auryn/NaudGroup.h +++ b/src/auryn/NaudGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/NeuronGroup.cpp b/src/auryn/NeuronGroup.cpp index 78eb501b..7202bb9e 100644 --- a/src/auryn/NeuronGroup.cpp +++ b/src/auryn/NeuronGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/NeuronGroup.h b/src/auryn/NeuronGroup.h index 9fd16549..d266f1cc 100644 --- a/src/auryn/NeuronGroup.h +++ b/src/auryn/NeuronGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/NormalStimulator.cpp b/src/auryn/NormalStimulator.cpp index 8b3bc8e7..aa5516e2 100644 --- a/src/auryn/NormalStimulator.cpp +++ b/src/auryn/NormalStimulator.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/NormalStimulator.h b/src/auryn/NormalStimulator.h index ef79248d..21970bdf 100644 --- a/src/auryn/NormalStimulator.h +++ b/src/auryn/NormalStimulator.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PairInteractionConnection.cpp b/src/auryn/PairInteractionConnection.cpp index 5a92e156..93b878a6 100644 --- a/src/auryn/PairInteractionConnection.cpp +++ b/src/auryn/PairInteractionConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PairInteractionConnection.h b/src/auryn/PairInteractionConnection.h index 66324e98..efa1304c 100644 --- a/src/auryn/PairInteractionConnection.h +++ b/src/auryn/PairInteractionConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ParrotGroup.cpp b/src/auryn/ParrotGroup.cpp index 9823fa9c..092f1c14 100644 --- a/src/auryn/ParrotGroup.cpp +++ b/src/auryn/ParrotGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ParrotGroup.h b/src/auryn/ParrotGroup.h index 088826da..498b9f1a 100644 --- a/src/auryn/ParrotGroup.h +++ b/src/auryn/ParrotGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PatternMonitor.cpp b/src/auryn/PatternMonitor.cpp index ec874cc1..a879c50b 100644 --- a/src/auryn/PatternMonitor.cpp +++ b/src/auryn/PatternMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PatternMonitor.h b/src/auryn/PatternMonitor.h index 65bfb6a3..0ba85005 100644 --- a/src/auryn/PatternMonitor.h +++ b/src/auryn/PatternMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PatternStimulator.cpp b/src/auryn/PatternStimulator.cpp index 6b536ad8..59691bcb 100644 --- a/src/auryn/PatternStimulator.cpp +++ b/src/auryn/PatternStimulator.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PatternStimulator.h b/src/auryn/PatternStimulator.h index 41508ad5..f13eb18e 100644 --- a/src/auryn/PatternStimulator.h +++ b/src/auryn/PatternStimulator.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PoissonGroup.cpp b/src/auryn/PoissonGroup.cpp index 8ecff15d..12ada983 100644 --- a/src/auryn/PoissonGroup.cpp +++ b/src/auryn/PoissonGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PoissonGroup.h b/src/auryn/PoissonGroup.h index 98115935..f7dc1cd2 100644 --- a/src/auryn/PoissonGroup.h +++ b/src/auryn/PoissonGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PoissonSpikeInjector.cpp b/src/auryn/PoissonSpikeInjector.cpp index 5eb89091..d75f5cff 100644 --- a/src/auryn/PoissonSpikeInjector.cpp +++ b/src/auryn/PoissonSpikeInjector.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PoissonSpikeInjector.h b/src/auryn/PoissonSpikeInjector.h index 1b06b7e7..70d954c8 100644 --- a/src/auryn/PoissonSpikeInjector.h +++ b/src/auryn/PoissonSpikeInjector.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PoissonStimulator.cpp b/src/auryn/PoissonStimulator.cpp index 676cb8c8..77c2749a 100644 --- a/src/auryn/PoissonStimulator.cpp +++ b/src/auryn/PoissonStimulator.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PoissonStimulator.h b/src/auryn/PoissonStimulator.h index 3cfd5d9b..e799c66b 100644 --- a/src/auryn/PoissonStimulator.h +++ b/src/auryn/PoissonStimulator.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PopulationRateMonitor.cpp b/src/auryn/PopulationRateMonitor.cpp index 42dfa13d..bc7c6bcf 100644 --- a/src/auryn/PopulationRateMonitor.cpp +++ b/src/auryn/PopulationRateMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/PopulationRateMonitor.h b/src/auryn/PopulationRateMonitor.h index 73bdcaa3..941e6bd0 100644 --- a/src/auryn/PopulationRateMonitor.h +++ b/src/auryn/PopulationRateMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ProfilePoissonGroup.cpp b/src/auryn/ProfilePoissonGroup.cpp index d341d3e6..16eeea5b 100644 --- a/src/auryn/ProfilePoissonGroup.cpp +++ b/src/auryn/ProfilePoissonGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/ProfilePoissonGroup.h b/src/auryn/ProfilePoissonGroup.h index df2028af..5f5372b1 100644 --- a/src/auryn/ProfilePoissonGroup.h +++ b/src/auryn/ProfilePoissonGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RateChecker.cpp b/src/auryn/RateChecker.cpp index 59e5255b..067b1a80 100644 --- a/src/auryn/RateChecker.cpp +++ b/src/auryn/RateChecker.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RateChecker.h b/src/auryn/RateChecker.h index 11912723..105e1fb1 100644 --- a/src/auryn/RateChecker.h +++ b/src/auryn/RateChecker.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RateModulatedConnection.cpp b/src/auryn/RateModulatedConnection.cpp index b1974ba1..741f4d59 100644 --- a/src/auryn/RateModulatedConnection.cpp +++ b/src/auryn/RateModulatedConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RateModulatedConnection.h b/src/auryn/RateModulatedConnection.h index f2260e24..4b7ffaf0 100644 --- a/src/auryn/RateModulatedConnection.h +++ b/src/auryn/RateModulatedConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RateMonitor.cpp b/src/auryn/RateMonitor.cpp index 75b63f0b..6c793f6e 100644 --- a/src/auryn/RateMonitor.cpp +++ b/src/auryn/RateMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RateMonitor.h b/src/auryn/RateMonitor.h index 83fa221b..b16242a4 100644 --- a/src/auryn/RateMonitor.h +++ b/src/auryn/RateMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RealTimeMonitor.cpp b/src/auryn/RealTimeMonitor.cpp index f223e3d7..ffd41f50 100644 --- a/src/auryn/RealTimeMonitor.cpp +++ b/src/auryn/RealTimeMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/RealTimeMonitor.h b/src/auryn/RealTimeMonitor.h index 2ea53c21..96c8c306 100644 --- a/src/auryn/RealTimeMonitor.h +++ b/src/auryn/RealTimeMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SRM0Group.cpp b/src/auryn/SRM0Group.cpp index 145b2e62..10e67e78 100644 --- a/src/auryn/SRM0Group.cpp +++ b/src/auryn/SRM0Group.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SRM0Group.h b/src/auryn/SRM0Group.h index 17f069c5..bdda8217 100644 --- a/src/auryn/SRM0Group.h +++ b/src/auryn/SRM0Group.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/STDPConnection.cpp b/src/auryn/STDPConnection.cpp index b6db61fe..15539a92 100644 --- a/src/auryn/STDPConnection.cpp +++ b/src/auryn/STDPConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/STDPConnection.h b/src/auryn/STDPConnection.h index 92652c92..b4514090 100644 --- a/src/auryn/STDPConnection.h +++ b/src/auryn/STDPConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/STDPwdConnection.cpp b/src/auryn/STDPwdConnection.cpp index b93d0cdf..fba9ec09 100644 --- a/src/auryn/STDPwdConnection.cpp +++ b/src/auryn/STDPwdConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/STDPwdConnection.h b/src/auryn/STDPwdConnection.h index deaa95b7..cab08b6d 100644 --- a/src/auryn/STDPwdConnection.h +++ b/src/auryn/STDPwdConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/STPConnection.cpp b/src/auryn/STPConnection.cpp index 703a341e..54582bfa 100644 --- a/src/auryn/STPConnection.cpp +++ b/src/auryn/STPConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/STPConnection.h b/src/auryn/STPConnection.h index f875e78d..46475368 100644 --- a/src/auryn/STPConnection.h +++ b/src/auryn/STPConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SimpleMatrix.h b/src/auryn/SimpleMatrix.h index df8b5f13..a1dc536f 100644 --- a/src/auryn/SimpleMatrix.h +++ b/src/auryn/SimpleMatrix.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SparseConnection.cpp b/src/auryn/SparseConnection.cpp index d9a2cae4..4a898c13 100644 --- a/src/auryn/SparseConnection.cpp +++ b/src/auryn/SparseConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SparseConnection.h b/src/auryn/SparseConnection.h index bdc0f218..082a4b1e 100644 --- a/src/auryn/SparseConnection.h +++ b/src/auryn/SparseConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SpikeDelay.cpp b/src/auryn/SpikeDelay.cpp index d2e8dd47..4702357e 100644 --- a/src/auryn/SpikeDelay.cpp +++ b/src/auryn/SpikeDelay.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SpikeDelay.h b/src/auryn/SpikeDelay.h index 4420ff5d..c7fb1920 100644 --- a/src/auryn/SpikeDelay.h +++ b/src/auryn/SpikeDelay.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SpikeMonitor.cpp b/src/auryn/SpikeMonitor.cpp index 856e973b..8764491a 100644 --- a/src/auryn/SpikeMonitor.cpp +++ b/src/auryn/SpikeMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SpikeMonitor.h b/src/auryn/SpikeMonitor.h index 359e84bc..97131a1c 100644 --- a/src/auryn/SpikeMonitor.h +++ b/src/auryn/SpikeMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -61,9 +61,6 @@ class SpikeMonitor : public Monitor void free(); public: - /*! Switch variable to enable/disable recording. */ - bool active; - /*! \brief Default constructor * * \param source Specifies the source SpikingGroup to record from diff --git a/src/auryn/SpikeTimingStimGroup.cpp b/src/auryn/SpikeTimingStimGroup.cpp index c59a5a01..ad689041 100644 --- a/src/auryn/SpikeTimingStimGroup.cpp +++ b/src/auryn/SpikeTimingStimGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SpikeTimingStimGroup.h b/src/auryn/SpikeTimingStimGroup.h index d0ff418f..4c3ac225 100644 --- a/src/auryn/SpikeTimingStimGroup.h +++ b/src/auryn/SpikeTimingStimGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SpikingGroup.cpp b/src/auryn/SpikingGroup.cpp index 06a066c1..cd09e3ef 100644 --- a/src/auryn/SpikingGroup.cpp +++ b/src/auryn/SpikingGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -31,7 +31,6 @@ int SpikingGroup::last_locked_rank = 0; NeuronID SpikingGroup::unique_id_count = 0; - AurynTime * SpikingGroup::clock_ptr = NULL; diff --git a/src/auryn/SpikingGroup.h b/src/auryn/SpikingGroup.h index 82afe4f9..6f724a51 100644 --- a/src/auryn/SpikingGroup.h +++ b/src/auryn/SpikingGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -84,8 +84,6 @@ class SpikingGroup /*! Stores the current value of the gid count */ static NeuronID unique_id_count; - /*! Standard initialization of the object. */ - void init( NeuronID size, NodeDistributionMode mode ); void lock_range( double rank_fraction ); /*! If not distributed the first rank to lock it to. */ @@ -95,12 +93,15 @@ class SpikingGroup /*! Keeps track on where rank-locking is */ static int last_locked_rank; - bool evolve_locally_bool; + /*! Standard initialization of the object. */ + void init( NeuronID size, NodeDistributionMode mode ); /*! Stores axonal delay value - by default MINDELAY */ int axonaldelay; protected: + bool evolve_locally_bool; + /*! \brief Pretraces */ std::vector pretraces; @@ -137,6 +138,7 @@ class SpikingGroup /*! \brief Implementatinon of serialize function for reading. */ virtual void virtual_serialize(boost::archive::binary_iarchive & ar, const unsigned int version ); + /*! \brief Frees potentially allocated memory */ void free(); diff --git a/src/auryn/StateMonitor.cpp b/src/auryn/StateMonitor.cpp index abb7e761..4bf50394 100644 --- a/src/auryn/StateMonitor.cpp +++ b/src/auryn/StateMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -90,6 +90,17 @@ StateMonitor::StateMonitor(Trace * trace, NeuronID id, std::string filename, Aur lastval = *target_variable; } +StateMonitor::StateMonitor(std::string filename, AurynDouble sampling_interval): Monitor(filename, "state") +{ + init(filename, sampling_interval); + + auryn::sys->register_device(this); + src = NULL; + nid = 0; + target_variable = NULL; + // lastval = *target_variable; +} + void StateMonitor::init(std::string filename, AurynDouble sampling_interval) { outfile << std::setiosflags(std::ios::fixed) << std::setprecision(6); diff --git a/src/auryn/StateMonitor.h b/src/auryn/StateMonitor.h index f75621a9..12ca9ad6 100644 --- a/src/auryn/StateMonitor.h +++ b/src/auryn/StateMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -108,6 +108,15 @@ class StateMonitor : public Monitor */ StateMonitor(Trace * trace, NeuronID id, string filename, AurynDouble sampling_interval=auryn_timestep); + /*! \brief NIL constructor + * + * Constructs a StateMonitor without specifying a state. This is mostly used for MultiStateMonitor. + * + * \param filename The filename of the file to dump the output to + * \param sampling_interval The sampling interval in seconds + */ + StateMonitor(string filename, AurynDouble sampling_interval=auryn_timestep); + /*! \brief Sets relative time at which to stop recording * * The time is given in seconds and interpreted as relative time with diff --git a/src/auryn/StimulusGroup.cpp b/src/auryn/StimulusGroup.cpp index 775e8d91..ff5a1166 100644 --- a/src/auryn/StimulusGroup.cpp +++ b/src/auryn/StimulusGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -192,7 +192,7 @@ void StimulusGroup::evolve() if ( binary_patterns ) { // binary patterns // detect and push spikes - boost::exponential_distribution<> dist(curscale); + boost::exponential_distribution<> dist(curscale*base_rate); boost::variate_generator > die(poisson_gen, dist); type_pattern current = stimuli[cur_stim_index]; @@ -454,7 +454,6 @@ void StimulusGroup::set_pattern_activity(unsigned int i) if ( background_during_stimulus ) addrate = background_rate; - AurynFloat curscale = scale; if ( randomintensities ) { boost::exponential_distribution<> dist(1.); boost::variate_generator > die(order_gen, dist); @@ -463,7 +462,7 @@ void StimulusGroup::set_pattern_activity(unsigned int i) for ( iter = current.begin() ; iter != current.end() ; ++iter ) { - set_activity(iter->i,curscale*iter->gamma+addrate); + set_activity(iter->i,base_rate*curscale*iter->gamma+addrate); } } diff --git a/src/auryn/StimulusGroup.h b/src/auryn/StimulusGroup.h index 91e15e00..ce55bc17 100644 --- a/src/auryn/StimulusGroup.h +++ b/src/auryn/StimulusGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/StructuredPoissonGroup.cpp b/src/auryn/StructuredPoissonGroup.cpp index c4dcce83..53a29e9b 100644 --- a/src/auryn/StructuredPoissonGroup.cpp +++ b/src/auryn/StructuredPoissonGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/StructuredPoissonGroup.h b/src/auryn/StructuredPoissonGroup.h index 057ae9ab..d17060d2 100644 --- a/src/auryn/StructuredPoissonGroup.h +++ b/src/auryn/StructuredPoissonGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SymmetricSTDPConnection.cpp b/src/auryn/SymmetricSTDPConnection.cpp index 85dcaeb1..376dae7e 100644 --- a/src/auryn/SymmetricSTDPConnection.cpp +++ b/src/auryn/SymmetricSTDPConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SymmetricSTDPConnection.h b/src/auryn/SymmetricSTDPConnection.h index 26fbd6b0..a8f212bf 100644 --- a/src/auryn/SymmetricSTDPConnection.h +++ b/src/auryn/SymmetricSTDPConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SynapseModel.cpp b/src/auryn/SynapseModel.cpp index ff75dddd..4e470e36 100644 --- a/src/auryn/SynapseModel.cpp +++ b/src/auryn/SynapseModel.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SynapseModel.h b/src/auryn/SynapseModel.h index 2b2f98f9..136f72d0 100644 --- a/src/auryn/SynapseModel.h +++ b/src/auryn/SynapseModel.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/SyncBuffer.cpp b/src/auryn/SyncBuffer.cpp index e0496610..3b7b7813 100644 --- a/src/auryn/SyncBuffer.cpp +++ b/src/auryn/SyncBuffer.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -40,6 +40,11 @@ SyncBuffer::~SyncBuffer( ) delete [] pop_offsets; delete [] pop_delta_spikes; delete [] last_spike_pos; + + delete [] rank_send_sum; + delete [] rank_send_sum2; + delete [] rank_recv_count; + delete [] rank_displs; } void SyncBuffer::init() @@ -48,6 +53,8 @@ void SyncBuffer::init() /* Overflow value for syncbuffer */ overflow_value = std::numeric_limits::max(); + overflow_counter = 0; + /* Maximum delta size. We make this one smaller than max to avoid problems * if the datatype is the same as NeuronID and then the max corresponds * to the overflow value in send buffer ... */ @@ -66,12 +73,20 @@ void SyncBuffer::init() } - maxSendSum = 0; - maxSendSum2 = 0; - syncCount = 0; - + sync_counter = 0; max_send_size = 4; - recv_buf.resize(mpicom->size()*max_send_size); + + rank_send_sum = new int[mpicom->size()]; + rank_send_sum2 = new int[mpicom->size()]; + rank_recv_count = new int[mpicom->size()]; + rank_displs = new int[mpicom->size()]; + for ( int r = 0 ; rsize() ; ++r ) { + rank_send_sum[r] = 0; + rank_send_sum2[r] = 0; + rank_recv_count[r] = 2; // make space for overflow + } + + resize_buffers(max_send_size); reset_send_buffer(); @@ -248,26 +263,151 @@ void SyncBuffer::pop(SpikeDelay * delay, const NeuronID size) #endif // DEBUG } +int SyncBuffer::compute_buffer_margin(int n, int sum, int sum2) +{ + const int mean = sum/n; + const int var = (sum2/n-mean*mean); + const int marg = SYNCBUFFER_SIZE_MARGIN_MULTIPLIER*std::sqrt(var); + return marg; +} -void SyncBuffer::sync() +int SyncBuffer::compute_buffer_size_with_margin(int n, int sum, int sum2) +{ + const int mean = sum/n; + const int uest = mean+compute_buffer_margin(n, sum, sum2); + return uest; +} + + +void SyncBuffer::update_send_recv_counts() { - if ( syncCount >= SYNCBUFFER_SIZE_HIST_LEN ) { // update the estimate of maximum send size - NeuronID mean_send_size = maxSendSum/syncCount; - NeuronID var_send_size = (maxSendSum2-mean_send_size*mean_send_size)/syncCount; - NeuronID upper_estimate = mean_send_size+SYNCBUFFER_SIZE_MARGIN_MULTIPLIER*sqrt(var_send_size); - - if ( max_send_size > upper_estimate && max_send_size > 4 ) { - max_send_size = (max_send_size+upper_estimate)/2; - recv_buf.resize(mpicom->size()*max_send_size); + // update per rank send size estimates + for ( int i = 0 ; isize() ; ++i ) { + const int uest = compute_buffer_size_with_margin(sync_counter,rank_send_sum[i],rank_send_sum2[i]); + if ( rank_recv_count[i] > uest && rank_recv_count[i] > 4 ) { + rank_recv_count[i] = rank_recv_count[i]+(uest-rank_recv_count[i])/2; + } else { + rank_recv_count[i] = uest; + } + + rank_send_sum[i] = 0; + rank_send_sum2[i] = 0; + } + + // find max send/recv value for max_send_size + int new_max_send_size = 0; + for ( int i = 0 ; isize() ; ++i ) { + new_max_send_size = std::max(rank_recv_count[i],new_max_send_size); + } + + if (max_send_size!=new_max_send_size) { + max_send_size = new_max_send_size; + resize_buffers(max_send_size); + } + + sync_counter = 0; +} + + +void SyncBuffer::sync_allgatherv() +{ + if ( sync_counter >= SYNCBUFFER_SIZE_HIST_LEN ) { // update the estimate of maximum send size + update_send_recv_counts(); + } + + int ierr = 0; + +#ifdef CODE_COLLECT_SYNC_TIMING_STATS + double T1, T2; + T1 = MPI_Wtime(); /* start time */ +#endif + + if ( send_buf.size() <= rank_recv_count[mpicom->rank()] ) { + send_buf[0] = send_buf.size(); + ierr = MPI_Allgatherv(send_buf.data(), rank_recv_count[mpicom->rank()], MPI_UNSIGNED, + recv_buf.data(), rank_recv_count, rank_displs, MPI_UNSIGNED, *mpicom); + } else { + // Create an overflow package + NeuronID * overflow_data; + overflow_data = new NeuronID[rank_recv_count[mpicom->rank()]]; + // overflow_data = new NeuronID[max_send_size]; + overflow_data[0] = overflow_value; + overflow_data[1] = send_buf.size(); + ierr = MPI_Allgatherv(overflow_data, rank_recv_count[mpicom->rank()], MPI_UNSIGNED, + recv_buf.data(), rank_recv_count, rank_displs, MPI_UNSIGNED, *mpicom); + delete [] overflow_data; + } + + // error handling + if ( ierr ) { + std::cerr << "Error during MPI_Allgatherv." << std::endl; + switch (ierr) { + case MPI_ERR_COMM: std::cerr << "(MPI_ERR_COMM)." ; break; + case MPI_ERR_COUNT: std::cerr << "(MPI_ERR_COUNT)." ; break; + case MPI_ERR_TYPE: std::cerr << "(MPI_ERR_TYPE)." ; break; + case MPI_ERR_BUFFER: std::cerr << "(MPI_ERR_BUFFER)." ; break; + default: std::cerr << "ierr = " << ierr ; break; + } + std::cerr << std::endl; + MPI::COMM_WORLD.Abort(-1); + } + +#ifdef CODE_COLLECT_SYNC_TIMING_STATS + T2 = MPI_Wtime(); /* end time */ + deltaT += (T2-T1); +#endif + + /* Detect overflow */ + bool overflow = false; + int new_send_size = 0; + for (int r = 0 ; r < mpicom->size() ; ++r ) { + if ( recv_buf[r*max_send_size]==overflow_value ) { + overflow = true; + const NeuronID value = recv_buf[r*max_send_size+1]; + rank_recv_count[r] = std::max(value,(unsigned int)2); // leave enough space for an overflow package + if ( value > new_send_size ) { + new_send_size = value; + } + } + } + + + if ( overflow ) { + // std::cout << "overflow" << std::endl; #ifdef DEBUG - std::cerr << "Reducing maximum send buffer size to " - << max_send_size - << std::endl; + std::cerr << "Overflow in SyncBuffer adapting buffersize to " + << (new_send_size+2)*sizeof(NeuronID) + << " ( " + << mpicom->size()*(new_send_size+2)*sizeof(NeuronID) + << " total ) " + << std::endl; #endif //DEBUG - } - maxSendSum = 0; - maxSendSum2 = 0; - syncCount = 0; + ++overflow_counter; + max_send_size = std::max(new_send_size+2,max_send_size); + resize_buffers(max_send_size); + // resend full buffer + ierr = MPI_Allgatherv(send_buf.data(), rank_recv_count[mpicom->rank()], MPI_UNSIGNED, + recv_buf.data(), rank_recv_count, rank_displs, MPI_UNSIGNED, *mpicom); + } + + for ( int r = 0 ; r < mpicom->size() ; ++r ) { + const unsigned int val = recv_buf[r*max_send_size]; + rank_send_sum[r] += val; + rank_send_sum2[r] += val*val; + } + sync_counter++; + + // update senc/recv counters and buffers earlier if there was an overflow and we have some stats + // if ( overflow && sync_counter>10 ) update_send_recv_counts(); + + reset_send_buffer(); +} + + +void SyncBuffer::sync_allgather() +{ + if ( sync_counter >= SYNCBUFFER_SIZE_HIST_LEN ) { // update the estimate of maximum send size + update_send_recv_counts(); } int ierr = 0; @@ -276,24 +416,35 @@ void SyncBuffer::sync() double T1, T2; T1 = MPI_Wtime(); /* start time */ #endif + + // if ( send_buf.size() <= rank_recv_count[mpicom->rank()] ) { if ( send_buf.size() <= max_send_size ) { + send_buf[0] = send_buf.size(); ierr = MPI_Allgather(send_buf.data(), max_send_size, MPI_UNSIGNED, recv_buf.data(), max_send_size, MPI_UNSIGNED, *mpicom); } else { // Create an overflow package - // std::cout << " overflow " << overflow_value << " " << send_buf.size() << std::endl; - NeuronID overflow_data [max_send_size]; + NeuronID * overflow_data; + overflow_data = new NeuronID[max_send_size]; overflow_data[0] = overflow_value; overflow_data[1] = send_buf.size(); - ierr = MPI_Allgather(&overflow_data, max_send_size, MPI_UNSIGNED, - recv_buf.data(), max_send_size, MPI_UNSIGNED, *mpicom); + ierr = MPI_Allgather(overflow_data, max_send_size, MPI_UNSIGNED, + recv_buf.data(), max_send_size, MPI_UNSIGNED, *mpicom); + delete [] overflow_data; } - // error handling if ( ierr ) { std::cerr << "Error during MPI_Allgather." << std::endl; - // TODO add an exception to actually break the run here + switch (ierr) { + case MPI_ERR_COMM: std::cerr << "(MPI_ERR_COMM)." ; break; + case MPI_ERR_COUNT: std::cerr << "(MPI_ERR_COUNT)." ; break; + case MPI_ERR_TYPE: std::cerr << "(MPI_ERR_TYPE)." ; break; + case MPI_ERR_BUFFER: std::cerr << "(MPI_ERR_BUFFER)." ; break; + default: std::cerr << "ierr = " << ierr ; break; + } + std::cerr << std::endl; + MPI::COMM_WORLD.Abort(-1); } #ifdef CODE_COLLECT_SYNC_TIMING_STATS @@ -303,11 +454,12 @@ void SyncBuffer::sync() /* Detect overflow */ bool overflow = false; - NeuronID new_send_size = 0; + int new_send_size = 0; for (int r = 0 ; r < mpicom->size() ; ++r ) { if ( recv_buf[r*max_send_size]==overflow_value ) { overflow = true; - NeuronID value = recv_buf[r*max_send_size+1]; + const NeuronID value = recv_buf[r*max_send_size+1]; + rank_recv_count[r] = std::max(value,(unsigned int)2); // leave enough space for an overflow package if ( value > new_send_size ) { new_send_size = value; } @@ -318,50 +470,79 @@ void SyncBuffer::sync() if ( overflow ) { #ifdef DEBUG std::cerr << "Overflow in SyncBuffer adapting buffersize to " - << (new_send_size+1)*sizeof(NeuronID) + << (new_send_size+2)*sizeof(NeuronID) << " ( " - << mpicom->size()*(new_send_size+1)*sizeof(NeuronID) + << mpicom->size()*(new_send_size+2)*sizeof(NeuronID) << " total ) " << std::endl; #endif //DEBUG - max_send_size = new_send_size+2; - recv_buf.resize(mpicom->size()*max_send_size); + ++overflow_counter; + max_send_size = std::max(new_send_size+2,max_send_size); + resize_buffers(max_send_size); // resend full buffer - ierr = MPI_Allgather(send_buf.data(), send_buf.size(), MPI_UNSIGNED, - recv_buf.data(), max_send_size, MPI_UNSIGNED, *mpicom); + ierr = MPI_Allgather(send_buf.data(), max_send_size, MPI_UNSIGNED, + recv_buf.data(), max_send_size, MPI_UNSIGNED, *mpicom); } - // reset - NeuronID largest_message = 0; - for ( int i = 0 ; i < mpicom->size() ; ++i ) { - largest_message = std::max(pop_offsets[i],largest_message); + for ( int r = 0 ; r < mpicom->size() ; ++r ) { + const unsigned int val = recv_buf[r*max_send_size]; + rank_send_sum[r] += val; + rank_send_sum2[r] += val*val; } - maxSendSum += largest_message; - maxSendSum2 += largest_message*largest_message; - + sync_counter++; - syncCount++; + // update senc/recv counters and buffers earlier if there was an overflow and we have some stats + // if ( overflow && sync_counter>10 ) update_send_recv_counts(); reset_send_buffer(); } +void SyncBuffer::sync() +{ + // allgather seems to be faster on the standard sim_background benchmark + // however, replacing the following line by synchronize will run the new + // code using Allgatherv in which each rank can send different amounts of data. + sync_allgather(); +} + void SyncBuffer::reset_send_buffer() { send_buf.clear(); + send_buf.push_back(0); // reset carry offsets for push and pop functions carry_offset = 0; for ( int i = 0 ; i < mpicom->size() ; ++i ) { - pop_offsets[i] = 0; + pop_offsets[i] = 1; pop_delta_spikes[i] = undefined_delta_size; } } +void SyncBuffer::resize_buffers(NeuronID send_size) +{ + send_buf.reserve(send_size); + recv_buf.resize(mpicom->size()*send_size); + // std::cout << "cap " << recv_buf.capacity() << std::endl; + for ( int r = 0 ; rsize() ; ++r ) { + rank_displs[r] = r*send_size; + } +} + int SyncBuffer::get_max_send_buffer_size() { return max_send_size; } +unsigned int SyncBuffer::get_overflow_count() +{ + return overflow_counter; +} + +unsigned int SyncBuffer::get_sync_count() +{ + return sync_counter; +} + #ifdef CODE_COLLECT_SYNC_TIMING_STATS AurynDouble SyncBuffer::get_relative_sync_time() { diff --git a/src/auryn/SyncBuffer.h b/src/auryn/SyncBuffer.h index 1c319bee..8a870061 100644 --- a/src/auryn/SyncBuffer.h +++ b/src/auryn/SyncBuffer.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -28,7 +28,7 @@ #define SYNCBUFFER_H_ -#define SYNCBUFFER_SIZE_MARGIN_MULTIPLIER 3 //!< Safety margin for receive buffer size -- a value of 3 should make overflows rare in AI state +#define SYNCBUFFER_SIZE_MARGIN_MULTIPLIER 5 //!< Safety margin for receive buffer size -- a value of 3 should make overflows rare in AI state #define SYNCBUFFER_SIZE_HIST_LEN 512 //!< Accumulate history over this number of timesteps before updating the sendbuffer size in the absence of overflows /*! \brief Datatype used for delta computation should be a "long" for large nets with sparse activity otherwise NeuronID @@ -61,18 +61,20 @@ namespace auryn { std::vector recv_buf; NeuronID overflow_value; + unsigned int overflow_counter; SYNCBUFFER_DELTA_DATATYPE max_delta_size; SYNCBUFFER_DELTA_DATATYPE undefined_delta_size; + unsigned int sync_counter; - // NeuronID size_history[SYNCBUFFER_SIZE_HIST_LEN]; - NeuronID maxSendSum; - NeuronID maxSendSum2; - NeuronID syncCount; + int * rank_send_sum; + int * rank_send_sum2; + int * rank_recv_count; + int * rank_displs; /*! \brief The send buffer size that all ranks agree upon */ - NeuronID max_send_size; + int max_send_size; mpi::communicator * mpicom; @@ -83,18 +85,30 @@ namespace auryn { SYNCBUFFER_DELTA_DATATYPE * last_spike_pos; /*! \brief vector with offset values to allow to pop more than one delay */ - NeuronID * pop_offsets; + unsigned int * pop_offsets; void reset_send_buffer(); + void resize_buffers(unsigned int send_size); void init(); void free(); + void update_send_recv_counts(); + int compute_buffer_margin(int n, int sum, int sum2); + int compute_buffer_size_with_margin(int n, int sum, int sum2); + /*! \brief Reads the next spike delta */ NeuronID * read_delta_spike_from_buffer(NeuronID * iter, SYNCBUFFER_DELTA_DATATYPE & delta); /*! \brief Reads a single spike attribute */ NeuronID * read_attribute_from_buffer(NeuronID * iter, AurynFloat & attrib); + + /*! \brief Synchronize spikes using Allgatherv (different sized data size per rank) */ + void sync_allgatherv(); + + /*! \brief Synchronize spikes using Allgather (same size data per rank) */ + void sync_allgather(); + public: /*! \brief The default contructor. */ @@ -118,6 +132,12 @@ namespace auryn { /*! \brief Return max_send_size value which determines the size of the MPI AllGather operation. */ int get_max_send_buffer_size(); + /*! \brief Return sync count since object instantiation. */ + unsigned int get_sync_count(); + + /*! \brief Return overflow count since object instantiation. */ + unsigned int get_overflow_count(); + #ifdef CODE_COLLECT_SYNC_TIMING_STATS AurynDouble deltaT; AurynDouble measurement_start; diff --git a/src/auryn/System.cpp b/src/auryn/System.cpp index 91ba473a..8bb2fced 100644 --- a/src/auryn/System.cpp +++ b/src/auryn/System.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -92,11 +92,13 @@ void System::init() { << std::numeric_limits::max()-1 << " cells."; auryn::logger->msg(oss.str(),INFO); +#ifdef AURYN_CODE_USE_MPI if ( sizeof(NeuronID) != sizeof(AurynFloat) ) { oss.str(""); oss << " NeuronID and AurynFloat have different byte sizes which is not supported by SyncBuffer."; auryn::logger->msg(oss.str(),ERROR); } +#endif // AURYN_CODE_USE_MPI oss.str(""); oss << "Simulation timestep is set to " @@ -199,8 +201,19 @@ void System::free() #ifdef AURYN_CODE_USE_MPI - if ( syncbuffer != NULL ) + if ( syncbuffer != NULL ) { + if ( get_clock() > 0 && mpi_rank()==0 ) { + const double relative_overflow_rate = 1.0*syncbuffer->get_overflow_count()/get_clock()*MINDELAY; + std::stringstream oss; + oss << "System:: Freeing SyncBuffer (overflow count=" + << syncbuffer->get_overflow_count() << ", " + << std::scientific << std::setprecision(5) + << "rel. overflow rate=" << relative_overflow_rate << ")"; + logger->info(oss.str()); + } + logger->debug("System:: Freeing SyncBuffer"); delete syncbuffer; + } #endif // AURYN_CODE_USE_MPI delete seed_dist; @@ -321,15 +334,15 @@ void System::evolve() void System::evolve_connections() { - for ( std::vector::const_iterator iter = spiking_groups.begin() ; - iter != spiking_groups.end() ; - ++iter ) - (*iter)->evolve_traces(); // evolve only if existing on rank - for ( std::vector::const_iterator iter = connections.begin() ; iter != connections.end() ; ++iter ) (*iter)->evolve(); + + for ( std::vector::const_iterator iter = spiking_groups.begin() ; + iter != spiking_groups.end() ; + ++iter ) + (*iter)->evolve_traces(); // evolve only if existing on rank } void System::propagate() @@ -469,7 +482,7 @@ bool System::run(AurynTime starttime, AurynTime stoptime, AurynFloat total_time, if ( (mpi_rank()==0) && (not quiet) && ( (get_clock()%progressbar_update_interval==0) || get_clock()==(stoptime-1) ) ) { double fraction = 1.0*(get_clock()-starttime+1)*auryn_timestep/total_time; - progressbar(fraction,get_clock()); // TODO find neat solution for the rate + progressbar(fraction, get_clock()); // TODO find neat solution for the rate } if ( get_clock()%LOGGER_MARK_INTERVAL==0 && get_clock()>0 ) // set a mark @@ -504,18 +517,25 @@ bool System::run(AurynTime starttime, AurynTime stoptime, AurynFloat total_time, // Auryn duty cycle evolve(); // Evolve state of NeuronGroups propagate(); // Propagate spikes through connections and implement plasticity - execute_devices(); // Calls Monitors for recording or other devices to interfere with sim - if ( checking ) { // run checkers to break run if needed + // Updates the internal state of connection instances + // (eg update synaptic traces etc) + // traditionally this is run after propagate for a simpler + // implementation of triplet models, however, might consider + // changing this in the future + evolve_connections(); + + // Call all Devices and Monitors + execute_devices(); + + // run checkers and break run if needed + if ( checking ) { if (!execute_checkers()) { return false; } } - // Updates the internal state of connection instances - // (eg update synaptic traces etc) - evolve_connections(); - + // increment kernel clock step(); #ifdef AURYN_CODE_USE_MPI diff --git a/src/auryn/System.h b/src/auryn/System.h index 33b8b417..5f3fbf0a 100644 --- a/src/auryn/System.h +++ b/src/auryn/System.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TIFGroup.cpp b/src/auryn/TIFGroup.cpp index 7f5caac3..b739a83d 100644 --- a/src/auryn/TIFGroup.cpp +++ b/src/auryn/TIFGroup.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TIFGroup.h b/src/auryn/TIFGroup.h index 629e6d59..80bc529e 100644 --- a/src/auryn/TIFGroup.h +++ b/src/auryn/TIFGroup.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Trace.cpp b/src/auryn/Trace.cpp index 94225e64..9608ab57 100644 --- a/src/auryn/Trace.cpp +++ b/src/auryn/Trace.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/Trace.h b/src/auryn/Trace.h index 0c821b8a..02936707 100644 --- a/src/auryn/Trace.h +++ b/src/auryn/Trace.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TripletConnection.cpp b/src/auryn/TripletConnection.cpp index 608a8785..fe0ef7ce 100644 --- a/src/auryn/TripletConnection.cpp +++ b/src/auryn/TripletConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TripletConnection.h b/src/auryn/TripletConnection.h index a912cb04..f056e935 100644 --- a/src/auryn/TripletConnection.h +++ b/src/auryn/TripletConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TripletDecayConnection.cpp b/src/auryn/TripletDecayConnection.cpp index afa861ff..859fd9e4 100644 --- a/src/auryn/TripletDecayConnection.cpp +++ b/src/auryn/TripletDecayConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TripletDecayConnection.h b/src/auryn/TripletDecayConnection.h index a83b3b8b..21253e4b 100644 --- a/src/auryn/TripletDecayConnection.h +++ b/src/auryn/TripletDecayConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TripletScalingConnection.cpp b/src/auryn/TripletScalingConnection.cpp index 2414df2a..9849e834 100644 --- a/src/auryn/TripletScalingConnection.cpp +++ b/src/auryn/TripletScalingConnection.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/TripletScalingConnection.h b/src/auryn/TripletScalingConnection.h index 7aa4901c..a19005de 100644 --- a/src/auryn/TripletScalingConnection.h +++ b/src/auryn/TripletScalingConnection.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/VoltageClamp.cpp b/src/auryn/VoltageClamp.cpp new file mode 100644 index 00000000..6b810095 --- /dev/null +++ b/src/auryn/VoltageClamp.cpp @@ -0,0 +1,74 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#include "VoltageClamp.h" + +using namespace auryn; + +VoltageClamp::VoltageClamp(NeuronGroup * target, std::string time_series_file, std::string neuron_state_name ) : FileCurrentInjector(target, time_series_file, neuron_state_name ) +{ + +} + + + +VoltageClamp::~VoltageClamp() +{ + +} + + +AurynState VoltageClamp::get_current_clamping_value() +{ + + AurynTime index = sys->get_clock(); + if ( loop ) { + index = sys->get_clock()%loop_grid; + } + + if ( index < current_time_series->size() ) { + return current_time_series->at( index ); + } else { + return 0.0; + } +} + +void VoltageClamp::execute() +{ + if ( dst->evolve_locally() ) { + AurynState cur = get_current_clamping_value(); + switch ( mode ) { + case LIST: + for ( int i = 0 ; i < target_neuron_ids->size() ; ++i ) { + target_vector->set(target_neuron_ids->at(i),cur); + } + break; + case ALL: + default: + target_vector->set_all(cur); + } + } +} + diff --git a/src/auryn/VoltageClamp.h b/src/auryn/VoltageClamp.h new file mode 100644 index 00000000..a683d8f1 --- /dev/null +++ b/src/auryn/VoltageClamp.h @@ -0,0 +1,97 @@ +/* +* Copyright 2014-2023 Friedemann Zenke +* +* This file is part of Auryn, a simulation package for plastic +* spiking neural networks. +* +* Auryn 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 3 of the License, or +* (at your option) any later version. +* +* Auryn 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 Auryn. If not, see . +* +* If you are using Auryn or parts of it for your work please cite: +* Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations +* of spiking neural networks using general-purpose computers. +* Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076 +*/ + +#ifndef VOLTAGECLAMP_H_ +#define VOLTAGECLAMP_H_ + +#include "auryn_definitions.h" +#include "AurynVector.h" +#include "System.h" +#include "Logger.h" +#include "Device.h" +#include "NeuronGroup.h" +#include "FileCurrentInjector.h" + + +namespace auryn { + +/*! \brief Stimulator class that implements a voltage clamp with temporal dynamics. + * + * Most commonly used to inject "currents" to arbitraty neuronal states. Maintains an internal vector with + * numbers which are added (times auryn_timestep) in each timestep to the neuronal target vector + * (per default that is the membrane voltage and hence the operation corresponds to injecting a current). + * Note that because of this current units of VoltageClamp are in a sense arbitrary because they depend + * on the neuron model. The scale of inputs can be with the set_scale runction. + * + * Upon construction the VoltageClamp accepts a human readable file in + * two-column format which stores the current time series. The first column + * should contain the time in s and the second column the corresponding current + * values. Missing current values are interpolated linearly. + * Here is an example for a valid time series file: + * + * 0.000000 0.000000 + * 0.050000 0.125333 + * 0.100000 0.248690 + * 0.150000 0.368125 + * 0.200000 0.481754 + * 0.250000 0.587785 + * 0.300000 0.684547 + * + * + */ + + +class VoltageClamp : public FileCurrentInjector +{ +private: + void free(); + + /*! \brief compute current current value from sys clock */ + AurynState get_current_clamping_value(); + +protected: + + + +public: + + /*! \brief Default Constructor + * @param[target] The target group + * @param[time_series_file] The path to the file holding the time series to inject + * @param[neuron_state_name] The state to manipulate + */ + VoltageClamp(NeuronGroup * target, std::string time_series_file, std::string neuron_state_name="mem" ); + + /*! \brief Default Destructor */ + virtual ~VoltageClamp(); + + /*! Implementation of necessary propagate() function. */ + void execute(); + +}; + +} + +#endif /*VOLTAGECLAMP_H_*/ diff --git a/src/auryn/VoltageClampMonitor.cpp b/src/auryn/VoltageClampMonitor.cpp index deb757b1..85206db2 100644 --- a/src/auryn/VoltageClampMonitor.cpp +++ b/src/auryn/VoltageClampMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/VoltageClampMonitor.h b/src/auryn/VoltageClampMonitor.h index f33f9f5a..5465b5b8 100644 --- a/src/auryn/VoltageClampMonitor.h +++ b/src/auryn/VoltageClampMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/VoltageMonitor.cpp b/src/auryn/VoltageMonitor.cpp index abeaf0ca..fb1c0d0a 100644 --- a/src/auryn/VoltageMonitor.cpp +++ b/src/auryn/VoltageMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/VoltageMonitor.h b/src/auryn/VoltageMonitor.h index 2b7f2f23..9fc4fe78 100644 --- a/src/auryn/VoltageMonitor.h +++ b/src/auryn/VoltageMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightChecker.cpp b/src/auryn/WeightChecker.cpp index 3d2f9255..6b782d5e 100644 --- a/src/auryn/WeightChecker.cpp +++ b/src/auryn/WeightChecker.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightChecker.h b/src/auryn/WeightChecker.h index 5491d352..56c1f972 100644 --- a/src/auryn/WeightChecker.h +++ b/src/auryn/WeightChecker.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightMatrixMonitor.cpp b/src/auryn/WeightMatrixMonitor.cpp index c2b72613..78721476 100644 --- a/src/auryn/WeightMatrixMonitor.cpp +++ b/src/auryn/WeightMatrixMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightMatrixMonitor.h b/src/auryn/WeightMatrixMonitor.h index 2656da01..36a8ac99 100644 --- a/src/auryn/WeightMatrixMonitor.h +++ b/src/auryn/WeightMatrixMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightMonitor.cpp b/src/auryn/WeightMonitor.cpp index f0107c8b..3cc48392 100644 --- a/src/auryn/WeightMonitor.cpp +++ b/src/auryn/WeightMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightMonitor.h b/src/auryn/WeightMonitor.h index 61f7797b..6a6a2a8e 100644 --- a/src/auryn/WeightMonitor.h +++ b/src/auryn/WeightMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightPatternMonitor.cpp b/src/auryn/WeightPatternMonitor.cpp index 0d6a476b..89113ebe 100644 --- a/src/auryn/WeightPatternMonitor.cpp +++ b/src/auryn/WeightPatternMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightPatternMonitor.h b/src/auryn/WeightPatternMonitor.h index c8b6dc16..a9905068 100644 --- a/src/auryn/WeightPatternMonitor.h +++ b/src/auryn/WeightPatternMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightStatsMonitor.cpp b/src/auryn/WeightStatsMonitor.cpp index f1711e53..d9335de3 100644 --- a/src/auryn/WeightStatsMonitor.cpp +++ b/src/auryn/WeightStatsMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightStatsMonitor.h b/src/auryn/WeightStatsMonitor.h index b5f03c55..cd5a52b0 100644 --- a/src/auryn/WeightStatsMonitor.h +++ b/src/auryn/WeightStatsMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightSumMonitor.cpp b/src/auryn/WeightSumMonitor.cpp index 0b7bb1ac..eaa1f035 100644 --- a/src/auryn/WeightSumMonitor.cpp +++ b/src/auryn/WeightSumMonitor.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/WeightSumMonitor.h b/src/auryn/WeightSumMonitor.h index 99c4db67..b7aa6b3a 100644 --- a/src/auryn/WeightSumMonitor.h +++ b/src/auryn/WeightSumMonitor.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/auryn_definitions.cpp b/src/auryn/auryn_definitions.cpp index 23507046..c1164ac1 100644 --- a/src/auryn/auryn_definitions.cpp +++ b/src/auryn/auryn_definitions.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/auryn_definitions.h b/src/auryn/auryn_definitions.h index 7a4637a1..5fdeb3b1 100644 --- a/src/auryn/auryn_definitions.h +++ b/src/auryn/auryn_definitions.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. @@ -107,6 +107,7 @@ #include #include #include +#include #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY #ifndef CODE_ACTIVATE_CILK_INSTRUCTIONS diff --git a/src/auryn/auryn_global.cpp b/src/auryn/auryn_global.cpp index b8f3cc73..edbcccaa 100644 --- a/src/auryn/auryn_global.cpp +++ b/src/auryn/auryn_global.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/auryn_global.h b/src/auryn/auryn_global.h index aca3a3cc..487cee35 100644 --- a/src/auryn/auryn_global.h +++ b/src/auryn/auryn_global.h @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2023 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/src/auryn/mk_version_info.sh b/src/auryn/mk_version_info.sh index 894001aa..a44533ec 100755 --- a/src/auryn/mk_version_info.sh +++ b/src/auryn/mk_version_info.sh @@ -4,8 +4,8 @@ AURYNVERSION=0 AURYNSUBVERSION=8 -AURYNREVISIONNUMBER=2 -AURYNREVISIONSUFFIX="dev" +AURYNREVISIONNUMBER=3 +AURYNREVISIONSUFFIX="" # Do not edit below diff --git a/test/coba_test/run_coba_parallel_test.sh b/test/coba_test/run_coba_parallel_test.sh index 37a83d7e..a37c2ac6 100755 --- a/test/coba_test/run_coba_parallel_test.sh +++ b/test/coba_test/run_coba_parallel_test.sh @@ -31,7 +31,7 @@ RETURNVALUE=$? echo "$REVISION $TESTNAME $RETURNVALUE" >> test_results.dat -if [ $? -ne 0 ] +if [ $RETURNVALUE -ne 0 ] then echo "The checksums for the $TESTNAME are different!" exit $RETURNVALUE fi diff --git a/test/coba_test/run_coba_test.sh b/test/coba_test/run_coba_test.sh index 70aa1c78..0bd014fc 100755 --- a/test/coba_test/run_coba_test.sh +++ b/test/coba_test/run_coba_test.sh @@ -35,7 +35,7 @@ RETURNVALUE=$? echo "$REVISION $TESTNAME $RETURNVALUE" >> test_results.dat -if [ $? -ne 0 ] +if [ $RETURNVALUE -ne 0 ] then echo "The checksums for the $TESTNAME are different!" exit $RETURNVALUE fi diff --git a/tools/aube.cpp b/tools/aube.cpp index 951e4c66..130e6d6d 100644 --- a/tools/aube.cpp +++ b/tools/aube.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2019 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/tools/aubs.cpp b/tools/aubs.cpp index 752c146f..fcae5f0f 100644 --- a/tools/aubs.cpp +++ b/tools/aubs.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2014-2018 Friedemann Zenke +* Copyright 2014-2019 Friedemann Zenke * * This file is part of Auryn, a simulation package for plastic * spiking neural networks. diff --git a/tools/python/auryntools/file_access.py b/tools/python/auryntools/file_access.py index 0beb2937..bc0a5497 100644 --- a/tools/python/auryntools/file_access.py +++ b/tools/python/auryntools/file_access.py @@ -8,7 +8,7 @@ from scipy.io import mmread, mmwrite -current_version = (0,8,1) +current_version = (0,8,2) class AurynBinaryFile: ''' diff --git a/tools/python/auryntools/stats.py b/tools/python/auryntools/stats.py index 435780d1..59760ada 100644 --- a/tools/python/auryntools/stats.py +++ b/tools/python/auryntools/stats.py @@ -3,12 +3,16 @@ import pylab as pl import struct -def spike_counts(spikes): +def spike_counts(spikes, size=None): ''' Compute spike count for each neuron ''' - nspikes = np.zeros(1) + if size is None: + nspikes = np.zeros(1) + else: + nspikes = np.zeros(size) + for spike in spikes: t,i = spike if i>=len(nspikes): @@ -17,7 +21,7 @@ def spike_counts(spikes): return nspikes -def rates(spikes): +def rates(spikes, nb_units=None, duration=None): ''' Compute firing rates for each neuron ''' @@ -28,11 +32,14 @@ def rates(spikes): print("Invalid input format. Expected a list of spikes.") raise AttributeError - t_min = ar[:,0].min() - t_max = ar[:,0].max() - t_diff = t_max-t_min + if duration is not None: + t_diff = duration + else: + t_min = ar[:,0].min() + t_max = ar[:,0].max() + t_diff = t_max-t_min - nspikes = spike_counts(spikes) + nspikes = spike_counts(spikes, nb_units) return 1.0*nspikes/t_diff