Auryn simulator

Simulator for spiking neural networks with synaptic plasticity

User Tools

Site Tools


examples:sim_coba_benchmark

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
examples:sim_coba_benchmark [2014/01/13 10:43] – starts important bit section zenkeexamples:sim_coba_benchmark [2015/06/01 17:58] zenke
Line 8: Line 8:
 To run the program the network first needs priming with external Poisson noise before it can self-sustain its activity. To do that invoke the program with the following command line arguments To run the program the network first needs priming with external Poisson noise before it can self-sustain its activity. To do that invoke the program with the following command line arguments
 <code shell> <code shell>
-./sim_coba_benchmark --dir /tmp --prime --simtime 0.050 
 ./sim_coba_benchmark --dir /tmp --simtime 5 ./sim_coba_benchmark --dir /tmp --simtime 5
 </code> </code>
 The ''prime'' keyword in the first command causes the network to run with external Poisson input and save its network state at the end of the run to a set of files created under ''/tmp''. Note that you can give any other directory name where you want the files to be created. The second call to the progrem without the ''--prime'' argument causes the program to read the current network state from these saved files and runs the network for the specified period in ''simtime''. All spiking output and the memory trace ([[mem]] file) of a single neuron are written to the directory specified with ''--dir'' and are prefixed with ''coba.*''. The ''prime'' keyword in the first command causes the network to run with external Poisson input and save its network state at the end of the run to a set of files created under ''/tmp''. Note that you can give any other directory name where you want the files to be created. The second call to the progrem without the ''--prime'' argument causes the program to read the current network state from these saved files and runs the network for the specified period in ''simtime''. All spiking output and the memory trace ([[mem]] file) of a single neuron are written to the directory specified with ''--dir'' and are prefixed with ''coba.*''.
 +
 +If you are interested in running the code in parallel please see the [[manual:parallel execution]] howto.
  
 ==== Output example ==== ==== Output example ====
Line 27: Line 28:
  
 {{ :examples:coba_ras.png?300 |}} {{ :examples:coba_ras.png?300 |}}
-This figure shows the rasterplot of the spiking activity of the excitatory population written to ''/tmp/coba.0.e.ras''.+This figure shows the raster plot of the spiking activity of the excitatory population written to ''/tmp/coba.0.e.ras''.
  
  
Line 42: Line 43:
 neurons_i->random_mem(-70e-3,10e-3); neurons_i->random_mem(-70e-3,10e-3);
 </code> </code>
