bool SpikingGroup::write_to_file(const char * filename) { if ( !evolve_locally() ) return true; ofstream outfile; outfile.open(filename,ios::out); if (!outfile) { cerr << "Can't open output file " << filename << endl; throw AurynOpenFileException(); } outfile << "# Auryn SpikingGroup state file for n="<< get_rank_size() <<" neurons (ver. " << VERSION << ")" << endl; outfile << "# Field order: "; for ( map<string,gsl_vector_float *>::const_iterator iter = state_vector.begin() ; iter != state_vector.end() ; ++iter ) { outfile << scientific << iter->first << " "; } outfile << "(plus traces)"; outfile << endl; boost::archive::text_oarchive oa(outfile); oa << *(delay); outfile << endl; for ( NeuronID i = 0 ; i < get_rank_size() ; ++i ) { outfile << get_output_line(i); } outfile.close(); return true; }
void SpikingGroup::conditional_evolve() { spikes = get_spikes_immediate(); spikes->clear(); attribs = get_attributes_immediate(); attribs->clear(); if ( evolve_locally() ) { evolve(); } }
bool SpikingGroup::load_from_file(const char * filename) { if ( !evolve_locally() ) return true; stringstream oss; oss << "Loading SpikingGroup from " << filename; logger->msg(oss.str(),NOTIFICATION); ifstream infile (filename); if (!infile) { stringstream oes; oes << "Can't open input file " << filename; logger->msg(oes.str(),ERROR); throw AurynOpenFileException(); } NeuronID count = 0; char buffer[1024]; infile.getline (buffer,1024); // skipping header TODO once could make this logic a bit smarter infile.getline (buffer,1024); // skipping header boost::archive::text_iarchive ia(infile); ia >> *delay; infile.getline (buffer,1024); // jumpting to next line while ( infile.getline (buffer,1024) ) { load_input_line(count,buffer); count++; } if ( get_rank_size() != count ) { // issue warning stringstream oes; oes << "SpikingGroup:: NeuronState file corrupted. Read " << count << " entries, but " << get_rank_size() << " expected in " << filename; logger->msg(oes.str(),WARNING); } infile.close(); return true; }
AIFGroup::AIFGroup( NeuronID size, AurynFloat load, NeuronID total ) : NeuronGroup(size,load,total) { sys->register_spiking_group(this); if ( evolve_locally() ) init(); }
AIFGroup::~AIFGroup() { if ( evolve_locally() ) free(); }
TIFGroup::~TIFGroup() { if ( !evolve_locally() ) return; gsl_vector_ushort_free (ref); }
TIFGroup::TIFGroup(NeuronID size) : NeuronGroup(size) { sys->register_spiking_group(this); if ( evolve_locally() ) init(); }
IF2Group::~IF2Group() { if ( evolve_locally() ) free(); }