[5] | 1 | // This file is a part of Framsticks GDK library. |
---|
| 2 | // Copyright (C) 2002-2006 Szymon Ulatowski. See LICENSE.txt for details. |
---|
| 3 | // Refer to http://www.frams.alife.pl/ for further information. |
---|
| 4 | |
---|
| 5 | #ifndef _NEUROIMPLSIMPLE_H_ |
---|
| 6 | #define _NEUROIMPLSIMPLE_H_ |
---|
| 7 | |
---|
| 8 | #include "neuroimpl.h" |
---|
| 9 | |
---|
| 10 | extern ParamEntry NI_StdNeuron_tab[]; |
---|
| 11 | |
---|
| 12 | class NI_StdNeuron: public NeuroImpl |
---|
| 13 | { |
---|
| 14 | protected: |
---|
| 15 | double istate, velocity; |
---|
| 16 | void calcInternalState(); |
---|
| 17 | virtual void calcOutput(); |
---|
| 18 | public: |
---|
| 19 | double inertia,force,sigmo; |
---|
| 20 | NI_StdNeuron():velocity(0) |
---|
| 21 | #ifdef MODEL_V1_COMPATIBLE |
---|
| 22 | ,inertia(-1),force(-1),sigmo(1e10)// illegal values, will be adjusted in lateinit() |
---|
| 23 | #else |
---|
| 24 | ,inertia(0),force(0),sigmo(0) |
---|
| 25 | #endif |
---|
| 26 | {paramentries=NI_StdNeuron_tab;} |
---|
| 27 | NeuroImpl* makeNew(){return new NI_StdNeuron();} // for NeuroFactory |
---|
| 28 | int lateinit(); |
---|
| 29 | void go(); |
---|
| 30 | }; |
---|
| 31 | |
---|
| 32 | extern ParamEntry NI_StdUNeuron_tab[]; |
---|
| 33 | |
---|
| 34 | class NI_StdUNeuron: public NI_StdNeuron |
---|
| 35 | { |
---|
| 36 | public: |
---|
| 37 | NI_StdUNeuron() |
---|
| 38 | {paramentries=NI_StdUNeuron_tab;} |
---|
| 39 | NeuroImpl* makeNew(){return new NI_StdUNeuron();} // for NeuroFactory |
---|
| 40 | void calcOutput(); |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | class NI_Const: public NeuroImpl |
---|
| 44 | { |
---|
| 45 | public: |
---|
| 46 | NeuroImpl* makeNew(){return new NI_Const();} // for NeuroFactory |
---|
| 47 | int lateinit() |
---|
| 48 | { |
---|
| 49 | neuro->state=newstate=1.0; |
---|
| 50 | simorder=0; |
---|
| 51 | return 1; |
---|
| 52 | } |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | class NI_Diff : public NeuroImpl |
---|
| 56 | { |
---|
| 57 | double previous; |
---|
| 58 | public: |
---|
| 59 | NeuroImpl* makeNew() { return new NI_Diff(); }; |
---|
| 60 | |
---|
| 61 | void go() |
---|
| 62 | { |
---|
| 63 | double s=getWeightedInputSum(); |
---|
| 64 | setState(s-previous); |
---|
| 65 | previous=s; |
---|
| 66 | } |
---|
| 67 | int lateinit() |
---|
| 68 | { |
---|
| 69 | NeuroImpl::lateinit(); |
---|
| 70 | previous=neuro->state; |
---|
| 71 | return 1; |
---|
| 72 | } |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | class NI_Random : public NeuroImpl |
---|
| 76 | { |
---|
| 77 | public: |
---|
| 78 | NeuroImpl* makeNew() { return new NI_Random(); }; |
---|
| 79 | void go() {setState(rnd01*2.0-1.0);} |
---|
| 80 | }; |
---|
| 81 | |
---|
| 82 | extern ParamEntry NI_Sinus_tab[]; |
---|
| 83 | |
---|
| 84 | class NI_Sinus : public NeuroImpl |
---|
| 85 | { |
---|
| 86 | public: |
---|
| 87 | double f0,t; |
---|
| 88 | NeuroImpl* makeNew() { return new NI_Sinus(); }; |
---|
| 89 | NI_Sinus():f0(0),t(0) |
---|
| 90 | {paramentries=NI_Sinus_tab;} |
---|
| 91 | void go() |
---|
| 92 | { |
---|
| 93 | t+=f0+getWeightedInputSum(); |
---|
| 94 | setState(sin(t)); |
---|
| 95 | } |
---|
| 96 | }; |
---|
| 97 | |
---|
| 98 | #endif |
---|
| 99 | |
---|