-This part instatiates two groups of neurons of type [[TIFGroup]] which corresponds to the conductance based model with exponentially decaying PSCs and an absolute refractoriness of 5ms. The ''random_mem'' methods randomize the initial membrane potentials with a Gaussian (mean=-70mV and standard deviation 10e-3mV).+This part instatiates two groups of neurons of type [[TIFGroup]] which corresponds to the conductance based model with exponentially decaying PSCs and an absolute refractoriness of 5ms. The ''random_mem'' methods randomize the initial membrane potentials with a Gaussian (mean=-70mV and standard deviation 10mV).
  
  
Line 62: Line 63:
  
  
-To implement the priming mechanism we find the following conditional branch:+ 
 + 
 +The folling code snipped is responsible for running the simulation for ''simtime'' seconds. The second parameter ''true'' indicates that we wan the simulation to be interrupted if the [[RateChecker]] detects too high firing rates, which usually suggests that something is going wrong.
 <code c++> <code c++>
 +if (!sys->run(simtime,true)) 
 +    errcode = 1;
 +
 if ( prime ) {  if ( prime ) { 
- msg = "Setting up external input ...";+    oss.str(""); 
 +    oss << dir << "/save"; 
 +    sys->save_network_state(oss.str()); 
 +
 +</code> 
 +The second part of the above code saves the network state if ''prime==true'' and is therefore used to create the initial conditions of the self-sustained activity. 
 + 
 + 
 +===== The full program ===== 
 +**Note** you might find a more recent version of this code in the ''auryn/examples'' directory. 
 + 
 +<code c++> 
 +/*  
 +* Copyright 2014 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 <http://www.gnu.org/licenses/>
 +*/ 
 + 
 +#include <iostream> 
 +#include <iomanip> 
 +#include <stdlib.h> 
 +#include <string> 
 + 
 +#include <boost/program_options.hpp> 
 +#include <boost/mpi/environment.hpp> 
 +#include <boost/mpi/communicator.hpp> 
 +#include <boost/mpi.hpp> 
 + 
 +#include "System.h" 
 +#include "IFGroup.h" 
 +#include "TIFGroup.h" 
 +#include "PoissonGroup.h" 
 +#include "SparseConnection.h" 
 +#include "SymmetricSTDPConnection.h" 
 +#include "WeightSumMonitor.h" 
 +#include "SpikeMonitor.h" 
 +#include "DelayedSpikeMonitor.h" 
 +#include "StateMonitor.h" 
 +#include "RateChecker.h" 
 + 
 +using namespace std; 
 + 
 +namespace po = boost::program_options; 
 +namespace mpi = boost::mpi; 
 + 
 +int main(int ac,char *av[]) { 
 + string dir = "/tmp"; 
 + 
 + string fwmat_ee = ""; 
 + string fwmat_ei = ""; 
 + string fwmat_ie = ""; 
 + string fwmat_ii = ""; 
 + 
 + stringstream oss; 
 + string strbuf ; 
 + string msg; 
 + 
 + double w = 0.4; // [g_leak] 
 + double wi = 5.1; // [g_leak] 
 + 
 + 
 + 
 + double sparseness = 0.02; 
 + double simtime = 20.; 
 + 
 + 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<double>(), "simulation time"
 +            ("fast", "turns off most monitoring to reduce IO") 
 +            ("dir", po::value<string>(), "load/save directory"
 +            ("fee", po::value<string>(), "file with EE connections"
 +            ("fei", po::value<string>(), "file with EI connections"
 +            ("fie", po::value<string>(), "file with IE connections"
 +            ("fii", po::value<string>(), "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")) { 
 +            cout << desc << "\n"; 
 +            return 1; 
 +        } 
 + 
 +        if (vm.count("simtime")) { 
 + simtime = vm["simtime"].as<double>(); 
 +        }  
 + 
 +        if (vm.count("fast")) { 
 + fast = true; 
 +        }  
 + 
 +        if (vm.count("dir")) { 
 + dir = vm["dir"].as<string>(); 
 +        }  
 + 
 +        if (vm.count("fee")) { 
 + fwmat_ee = vm["fee"].as<string>(); 
 +        }  
 + 
 +        if (vm.count("fie")) { 
 + fwmat_ie = vm["fie"].as<string>(); 
 +        }  
 + 
 +        if (vm.count("fei")) { 
 + fwmat_ei = vm["fei"].as<string>(); 
 +        }  
 + 
 +        if (vm.count("fii")) { 
 + fwmat_ii = vm["fii"].as<string>(); 
 +        }  
 + 
 +    } 
 +    catch(exception& e) { 
 +        cerr << "error: " << e.what() << "\n"; 
 +        return 1; 
 +    } 
 +    catch(...) { 
 +        cerr << "Exception of unknown type!\n"; 
 +    } 
 + 
 + // BEGIN Global stuff 
 + mpi::environment env(ac, av); 
 + mpi::communicator world; 
 + communicator = &world; 
 + 
 + oss << dir  << "/coba." << world.rank() << "."; 
 + string outputfile = oss.str(); 
 + 
 + char tmp [255]; 
 + stringstream logfile; 
 + logfile << outputfile << "log"; 
 + logger = new Logger(logfile.str(),world.rank(),PROGRESS,EVERYTHING); 
 + 
 + sys = new System(&world); 
 + // END Global stuff 
 + 
 + logger->msg("Setting up neuron groups ...",PROGRESS,true); 
 + 
 + TIFGroup * neurons_e = new TIFGroup( ne); 
 + TIFGroup * neurons_i = new TIFGroup( ni); 
 + 
 + 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); 
 + 
 + 
 + if ( !fast ) { 
 + msg = "Setting up monitors ...";
  logger->msg(msg,PROGRESS,true);  logger->msg(msg,PROGRESS,true);
  
- PoissonGroup poisson= new PoissonGroup(200,10)+ stringstream filename; 
- poisson->seed(132341);  + filename << outputfile << "e.ras"; 
- // this will give the same seed on each rank, + SpikeMonitor smon_e = new SpikeMonitorneurons_efilename.str().c_str();
- // but since the group should be locked to a single +
- // rank we do not care.+
  
- SparseConnection * con_ext_e = new SparseConnection(poisson,neurons_e,1,sparseness/2,GLUT); + // filename.str(""); 
- SparseConnection con_ext_i = new SparseConnection(poisson,neurons_i,1,sparseness/2,GLUT);+ // filename.clear(); 
 + // filename << outputfile << "e.dras"; 
 + // DelayedSpikeMonitor dsmon_e = new DelayedSpikeMonitorneurons_efilename.str().c_str() );
  
- } else { + filename.str(""); 
- oss.str(""); + filename.clear(); 
- oss << dir << "/save"; + filename << outputfile << "i.ras"; 
- sys->load_network_state(oss.str());+ SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, filename.str().c_str() ); 
 +  
 + filename.str(""); 
 + filename << outputfile << "e.mem"; 
 + StateMonitor * smon_mem = new StateMonitorneurons_e, 7, "mem", filename.str() ,dt );  
 +  
 + filename.str(""); 
 + filename << outputfile << "e.ampa"; 
 + StateMonitor * smon_ampa = new StateMonitor( neurons_e, 7, "g_ampa", filename.str() ); 
 + 
 + filename.str(""); 
 + filename << outputfile << "e.gaba"; 
 + StateMonitor * smon_gaba = new StateMonitor( neurons_e, 7, "g_gaba", filename.str() );
  }  }
 +
 +
 + RateChecker * chk = new RateChecker( neurons_e , -0.1 , 1000. , 100e-3);
 +
 + logger->msg("Running sanity check ...",PROGRESS,true);
 + con_ee->sanity_check();
 + con_ei->sanity_check();
 + con_ie->sanity_check();
 + con_ii->sanity_check();
 +
 + logger->msg("Simulating ..." ,PROGRESS,true);
 + if (!sys->run(simtime,true)) 
 + errcode = 1;
 +
 + logger->msg("Freeing ..." ,PROGRESS,true);
 + delete sys;
 +
 + if (errcode)
 + env.abort(errcode);
 +
 + return errcode;
 +}
 </code> </code>
-If the ''prime'' directive is set (via the command line) this code will create a [[PoissonGroup]] and connect it to the excitatory and inhibitory populations. If ''prime==false'' this will try to load the network state from the hopefully existing save files stored under ''/tmp/save*'' in our example.+ 
examples/sim_coba_benchmark.txt · Last modified: 2016/07/05 23:40 by zenke