46 #include <Xyce_config.h>
65 #include <N_ERH_ErrorMgr.h>
67 #include <N_LAS_Vector.h>
68 #include <N_LAS_Matrix.h>
69 #include <N_UTL_BreakPoint.h>
70 #include <N_UTL_FeatureTest.h>
75 namespace NeuronPop1 {
83 .setDescription(
"Connected Target Population list");
90 .setDescription(
"Maximum number of neurons in the device");
94 .setDescription(
"Maximum number of internal connections in the device");
98 .setDescription(
"Maximum number of external connections in the device");
103 .setDescription(
"Rate in days of GC neurogenesis in the population");
108 .setDescription(
"Time in days for population updates");
111 .setDescription(
"Flag to save population variables" );
133 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
139 populationInitialized(false),
141 connectionTargetPopulationGiven(false),
142 numberOfUpdatesDone(0),
143 lastPopulationUpdateTime(0.0),
144 lastNeurogenesisUpdateTime(0.0),
145 outputPopulationVarsFlag(false),
146 newStateToOutput(false)
241 std::string filename(
"NeuronPop_" );
242 filename.append(
getName().getEncodedName() );
243 filename.append(
".dat" );
245 replace( filename.begin(), filename.end(),
'%',
'_' );
246 replace( filename.begin(), filename.end(),
':',
'_' );
249 outputFileStreamPtr->open( filename.c_str() );
250 if( !(*outputFileStreamPtr) )
252 UserError(*
this) <<
"Could not open file " << filename <<
" for output of population variables";
255 (*outputFileStreamPtr).setf(std::ios::scientific, std::ios::floatfield );
256 (*outputFileStreamPtr).width(20);
257 (*outputFileStreamPtr).precision(12);
303 bool bsuccess =
true;
316 const std::vector<int> & extLIDVecRef)
321 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
323 Xyce::dout() << std::endl << section_divider << std::endl;
324 Xyce::dout() <<
" Instance::registerLIDs" << std::endl;
325 Xyce::dout() <<
" name = " <<
getName() << std::endl;
399 int numRows = jacLIDVec.size();
423 const double random_max = std::pow(2.0,31)-1;
433 Xyce::dout() <<
"Instance::initializePopulation "
441 for(
int i=0; i<maxPopSize; i++)
446 staVector[ liNeuronPopState[
model_.
neuronsMax + i ] ] = (rand()/random_max);
448 staVector[ liNeuronPopState[2 *
model_.
neuronsMax + i ] ] = (rand()/random_max);
452 for(
int i=0; i<maxPopSize; i++)
457 for(; k<numConnections; k++)
459 int postNeuron = (rand()/random_max) * maxPopSize;
501 Xyce::dout() <<
"Instance::updatePopulation "
555 bool bsuccess =
true;
575 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
577 Xyce::dout() <<
" Instance::updateIntermediateVars\n";
582 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
584 Xyce::dout() <<
" Time = " << time << std::endl;
619 bool bsuccess =
true;
635 bool bsuccess =
true;
650 bool bsuccess =
true;
692 bool bsuccess =
true;
711 bool bsuccess =
true;
734 bool bsuccess =
true;
749 (*outputFileStreamPtr)
784 (*outputFileStreamPtr) <<
", ";
788 (*outputFileStreamPtr) << std::endl;
807 bool bsuccess =
true;
839 :
DeviceModel(MB, configuration.getModelParameters(), factory_block),
841 neuronsMaxGiven(false),
842 internalMaxConnections(0),
843 internalMaxConnectionsGiven(false),
844 externalMaxConnections(0),
845 externalMaxConnectionsGiven(false),
846 populationNeurogenesisRate(0.0),
847 populationNeurogenesisRateGiven(false),
848 populationUpdatePeriod(0.0),
849 populationUpdatePeriodGiven(false),
850 outputPopulationVars(0)
883 std::vector<Instance*>::iterator iter;
887 for (iter=first; iter!=last; ++iter)
919 std::vector<Instance*>::iterator iter;
923 for (iter=first; iter!=last; ++iter)
925 (*iter)->processParams();
940 std::vector<Instance*>::const_iterator iter;
948 os <<
"Number of Neuron instances: " << isize << std::endl;
949 os <<
" name=\t\tmodelName\tParameters" << std::endl;
950 for (i=0, iter=first; iter!=last; ++iter, ++i)
952 os <<
" " << i <<
": " << (*iter)->getName() <<
"\t";
977 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
991 .registerDevice(
"neuronpop", 1)
992 .registerModelType(
"neuronpop", 1);
const InstanceName & getName() const
bool updateSecondaryState()
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
std::vector< int > liNeuronPopState
bool updateDependentParameters()
const SolverState & solverState_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
std::vector< Instance * > instanceContainer
bool processInstanceParams()
processInstanceParams
Linear::Vector * nextSolVectorPtr
const std::vector< std::vector< int > > & jacobianStamp() const
Linear::Vector * daeQVectorPtr
Pure virtual class to augment a linear system.
void varTypes(std::vector< char > &varTypeVec)
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
bool externalMaxConnectionsGiven
std::vector< std::string > connectionTargetPopulation
double lastNeurogenesisUpdateTime
bool populationInitialized
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
bool processParams()
processParams
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
std::vector< std::vector< int > > jacStamp
static void loadModelParameters(ParametricData< Model > &model_parameters)
bool outputPopulationVarsFlag
std::vector< Param > params
Parameters from the line.
RCP< std::ofstream > outputFileStreamPtr
void setParams(const std::vector< Param > ¶ms)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
const std::string & getName() const
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual std::ostream & printOutInstances(std::ostream &os) const
bool internalMaxConnectionsGiven
const DeviceOptions & deviceOptions_
bool connectionTargetPopulationGiven
Linear::Vector * nextStaVectorPtr
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
Linear::Matrix * dFdxMatrixPtr
double populationUpdatePeriod
double populationNeurogenesisRate
The Device class is an interface for device implementations.
bool getInstanceBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
bool updateIntermediateVars()
bool updatePrimaryState()
Class Configuration contains device configuration data.
void initializePopulation()
bool populationNeurogenesisRateGiven
const SolverState & getSolverState() const
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Linear::Vector * daeFVectorPtr
int externalMaxConnections
bool updateTemperature(const double &temp_tmp)
const ExternData & extData
double lastPopulationUpdateTime
ModelBlock represents a .MODEL line from the netlist.
bool populationUpdatePeriodGiven
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
std::vector< Param > params
int internalMaxConnections
Linear::Matrix * dQdxMatrixPtr
Linear::Vector * nextStaDerivVectorPtr
void setModParams(const std::vector< Param > ¶ms)