46 #include <Xyce_config.h>
53 #include <N_UTL_Misc.h>
68 #include <N_ERH_ErrorMgr.h>
70 #include <N_LAS_Vector.h>
71 #include <N_LAS_Matrix.h>
72 #include <N_UTL_BreakPoint.h>
78 namespace NeuronPop1 {
94 .setDescription(
"Maximum number of neurons in the device");
97 .setDescription(
"Maximum number of internal connections in the device");
100 .setDescription(
"Maximum number of external connections in the device");
104 .setDescription(
"Rate in days of GC neurogenesis in the population");
108 .setDescription(
"Time in days for population updates");
110 .setDescription(
"Flag to save population variables" );
132 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
138 populationInitialized(false),
140 connectionTargetPopulationGiven(false),
141 numberOfUpdatesDone(0),
142 lastPopulationUpdateTime(0.0),
143 lastNeurogenesisUpdateTime(0.0),
144 outputPopulationVarsFlag(false),
145 newStateToOutput(false)
240 std::string filename(
"NeuronPop_" );
241 filename.append(
getName().getEncodedName() );
242 filename.append(
".dat" );
244 replace( filename.begin(), filename.end(),
'%',
'_' );
245 replace( filename.begin(), filename.end(),
':',
'_' );
248 outputFileStreamPtr->open( filename.c_str() );
249 if( !(*outputFileStreamPtr) )
251 UserError(*
this) <<
"Could not open file " << filename <<
" for output of population variables";
254 (*outputFileStreamPtr).setf(std::ios::scientific, std::ios::floatfield );
255 (*outputFileStreamPtr).width(20);
256 (*outputFileStreamPtr).precision(12);
302 bool bsuccess =
true;
315 const std::vector<int> & extLIDVecRef)
320 #ifdef Xyce_DEBUG_DEVICE
323 Xyce::dout() << std::endl << section_divider << std::endl;
324 Xyce::dout() <<
" Instance::registerLIDs" << std::endl;
325 Xyce::dout() <<
" name = " <<
getName() << std::endl;
352 std::ostringstream segNumber;
400 bool returnVal=
false;
433 int numRows = jacLIDVec.size();
457 const double random_max = std::pow(2.0,31)-1;
465 #ifdef Xyce_DEBUG_DEVICE
468 Xyce::dout() <<
"Instance::initializePopulation "
477 for(
int i=0; i<maxPopSize; i++)
482 staVector[ liNeuronPopState[
model_.
neuronsMax + i ] ] = (rand()/random_max);
484 staVector[ liNeuronPopState[2 *
model_.
neuronsMax + i ] ] = (rand()/random_max);
488 for(
int i=0; i<maxPopSize; i++)
493 for(; k<numConnections; k++)
495 int postNeuron = (rand()/random_max) * maxPopSize;
535 #ifdef Xyce_DEBUG_DEVICE
538 Xyce::dout() <<
"Instance::updatePopulation "
593 bool bsuccess =
true;
613 #ifdef Xyce_DEBUG_DEVICE
616 Xyce::dout() <<
" Instance::updateIntermediateVars\n";
622 #ifdef Xyce_DEBUG_DEVICE
625 Xyce::dout() <<
" Time = " << time << std::endl;
661 bool bsuccess =
true;
677 bool bsuccess =
true;
692 bool bsuccess =
true;
734 bool bsuccess =
true;
753 bool bsuccess =
true;
776 bool bsuccess =
true;
791 (*outputFileStreamPtr)
826 (*outputFileStreamPtr) <<
", ";
830 (*outputFileStreamPtr) << std::endl;
849 bool bsuccess =
true;
881 :
DeviceModel(MB, configuration.getModelParameters(), factory_block),
883 neuronsMaxGiven(false),
884 internalMaxConnections(0),
885 internalMaxConnectionsGiven(false),
886 externalMaxConnections(0),
887 externalMaxConnectionsGiven(false),
888 populationNeurogenesisRate(0.0),
889 populationNeurogenesisRateGiven(false),
890 populationUpdatePeriod(0.0),
891 populationUpdatePeriodGiven(false),
892 outputPopulationVars(0)
925 std::vector<Instance*>::iterator iter;
929 for (iter=first; iter!=last; ++iter)
961 std::vector<Instance*>::iterator iter;
965 for (iter=first; iter!=last; ++iter)
967 (*iter)->processParams();
982 std::vector<Instance*>::const_iterator iter;
990 os <<
"Number of Neuron instances: " << isize << std::endl;
991 os <<
" name=\t\tmodelName\tParameters" << std::endl;
992 for (i=0, iter=first; iter!=last; ++iter, ++i)
994 os <<
" " << i <<
": " << (*iter)->getName() <<
"\t";
1019 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1033 .registerDevice(
"neuronpop", 1)
1034 .registerModelType(
"neuronpop", 1);