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)
196 std::string filename(
"NeuronPop_" );
197 filename.append(
getName().getEncodedName() );
198 filename.append(
".dat" );
200 replace( filename.begin(), filename.end(),
'%',
'_' );
201 replace( filename.begin(), filename.end(),
':',
'_' );
204 outputFileStreamPtr->open( filename.c_str() );
205 if( !(*outputFileStreamPtr) )
207 UserError(*
this) <<
"Could not open file " << filename <<
" for output of population variables";
210 (*outputFileStreamPtr).setf(std::ios::scientific, std::ios::floatfield );
211 (*outputFileStreamPtr).width(20);
212 (*outputFileStreamPtr).precision(12);
255 bool bsuccess =
true;
268 const std::vector<int> & extLIDVecRef)
273 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
275 Xyce::dout() << std::endl << section_divider << std::endl;
276 Xyce::dout() <<
" Instance::registerLIDs" << std::endl;
277 Xyce::dout() <<
" name = " <<
getName() << std::endl;
351 int numRows = jacLIDVec.size();
375 const double random_max = std::pow(2.0,31)-1;
385 Xyce::dout() <<
"Instance::initializePopulation "
393 for(
int i=0; i<maxPopSize; i++)
398 staVector[ liNeuronPopState[
model_.
neuronsMax + i ] ] = (rand()/random_max);
400 staVector[ liNeuronPopState[2 *
model_.
neuronsMax + i ] ] = (rand()/random_max);
404 for(
int i=0; i<maxPopSize; i++)
409 for(; k<numConnections; k++)
411 int postNeuron = (rand()/random_max) * maxPopSize;
453 Xyce::dout() <<
"Instance::updatePopulation "
507 bool bsuccess =
true;
527 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
529 Xyce::dout() <<
" Instance::updateIntermediateVars\n";
534 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
536 Xyce::dout() <<
" Time = " << time << std::endl;
571 bool bsuccess =
true;
587 bool bsuccess =
true;
602 bool bsuccess =
true;
644 bool bsuccess =
true;
663 bool bsuccess =
true;
686 bool bsuccess =
true;
701 (*outputFileStreamPtr)
736 (*outputFileStreamPtr) <<
", ";
740 (*outputFileStreamPtr) << std::endl;
759 bool bsuccess =
true;
791 :
DeviceModel(MB, configuration.getModelParameters(), factory_block),
793 neuronsMaxGiven(false),
794 internalMaxConnections(0),
795 internalMaxConnectionsGiven(false),
796 externalMaxConnections(0),
797 externalMaxConnectionsGiven(false),
798 populationNeurogenesisRate(0.0),
799 populationNeurogenesisRateGiven(false),
800 populationUpdatePeriod(0.0),
801 populationUpdatePeriodGiven(false),
802 outputPopulationVars(0)
835 std::vector<Instance*>::iterator iter;
839 for (iter=first; iter!=last; ++iter)
871 std::vector<Instance*>::iterator iter;
875 for (iter=first; iter!=last; ++iter)
877 (*iter)->processParams();
892 std::vector<Instance*>::const_iterator iter;
900 os <<
"Number of Neuron instances: " << isize << std::endl;
901 os <<
" name=\t\tmodelName\tParameters" << std::endl;
902 for (i=0, iter=first; iter!=last; ++iter, ++i)
904 os <<
" " << i <<
": " << (*iter)->getName() <<
"\t";
929 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
943 .registerDevice(
"neuronpop", 1)
944 .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
bool outputPlotFiles(bool force_final_output)
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.
double currTime_
DeviceEntity for expression time, breakpoints DeviceMgr for dependent parameters, breakpoints...
std::vector< Param > params
int internalMaxConnections
Linear::Matrix * dQdxMatrixPtr
Linear::Vector * nextStaDerivVectorPtr
void setModParams(const std::vector< Param > ¶ms)