/*Copyright (C) 2005, 2006, 2007, 2008 Frank Michler, Philipps-University Marburg, Germany 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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _H_LIBCSIM #define _H_LIBCSIM #include "libvector.h" #include #include #include "anyoption.h" #include #include #include #include #include #include #include #include #include #include #include #include "lut.hpp" #include "typedefs.hpp" #include "stringutils.h" //#include using namespace std; inline string AddSpaces(const string &st) { string Spaces = " "; string out=st; string::size_type i; out.replace(0,0,Spaces); i=0; i = out.find("\n", i+1); while (i != string::npos) { if (i+1 < out.size()) out.replace(i+1, 0, Spaces); i = out.find("\n", i+1); } return out; } #define getrandom(max1) ((rand()%(int)((max1)))) // random integer between 0 and max-1 #define ExpDec(t) (LutExpDec(int(t))) const int NLutExpDec=100000; const float TauLut=NLutExpDec/10; static LUT_function<0, NLutExpDec> LutExpDec(exp,-1./(TauLut)); //define lookup table for NMDA current inline double NmdaCurrent(double Voltage) { // from Deco&Rolls 2005 // (they cite Jahr and Stevens 1990). return -0.327*Voltage/(1+exp(-0.062*Voltage)/3.57); } const int NLutNmda=10000; const float NmdaV0=-200; const float NmdaV1=50; const float NmdaVRange=NmdaV1-NmdaV0; const float NmdaVToIntFactor=NLutNmda/NmdaVRange; const float NmdaIntToVFactor=NmdaVRange/NLutNmda; //!static LUT_function static LUT_function<-8000, 2000> LutNmdaCurrent(NmdaCurrent,0.0250000); // FixMe clean up this, converted const expressions into literals after // transition to debian etch g++ 4.1.2 #define INmda(v) (LutNmdaCurrent(int(NmdaVToIntFactor*v))) double gauss(double x, double sigma=1, double x0=0); int fexist(const char *filename ); int FileSize(const char *filename ); // alpha function: f(t) = t*exp(-t/tau)/(tau/e) inline float* AlphaFktLut( int &N, float TauPeak=10, float Amp=1, float BaseLine=0, float dt=0.25) { float Bound = 10*TauPeak; N = int(Bound/dt); float* Lut = new float [N]; float Em1 = exp(-1.0); // 1/e for (int n=0;n Rectangle(float x0, float x1, float y0, float y1, int N) { vector tmp; if (N>=4) { float circumference =2*(x1+y1-x0-y0); float corners [4] = {0, x1-x0, circumference/2, circumference-(y1-y0)}; // float corners[4] = {3,3,3,3}; float CurMP=0; float StepSize=circumference/(N); while ((circumference-CurMP)>(StepSize/2)) { cout << "CurMP=" << CurMP << " circ=" << circumference << "diff=" << circumference-CurMP << "\n"; if (CurMP< corners[1]) tmp.push_back(vector2d(x0 + CurMP, y0)); else if (CurMP T** NewArray2d(T** &temp, int a, int b) { temp = new T*[a]; for (int i=0; i int DeleteArray2d(T** &ArrayPointer, int a) { int i; for (i=0; i T*** NewArray3d(T*** &temp, int a, int b, int c) { temp = new T**[a]; for (int i=0; i int DeleteArray3d(T*** &ArrayPointer, int a, int b) { int i,j; for (i=0;i &Profile); ~DistanceProfile(); float GetValue(float dist); float GetMaxConDistance(float minweight); void print(); }; class CircleDistanceProfile: public DistanceProfile { public: CircleDistanceProfile(int N, float Radius, bool invers=false); }; enum DirType {CSIM_left=-1, CSIM_right=1}; /** @brief input channels */ enum csimInputChannel { csimInputChannel_AMPA, //!< AMPA: fast excitatory csimInputChannel_GABAa, //!< GABAa: fast inhibitory //! NMDA_AMPA: combined NMDA and AMPA input, NMDA is long lasting excitatory csimInputChannel_NMDA_AMPA, csimInputChannel_GABAb, //!< GABAb: long lasting inhibitory csimInputChannel_AMPA2, //!< csimInputChannel_Linking, //!< csimInputChannel_Endu, //!< csimInputChannel_EnduLinking,//!< csimInputChannel_Membrane, //!< inject current directly to membrand potential }; class layer; // forward declaration class Connection; //! forward declaration class connection; //! forward declaration --> loeschen geht noch nicht?? class AbstractNormalize; //! forward declaration class learning; // forward declaration for learning pointer in class connection class veclearning; // forward declaration for learning pointer in class connection class input; //! structure for transfering connection parameters to learning object typedef struct { int Dmax; int maximumDelay; float MaxWeight; layer *TargetLayer, *SourceLayer; short** delays_length; short*** delays; int M; int **post; int **I_pre, **D_pre; int **m_pre; float **WeightPointer; float **WeightDerivativePointer; int maxN_pre; int *N_pre; pfloat **s_pre, **sd_pre; } ConnectionInfo; //! structure for transfering connection parameters to learning object typedef struct { int Dmax; int maximumDelay; float MaxWeight; layer *TargetLayer, *SourceLayer; vector* PSynWeights; vector* PSynSourceNr; vector* PSynTargetNr; vector* PSynDelays; vector >* PPreSynNr; vector > >* Pdelays; } VecConnectionInfo; ///////////////////////////////////////// class ParameterSet { public: // virtual destructor needed to make class polymorphic and use dynamic_cast virtual ~ParameterSet(){} }; template class TwoParameters: public ParameterSet { public: TwoParameters(T1 Val1, T2 Val2): first(Val1), second(Val2) {} T1 first; T2 second; }; class Changable { public: virtual void changeParameter(ParameterSet* Paras)=0; }; ///////////////////////////////// class SimpleTextProgressBar { float Status; // 0<=status<=Final float StepSize; int Final; public: SimpleTextProgressBar(int MaxSteps=10); int Next(int StepNr); int Reset(int MaxSteps); }; ////////////////////// // forward declaration class AnyOptionWrapper; //StandardOptions class CSimStandardOptions { private: AnyOptionWrapper *myAnyWrap; public: CSimStandardOptions(AnyOptionWrapper* _opt); int NTrials; int NSteps; int TestNSteps; string DataDirectory; bool LoadWeights; bool SimFinishButton; float InputStrength; bool SaveInitialWeights; }; ///////////////// /*********IDLrpc******************/ /* class IDLrpc */ /* { */ /* public: */ /* IDLrpc(); */ /* ~IDLrpc(); */ /* }; */ //////////////////// #endif /*_H_LIBCSIM */