Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Public Member Functions | Public Attributes | List of all members
auryn::System Class Reference

Class that implements system wide variables and methods to manage and run simulations. More...

#include <System.h>

Collaboration diagram for auryn::System:
Collaboration graph
[legend]

Public Member Functions

 System (mpi::communicator *communicator)
 Default constructor for MPI enabled. More...
 
void set_simulation_name (std::string name)
 Sets the simulation name. More...
 
std::string get_simulation_name ()
 Returns the simulation name. More...
 
void set_output_dir (std::string path)
 Set output dir for fn function. More...
 
virtual ~System ()
 
void set_online_rate_monitor_target (SpikingGroup *group=NULL)
 Sets the target group for online rate estimate. More...
 
void set_online_rate_monitor_id (unsigned int id=0)
 Sets the SpikingGroup used to display the rate estimate in the progressbar. More...
 
void set_online_rate_monitor_tau (AurynDouble tau=100e-3)
 Sets the timeconstant to compute the online rate average for the status bar. More...
 
double get_last_elapsed_time ()
 Returns last elapsed time in seconds. More...
 
double get_total_elapsed_time ()
 Returns total elapsed time in seconds. More...
 
void save_network_state (std::string basename)
 Saves network state to a netstate file. More...
 
void load_network_state (std::string basename)
 Loads network state from a netstate file. More...
 
void save_network_state_text (std::string basename)
 Saves the network state to human readable text files. More...
 
void flush_devices ()
 Flush devices. More...
 
void register_spiking_group (SpikingGroup *spiking_group)
 Registers an instance of SpikingGroup to the spiking_groups vector. More...
 
void register_connection (Connection *connection)
 Registers an instance of Connection to the connections vector. More...
 
void register_device (Device *device)
 Registers an instance of Device to the devices vector. More...
 
void register_checker (Checker *checker)
 Registers an instance of Checker to the checkers vector. More...
 
bool run (AurynFloat simulation_time, bool checking=true)
 Runs a simulation for a given amount of time. More...
 
bool run_chunk (AurynFloat chunk_time, AurynFloat interval_start, AurynFloat interval_end, bool checking=true)
 Runs simulation for a given amount of time. More...
 
AurynDouble get_time ()
 Gets the current system time in [s]. More...
 
AurynTime get_clock ()
 Gets the current clock value in AurynTime. More...
 
AurynTimeget_clock_ptr ()
 Gets a pointer to the current clock. More...
 
AurynLong get_total_neurons ()
 Get total number of registered neurons. More...
 
AurynDouble get_total_effective_load ()
 Get total effective load. More...
 
AurynLong get_total_synapses ()
 Get total number of registered synapses. More...
 
string fn (std::string extension)
 Format output file name. More...
 
string fn (std::string name, std::string extension)
 Format output file name. More...
 
string fn (std::string name, NeuronID index, std::string extension)
 Format output file name. More...
 
mpi::communicator * get_com ()
 Returns global mpi communicator. More...
 
unsigned int mpi_size ()
 Returns number of ranks. More...
 
unsigned int mpi_rank ()
 Returns current rank. More...
 
void set_master_seed (unsigned int seed=123)
 Set master seed. More...
 
unsigned int get_seed ()
 Returns a random seed which is different on each rank. More...
 
unsigned int get_synced_seed ()
 Returns a random seed which is the same on each rank. More...
 

Public Attributes

bool quiet
 Switch to turn output to quiet mode (no progress bar). More...
 
AurynVersion build
 Version info. More...
 
unsigned int progressbar_update_interval
 The progressbar update interval in timesteps of auryn_timestep. More...
 

Detailed Description

Class that implements system wide variables and methods to manage and run simulations.

This Class contains methods to manage and run sets of classes that make up the simulation. In particular it distinguishes between constituents of types SpikingGroup, Connection, Monitor and Checker. A MPI implementation should implement communicators and all that stuff in here. All the constituent object of a single simulation are stored in STL vectors. The methods evolve() and propagate() from each object in these vectors are called alternatingly from within the run procedure.

Constructor & Destructor Documentation

◆ System()

System::System ( mpi::communicator *  communicator)

Default constructor for MPI enabled.

