Simulator for rate-based neurons with synaptic and structural plasticity
devised by Michael Fauth (mfauth[at]gwdg.de), 2017-2019

Compile:

    g++ -std=c++11 -O3 simulate.cpp -osimulate

Usage:

    simulate [filename-prefix] [random stimulation interval s] [simulation time in h] [in-group-connectivity] [stimulation file]


    
This program simulates the dynamics of a network of rate-based neurons with synaptic and structural plasticity as well as 
short term depression.

The specified filename-prefix will be combined with different suffixes to produce different output files. [prefix].rates
will hold the neuron rates, [prefix].weights, .synapses and .synapses2  contain the flattened weight and number of synapse
matrices as well as the occupancy of all potential synapses (binary representation) for each log-interval. Note, logging 
will slow down the simulation and produce vast amounts of data such that the log interval is typically chosen to be large 
(determined within the stimulation file, see below).

To monitor effects at short timescales, specific mechanisms have been implemented:
- The program assumes that the first neurons belong to one of three stimulation groups which have a specific size (and 
  overlap). The initial number of synapses within these stimulation groups is specified by the initial in-group connectivity 
  parameter.
- A histogram of weights within and between the stimulation groups and the rest of the neurons (control) is saved at every 
  log interval (.histograms).
- The program will detect spontaneous reactivations (Up-states) within the first group and log their timings as well as the 
  group rates and connectivity. 
- The stimulation file can be used to activate a fast-log-mechanism that logs all rates every random stimulation interval 
   (.switches).
Moreover, te program will output a histogram of synapse-lifetimes and histograms of the pairwise activitiy of neurons
within and across the stimulation groups during the non-random-stimulation intervals

The neurons in the simulation receive stimulations currents specified in a stimuation file with following line structure:
 	[time in h] [mode] [start neuron index] [stop neuron index] [stimulation current (unitless)] [log interval in seconds]
If mode is "S", neurons betwen start and stop neuron indices (0 to N-1) receive the specified stimulation current at the 
specified time. If mode is "R" a random stimulation protocoll will be initialized. Here a number of neurons are randomly
selected and stimulated. After the specified random stimulation interval, the pattern is changed. Other parameters are
ignored. This paradigm ends as soon as a stimulation is applied. If the mode is "F", a fast-log-mechanism is activated or 
deactivated,  which writes out the rates of all neurons at each timestep. 


Example Usage: 

    simulate long_term_simulation 1 330 0 stimulation_long_term.txt
    
    Reproduces long-term simulation shown in paper using the provided stimulation file "stimulation_long_term.txt". Initial 
    connectivity is zero and total simulation time will be 330 hours. Random patterns are changed every 1s. Output files
    will be named "long_term_simulation.rates" and so forth.
