⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlogger.cpp

📁 a useful spiking neural networks simulator
💻 CPP
字号:
/**  * @file  dlogger.cpp * @brief Logger * * @author Makino, Takaki <t-makino-punnets01@snowelm.com> * @date 2003-05-01 * @version $Id: dlogger.cpp,v 1.1 2003/05/01 10:57:43 t Exp $ * *  Copyright (C) 2003 Makino, Takaki.  * *  This program 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 2, or (at your option) *  any later version. *  This program 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 this program; if not, write to the Free Software *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   */#include "dlogger.h"#include <iomanip>using namespace std;//////////////////////////////////////////////////////////////////////////namespace punnets_common {//////////////////////////////////////////////////////////////////////////const int lev_shift = 0;void tlogger::activate(tscheduler &scheduler, ntime_t current_time){ 	out << setprecision(15) << current_time;	int lev = 0;		for( vector< neuentry >::iterator i = neus.begin(); i != neus.end(); i++ )	{		if( i->delay != 0.0 )			out << "\t" << setprecision(15) << current_time - i->delay;		out << "\t" << setprecision(15) << 			(i->neuron->getLastFire() >= current_time - step ? 				i->lastthr + 1.0 : 				i->neuron->getCurrentSigLevel(current_time) ) + lev + i->offset;		i->lastthr = i->neuron->getCurrentThrLevel(current_time);		if( i->logopt & showthr )			out << "\t" << setprecision(15) << i->lastthr + lev + i->offset;		if( i->logopt & showext )			out << "\t" << setprecision(15) << i->neuron->getCurrentExtInput(current_time) + lev + i->offset;		if( i->logopt & showpart )		{			if( i->neuron->getLastSimulate() >= current_time - step )			{				switch( i->neuron->getLastSimulateType() )				{					case 0:					default:						out << " -10 = = ="; break;					case 1:						out << " = -10 = ="; break;					case 2:						out << " = = -10 ="; break;					case 3:						out << " = = = -10"; break;				}			}			else				out << " = = = =";		}		lev += lev_shift;	}	for( vector<pair<tsynapse_base *, ntime_t> >::iterator i = syns.begin(); i != syns.end(); i++ )	{		if( i->second != 0.0 )			out << "\t" << setprecision(15) << current_time - i->second;		out << "\t" << setprecision(15) << i->first->getWeight();// + lev;//		lev += lev_shift;	}	out << endl;	if( current_time + step < until + delaymax )		scheduler.scheduleEvent(current_time + step, *this);};void tlogger::gnuplot_def(ostream &os, string logfile){//	cerr << "min/max: " << delaymin << "/" << delaymax << endl;//	os << "set term X11" << endl;	os << "set y2tics" << endl;	os << "plot [" << from << ":" << until << "]";	string delim = "";	int column = 1;	for( vector< neuentry >::iterator i = neus.begin(); i != neus.end(); i++ )	{		int xcol = (i->delay == 0.0 ? 1 : ++column);		os << delim << " \\" << endl << "\t'" << logfile << "' " << 			"using " << xcol << ":" << (++column) << " axes x1y1 " << 			"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";		if( i->delay != 0.0 )			os << "(delay " << i->delay << ")";		if( i->offset != 0.0 )			os << "(offset " << i->offset << ")";		os << " signal\" with lines";		delim = ",";		if( i->logopt & showthr )		{			os << delim << " \\" << endl << "\t'" << logfile << "' " << 				"using " << xcol << ":" << (++column) << " axes x1y1 " << 				"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";			if( i->delay != 0.0 )				os << "(delay " << i->delay << ")";			if( i->offset != 0.0 )				os << "(offset " << i->offset << ")";			os << " threshold\" with dots";			delim = ",";		}		if( i->logopt & showext )		{			os << delim << " \\" << endl << "\t'" << logfile << "' " << 				"using " << xcol << ":" << (++column) << " axes x1y1 " << 				"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";			if( i->delay != 0.0 )				os << "(delay " << i->delay << ")";			if( i->offset != 0.0 )				os << "(offset " << i->offset << ")";			os << " external\" with dots";			delim = ",";		}		if( i->logopt & showpart )		{			os << delim << " \\" << endl << "\t'" << logfile << "' " << 				"using " << xcol << ":" << (++column) << " axes x1y1 " << 				"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";			if( i->delay != 0.0 )				os << "(delay " << i->delay << ")";			if( i->offset != 0.0 )				os << "(offset " << i->offset << ")";			os << " partition 0\" with impulses";			delim = ",";			os << delim << " \\" << endl << "\t'" << logfile << "' " << 				"using " << xcol << ":" << (++column) << " axes x1y1 " << 				"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";			if( i->delay != 0.0 )				os << "(delay " << i->delay << ")";			if( i->offset != 0.0 )				os << "(offset " << i->offset << ")";			os << " partition 1\" with impulses";			os << delim << " \\" << endl << "\t'" << logfile << "' " << 				"using " << xcol << ":" << (++column) << " axes x1y1 " << 				"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";			if( i->delay != 0.0 )				os << "(delay " << i->delay << ")";			if( i->offset != 0.0 )				os << "(offset " << i->offset << ")";			os << " partition 2\" with impulses";			os << delim << " \\" << endl << "\t'" << logfile << "' " << 				"using " << xcol << ":" << (++column) << " axes x1y1 " << 				"title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";			if( i->delay != 0.0 )				os << "(delay " << i->delay << ")";			if( i->offset != 0.0 )				os << "(offset " << i->offset << ")";			os << " partition delta_t\" with impulses";		}	}	for( vector<pair<tsynapse_base *, ntime_t> >::iterator i = syns.begin(); i != syns.end(); i++ )	{		int xcol = (i->second == 0.0 ? 1 : ++column);		os << delim << " \\" << endl << "\t'" << logfile << "' " << 			"using " << xcol << ":" << (++column) << " axes x1y2 " <<			"title \"" << i->first->getClassName() << " '" << i->first->getSrc().getName() << "' -> '" << i->first->getDest().getName() << "'";		if( i->second != 0.0 )			os << "(delay " << i->second << ")";		os << "\" with lines";		delim = ",";	}	os << endl;	os << "pause -1" << endl;}//////////////////////////////////////////////////////////////////////////} // namespace punnets_common//////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -