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