The following source file, led by a gray banner, contains all the class functions needed for the user override routines in Project IAC. The sections highlighted by a yellow background Color are manually entered. Code sections with white background color are from the skeleton code supplied with the SansGUI Modeling and Simulation Environment. The source file is compiled into a dynamic linked library to be invoked by SansGUI during simulation runs.
Overriding Functions for Class Base.Neuron
For more details about this example, please read A Tour of SansGUI Examples in the SansGUI Getting Started Guide.
/*
SGover.cpp - sample user DLL override framework *
simulation developers' routines for run-time execution. *
Grossberg's method for neuron input and evaluation calculations. |
#include <stdio.h> |
#include <string.h> |
#define
SG_OVERRIDE_FUNC /* to use the function declarations in SGdll.h */ |
/* Macros for attribute indices in class <Component>Base.Neuron * version [1.0.beta.0] */ #define SG_NDX_FACTIVATION
2 /* fActivation - Activation Level */ /*
Macros added to access link attributes */ |
/* ====================================================================== *
SG_xPreEval - called before SG_xEval() per cycle or event |
INT i; |
if (!SG_IsSchemaOK(self->nSGobjSchema)) /* TODO: put your simulator code here */ |
/* This routine implements get net input from each of the adjacent unit */
/* zero out local excitation and inhibition level for accumulation */
/* calculate excitation and inhibition level from adjacent units */
lnkObjs[i]->zValues[LINK_NDX_FWINH].fData[0] :
/* scale excitation and inhibition */
/* using grossberg's method, adjust excitation and inhibition levels
* separately according to the external input level
(*pfExtInput); (*pfExtInput); |
return SG_R_OK; |
FLOAT* pfAct = &self->zValues[SG_NDX_FACTIVATION].fData[0]; |
if (!SG_IsSchemaOK(self->nSGobjSchema)) /* TODO: put your simulator code here */ |
/* implements Grossberg's method for activation level update */
(fMaxActiv - (*pfAct)) +
((*pfAct) - fMinActiv) +
/* adjust to max or min activation when out of range */
/* uncomment the following to show the message in the log -- * slower update! */
/* |
return SG_R_OK; |
SansGUI Modeling and Simulation Environment version 1.2
Copyright © 2000-2003 ProtoDesign, Inc. All rights reserved.