140 {
141 
142  mpicom = communicator;
143  init();
144 
145 
146  std::stringstream oss;
147  if ( mpi_size() > 1 ) {
148  oss << "This is an MPI run. I am rank "
149  << mpi_rank() << " of a total of "
150  << mpi_size() << " ranks.";
151  auryn::logger->msg(oss.str(),NOTIFICATION);
152  } else {
153  auryn::logger->msg("Not running a parallel simulation.",NOTIFICATION);
154  }
155 
156  if ( mpi_size() > 0 && (mpi_size() & (mpi_size()-1)) ) {
157  oss.str("");
158  oss << "WARNING! The number of processes is not a power of two. "
159  << "This causes impaired performance or even crashes "
160  << "in some MPI implementations.";
161  auryn::logger->msg(oss.str(),WARNING,true);
162  }
163 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
unsigned int mpi_size()
Returns number of ranks.
Definition: System.cpp:1004
Definition: Logger.h:41
Definition: Logger.h:41
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Here is the call graph for this function:

◆ ~System()

System::~System ( )
virtual
172 {
173  free();
174 }
Here is the call graph for this function:

Member Function Documentation

◆ flush_devices()

void System::flush_devices ( )

Flush devices.

Write monitor data buffers to file.

970 {
971  for ( unsigned int i = 0 ; i < devices.size() ; ++i )
972  devices[i]->flush();
973 }

◆ fn() [1/3]

string System::fn ( std::string  extension)

Format output file name.

Formats output files according to the following convention: <outputdir>/<name>.<rank>.<extension> where <name> is taken from System->get_name() and returns it as a c string;

690 {
691  return fn(get_simulation_name(), extension);
692 }
std::string get_simulation_name()
Returns the simulation name.
Definition: System.cpp:659
string fn(std::string extension)
Format output file name.
Definition: System.cpp:689
Here is the call graph for this function:

◆ fn() [2/3]

string System::fn ( std::string  name,
std::string  extension 
)

Format output file name.

Formats output files according to the following convention: <outputdir>/<name>.<rank>.<extension> and returns it as a c string;

670 {
671  std::stringstream oss;
672  oss << outputdir << "/" << name
673  << "." << mpi_rank()
674  << "." << extension;
675  return oss.str();
676 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
Here is the call graph for this function:

◆ fn() [3/3]

string System::fn ( std::string  name,
NeuronID  index,
std::string  extension 
)

Format output file name.

Formats output files according to the following convention: <outputdir>/<name><index>.<rank>.<extension> and returns it as a c string;

679 {
680  std::stringstream oss;
681  oss << outputdir << "/"
682  << name
683  << index
684  << "." << mpi_rank()
685  << "." << extension;
686  return oss.str();
687 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
Here is the call graph for this function:

◆ get_clock()

AurynTime System::get_clock ( )

Gets the current clock value in AurynTime.

232 {
233  return clock;
234 }

◆ get_clock_ptr()

AurynTime * System::get_clock_ptr ( )

Gets a pointer to the current clock.

237 {
238  return &clock;
239 }

◆ get_com()

mpi::communicator * System::get_com ( )

Returns global mpi communicator.

649 {
650  return mpicom;
651 }

◆ get_last_elapsed_time()

AurynDouble System::get_last_elapsed_time ( )

Returns last elapsed time in seconds.

957 {
958  return last_elapsed_time;
959 }

◆ get_seed()

unsigned int System::get_seed ( )

Returns a random seed which is different on each rank.

1031 {
1032  return (*seed_die)();
1033 }

◆ get_simulation_name()

std::string System::get_simulation_name ( )

Returns the simulation name.

660 {
661  return simulation_name;
662 }

◆ get_synced_seed()

unsigned int System::get_synced_seed ( )

Returns a random seed which is the same on each rank.

Can be used to synchronize randomness across ranks StimulusGroup etc

1036 {
1037  unsigned int value;
1038  if ( mpi_rank() == 0 ) value = get_seed();
1039 #ifdef AURYN_CODE_USE_MPI
1040  broadcast(*mpicom, value, 0);
1041 #endif // AURYN_CODE_USE_MPI
1042  // std::cout << mpi_rank() << " " << value << std::endl;
1043  return value;
1044 }
unsigned int get_seed()
Returns a random seed which is different on each rank.
Definition: System.cpp:1030
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
Here is the call graph for this function:

◆ get_time()

AurynDouble System::get_time ( )

Gets the current system time in [s].

227 {
228  return auryn_timestep * clock;
229 }
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31

◆ get_total_effective_load()

AurynDouble auryn::System::get_total_effective_load ( )

Get total effective load.

◆ get_total_elapsed_time()

AurynDouble System::get_total_elapsed_time ( )

Returns total elapsed time in seconds.

962 {
963  time_t t_now ;
964  time(&t_now);
965  double elapsed = difftime(t_now,t_sys_start);
966  return elapsed;
967 }

◆ get_total_neurons()

AurynLong System::get_total_neurons ( )

Get total number of registered neurons.

242 {
243  AurynLong sum = 0;
244  std::vector<SpikingGroup *>::const_iterator iter;
245  for ( iter = spiking_groups.begin() ; iter != spiking_groups.end() ; ++iter ) {
246  sum += (*iter)->get_rank_size();
247  }
248  return sum;
249 }
unsigned long AurynLong
An unsigned long type used to count synapses or similar.
Definition: auryn_definitions.h:154

◆ get_total_synapses()

AurynLong System::get_total_synapses ( )

Get total number of registered synapses.

252 {
253  AurynLong sum = 0;
254  std::vector<Connection *>::const_iterator iter;
255  for ( iter = connections.begin() ; iter != connections.end() ; ++iter ) {
256  sum += (*iter)->get_nonzero();
257  }
258  return sum;
259 }
unsigned long AurynLong
An unsigned long type used to count synapses or similar.
Definition: auryn_definitions.h:154

◆ load_network_state()

void System::load_network_state ( std::string  basename)

Loads network state from a netstate file.

Parameters
basename(directory and prefix of file) of the netstate file without extension
813 {
814  auryn::logger->msg("Loading network state", NOTIFICATION);
815 
816 
817  std::string netstate_filename;
818  {
819  std::stringstream oss;
820  oss << basename
821  << "." << mpi_rank()
822  << ".netstate";
823  netstate_filename = oss.str();
824  } // oss goes out of focus
825 
826  std::ifstream ifs(netstate_filename.c_str());
827 
828  if ( !ifs.is_open() ) {
829  std::stringstream oss;
830  oss << "Error opening netstate file: "
831  << netstate_filename;
832  auryn::logger->msg(oss.str(),ERROR);
833  throw AurynOpenFileException();
834  }
835 
836  boost::archive::binary_iarchive ia(ifs);
837 
838 
839  // verify simulator version information
840  bool pass_version = true;
841  int tmp_version;
842  ia >> tmp_version;
843  pass_version = pass_version && build.version==tmp_version;
844  ia >> tmp_version;
845  pass_version = pass_version && build.subversion==tmp_version;
846  ia >> tmp_version;
847  pass_version = pass_version && build.revision_number==tmp_version;
848 
849  if ( !pass_version ) {
850  auryn::logger->msg("WARNING: Version check failed! Current Auryn version "
851  "does not match the version which created the file. "
852  "This could pose a problem. "
853  "Proceed with caution!" ,WARNING);
854  }
855 
856  // verify communicator information
857  bool pass_comm = true;
858  unsigned int tmp_int;
859  ia >> tmp_int;
860  pass_comm = pass_comm && (tmp_int == mpi_size());
861  ia >> tmp_int;
862  pass_comm = pass_comm && (tmp_int == mpi_rank());
863 
864  if ( !pass_comm ) {
865  auryn::logger->msg("ERROR: Communicator size or rank do not match! "
866  "Presumably you are trying to load the network "
867  "state netstate from a simulation which was run "
868  "on a different number of cores." ,ERROR);
869  }
870 
871  auryn::logger->msg("Loading connections ...",VERBOSE);
872  for ( unsigned int i = 0 ; i < connections.size() ; ++i ) {
873 
874  std::stringstream oss;
875  oss << "Loading connection "
876  << i
877  << ": "
878  << connections[i]->get_name();
879  auryn::logger->msg(oss.str(),VERBOSE);
880 
881  ia >> *(connections[i]);
882  connections[i]->finalize();
883  }
884 
885  auryn::logger->msg("Loading SpikingGroups ...",VERBOSE);
886  for ( unsigned int i = 0 ; i < spiking_groups.size() ; ++i ) {
887 
888  std::stringstream oss;
889  oss << "Loading group "
890  << i
891  << ": "
892  << spiking_groups[i]->get_name();
893  auryn::logger->msg(oss.str(),VERBOSE);
894 
895  ia >> *(spiking_groups[i]);
896  }
897 
898  // Loading Devices states
899  auryn::logger->msg("Loading Devices ...",VERBOSE);
900  for ( unsigned int i = 0 ; i < devices.size() ; ++i ) {
901 
902  std::stringstream oss;
903  oss << "Loading Device "
904  << i;
905  auryn::logger->msg(oss.str(),VERBOSE);
906 
907  ia >> *(devices[i]);
908  }
909 
910 
911  auryn::logger->msg("Loading Checkers ...",VERBOSE);
912  for ( unsigned int i = 0 ; i < checkers.size() ; ++i ) {
913 
914  std::stringstream oss;
915  oss << "Loading Checker "
916  << i;
917  auryn::logger->msg(oss.str(),VERBOSE);
918 
919  ia >> *(checkers[i]);
920  }
921 
922  ifs.close();
923 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
unsigned int mpi_size()
Returns number of ranks.
Definition: System.cpp:1004
Definition: Logger.h:41
Definition: Logger.h:41
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
static int revision_number
Definition: AurynVersion.h:41
Definition: auryn_definitions.h:208
AurynVersion build
Version info.
Definition: System.h:161
Definition: Logger.h:41
static int subversion
Definition: AurynVersion.h:40
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
static int version
Definition: AurynVersion.h:39
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156
Here is the call graph for this function:

◆ mpi_rank()

unsigned int System::mpi_rank ( )

Returns current rank.

like mpicom->rank(), but also defined when run without mpi.

1010 {
1011  return mpi_rank_;
1012 }

◆ mpi_size()

unsigned int System::mpi_size ( )

Returns number of ranks.

like mpicom->size(), but also defined when run without mpi.

1005 {
1006  return mpi_size_;
1007 }

◆ register_checker()

void System::register_checker ( Checker checker)

Registers an instance of Checker to the checkers vector.

Note: The first checker that is registered is by default used by System for the rate output in the progress bar. Called internally by constructor of Monitor.

278 {
279  checkers.push_back(checker);
280 }
Here is the call graph for this function:

◆ register_connection()

void System::register_connection ( Connection connection)

Registers an instance of Connection to the connections vector.

Called internally by constructor of Connection.

268 {
269  connections.push_back(connection);
270 }

◆ register_device()

void System::register_device ( Device device)

Registers an instance of Device to the devices vector.

Called internally by constructor of Monitor.

273 {
274  devices.push_back(device);
275 }

◆ register_spiking_group()

void System::register_spiking_group ( SpikingGroup spiking_group)

Registers an instance of SpikingGroup to the spiking_groups vector.

Called internally by constructor of SpikingGroup.

262 {
263  spiking_groups.push_back(spiking_group);
264  spiking_group->set_clock_ptr(get_clock_ptr());
265 }
AurynTime * get_clock_ptr()
Gets a pointer to the current clock.
Definition: System.cpp:236
void set_clock_ptr(AurynTime *clock)
Definition: SpikingGroup.cpp:228
Here is the call graph for this function:

◆ run()

bool System::run ( AurynFloat  simulation_time,
bool  checking = true 
)

Runs a simulation for a given amount of time.

Parameters
simulation_timetime to run the simulation in seconds.
checkingtrue if checkers can break the run (e.g. if a frequency get's to high and the network explodes)
Returns
bool true on success
616 {
617  if ( simulation_time < 0.0 ) {
618  logger->error("Negative run time not allowed.");
619  return false;
620  }
621 
622  // throw an exception if the stoptime is post the range of AurynTime
623  if ( get_time() + simulation_time > std::numeric_limits<AurynTime>::max()*auryn_timestep ) {
624  auryn::logger->msg("The requested simulation time exceeds the number of possible timesteps limited by AurynTime datatype.",ERROR);
626  }
627 
628  AurynTime starttime = get_clock();
629  AurynTime stoptime = get_clock() + (AurynTime) (simulation_time/auryn_timestep);
630 
631  return run(starttime, stoptime, simulation_time, checking);
632 }
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
Definition: Logger.h:41
AurynDouble get_time()
Gets the current system time in [s].
Definition: System.cpp:226
void error(std::string text)
Definition: Logger.cpp:141
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
NeuronID AurynTime
Defines Auryns discrete time unit of the System clock. Change to AurynLong if 120h of simtime are not...
Definition: auryn_definitions.h:155
Definition: auryn_definitions.h:281
Here is the call graph for this function:

◆ run_chunk()

bool System::run_chunk ( AurynFloat  chunk_time,
AurynFloat  interval_start,
AurynFloat  interval_end,
bool  checking = true 
)

Runs simulation for a given amount of time.

Exposes the interface to the progressbar params. Can be used to run a single progress bar, but cut it in different chunks to turn on and off stuff in the simulation without perturbing the output. interval_start and end define the total duration of the simulation (this is used to build the progress bar, while chung_time is the actual time that is simulated for each call.

635 {
636  AurynTime stopclock = get_clock()+chunk_time/auryn_timestep;
637 
638  // throw an exception if the stoptime is post the range of AurynTime
639  if ( interval_end > std::numeric_limits<AurynTime>::max()*auryn_timestep ) {
640  auryn::logger->msg("The requested simulation time exceeds the number of possible timesteps limited by AurynTime datatype.",ERROR);
642  }
643 
644  return run(interval_start/auryn_timestep, stopclock, (interval_end-interval_start), checking);
645 }
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
NeuronID AurynTime
Defines Auryns discrete time unit of the System clock. Change to AurynLong if 120h of simtime are not...
Definition: auryn_definitions.h:155
Definition: auryn_definitions.h:281
Here is the call graph for this function:

◆ save_network_state()

void System::save_network_state ( std::string  basename)

Saves network state to a netstate file.

This function saves the network state to one serialized file. The network state includes the internal state variables of all neurons and the synaptic connections. It currently does not save the state of any random number generators (v0.5) but this is planned to change in the future. Note that netstate files do not contain any parameters either. This was done to allow to run a simulation with a certain parameter set for a given amount of time. Save the network state and then continue the simulation from that point with a changed parameter set (e.g. a new stimulus set or similar).

Parameters
basename(including directory path) of the netstate file without extension
695 {
696  auryn::logger->msg("Saving network state", NOTIFICATION);
697 
698  std::string netstate_filename;
699  {
700  std::stringstream oss;
701  oss << outputdir
702  << "/" << basename
703  << "." << mpi_rank()
704  << ".netstate";
705  netstate_filename = oss.str();
706  } // oss goes out of focus
707 
708  auryn::logger->msg("Opening output stream ...",VERBOSE);
709  std::ofstream ofs(netstate_filename.c_str());
710  boost::archive::binary_oarchive oa(ofs);
711 
712  auryn::logger->msg("Saving version information ...",VERBOSE);
713  // save simulator version information
714  oa << build.version;
715  oa << build.subversion;
716  oa << build.revision_number;
717 
718  auryn::logger->msg("Saving communicator information ...",VERBOSE);
719  // save communicator information
720  unsigned int tmp_int = mpi_size();
721  oa << tmp_int;
722  tmp_int = mpi_rank();
723  oa << tmp_int;
724 
725 
726  auryn::logger->msg("Saving Connections ...",VERBOSE);
727  for ( unsigned int i = 0 ; i < connections.size() ; ++i ) {
728 
729  std::stringstream oss;
730  oss << "Saving connection "
731  << i
732  << " '"
733  << connections[i]->get_name()
734  << "' "
735  << " to stream";
736  auryn::logger->msg(oss.str(),VERBOSE);
737 
738  oa << *(connections[i]);
739  }
740 
741  auryn::logger->msg("Saving SpikingGroups ...",VERBOSE);
742  for ( unsigned int i = 0 ; i < spiking_groups.size() ; ++i ) {
743 
744  std::stringstream oss;
745  oss << "Saving SpikingGroup "
746  << i
747  << " ("
748  << spiking_groups[i]->get_name()
749  << ")"
750  << " to stream";
751  auryn::logger->msg(oss.str(),VERBOSE);
752 
753  oa << *(spiking_groups[i]);
754  }
755 
756  // Save Devices
757  auryn::logger->msg("Saving Devices ...",VERBOSE);
758  for ( unsigned int i = 0 ; i < devices.size() ; ++i ) {
759 
760  std::stringstream oss;
761  oss << "Saving Device "
762  << i
763  << " to stream";
764  auryn::logger->msg(oss.str(),VERBOSE);
765 
766  oa << *(devices[i]);
767  }
768 
769  auryn::logger->msg("Saving Checkers ...",VERBOSE);
770  for ( unsigned int i = 0 ; i < checkers.size() ; ++i ) {
771 
772  std::stringstream oss;
773  oss << "Saving Checker "
774  << i
775  << " to stream";
776  auryn::logger->msg(oss.str(),VERBOSE);
777 
778  oa << *(checkers[i]);
779  }
780 
781  ofs.close();
782 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
unsigned int mpi_size()
Returns number of ranks.
Definition: System.cpp:1004
Definition: Logger.h:41
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
static int revision_number
Definition: AurynVersion.h:41
AurynVersion build
Version info.
Definition: System.h:161
static int subversion
Definition: AurynVersion.h:40
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
static int version
Definition: AurynVersion.h:39
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156
Here is the call graph for this function:

◆ save_network_state_text()

void System::save_network_state_text ( std::string  basename)

Saves the network state to human readable text files.

This deprecated method of saving the network state generates a large number of files because each Connection object or SpikingGroup creates their own respective file. This function might still be useful if you have code in which you analaze these files offline. In most cases you will want to use save_network_state and only dump a limited subset (e.g. all the plastic connections) in human-readable text files for analysis.

Parameters
Basename(directory and prefix of file) of the netstate file without extension
785 {
786  auryn::logger->msg("Saving network state to textfile", NOTIFICATION);
787 
788  char filename [255];
789  for ( unsigned int i = 0 ; i < connections.size() ; ++i ) {
790  sprintf(filename, "%s.%d.%d.wmat", basename.c_str(), i, mpi_rank());
791 
792  std::stringstream oss;
793  oss << "Saving connection "
794  << filename ;
795  auryn::logger->msg(oss.str(),VERBOSE);
796 
797  connections[i]->write_to_file(filename);
798  }
799 
800  for ( unsigned int i = 0 ; i < spiking_groups.size() ; ++i ) {
801  sprintf(filename, "%s.%d.%d.gstate", basename.c_str(), i, mpi_rank());
802 
803  std::stringstream oss;
804  oss << "Saving group "
805  << filename ;
806  auryn::logger->msg(oss.str(),VERBOSE);
807 
808  spiking_groups[i]->write_to_file(filename);
809  }
810 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
Definition: Logger.h:41
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Here is the call graph for this function:

◆ set_master_seed()

void System::set_master_seed ( unsigned int  seed = 123)

Set master seed.

Set the master seed from which other seeds are drawn. When the master seed is set to 0 a master seed is generated from ctime and will be different at each run.

1015 {
1016  if ( seed == 0 ) {
1017  seed = static_cast<unsigned int>(std::time(0));
1018  }
1019 
1020  const unsigned int master_seed_multiplier = 257;
1021  const unsigned int rank_master_seed = seed*master_seed_multiplier*(mpi_rank()+1);
1022 
1023  std::stringstream oss;
1024  oss << "Seeding this rank with master seed " << rank_master_seed;
1025  auryn::logger->msg(oss.str(),INFO);
1026 
1027  seed_gen.seed(rank_master_seed);
1028 }
unsigned int mpi_rank()
Returns current rank.
Definition: System.cpp:1009
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Definition: Logger.h:41
Here is the call graph for this function:

◆ set_online_rate_monitor_id()

void System::set_online_rate_monitor_id ( unsigned int  id = 0)

Sets the SpikingGroup used to display the rate estimate in the progressbar.

Deprecated:
This function should not be used any more. Use set_online_rate_monitor_target instead.

This typically is reflected by the order in which you define the SpikingGroup and NeuronGroup classes. It starts numbering from 0.

940 {
941  if ( id < spiking_groups.size() ) {
942  online_rate_monitor_id = id;
943  set_online_rate_monitor_target(spiking_groups[online_rate_monitor_id]);
944  } else {
945  online_rate_monitor_id = -1;
947  }
948 }
void set_online_rate_monitor_target(SpikingGroup *group=NULL)
Sets the target group for online rate estimate.
Definition: System.cpp:950
Here is the call graph for this function:

◆ set_online_rate_monitor_target()

void System::set_online_rate_monitor_target ( SpikingGroup group = NULL)

Sets the target group for online rate estimate.

951 {
952  online_rate_monitor_state = 0.0;
953  online_rate_monitor_target = group;
954 }

◆ set_online_rate_monitor_tau()

void System::set_online_rate_monitor_tau ( AurynDouble  tau = 100e-3)

Sets the timeconstant to compute the online rate average for the status bar.

926 {
927  online_rate_monitor_tau = tau;
928  online_rate_monitor_mul = exp(-auryn_timestep/tau);
929 }
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
Here is the call graph for this function:

◆ set_output_dir()

void System::set_output_dir ( std::string  path)

Set output dir for fn function.

665 {
666  outputdir = path;
667 }

◆ set_simulation_name()

void System::set_simulation_name ( std::string  name)

Sets the simulation name.

655 {
656  simulation_name = name;
657 }

Member Data Documentation

◆ build

AurynVersion auryn::System::build

Version info.

◆ progressbar_update_interval

unsigned int auryn::System::progressbar_update_interval

The progressbar update interval in timesteps of auryn_timestep.

◆ quiet

bool auryn::System::quiet

Switch to turn output to quiet mode (no progress bar).


The documentation for this class was generated from the following files: