| 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
|---|
| 2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
|---|
| 3 | // See LICENSE.txt for details. |
|---|
| 4 | |
|---|
| 5 | #ifndef _NEUROIMPLSIMPLE_H_ |
|---|
| 6 | #define _NEUROIMPLSIMPLE_H_ |
|---|
| 7 | |
|---|
| 8 | #include <frams/neuro/neuroimpl.h> |
|---|
| 9 | #include <common/nonstd_math.h> |
|---|
| 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),inertia(0),force(0),sigmo(0) |
|---|
| 22 | {paramentries=NI_StdNeuron_tab;} |
|---|
| 23 | NeuroImpl* makeNew(){return new NI_StdNeuron();} // for NeuroFactory |
|---|
| 24 | int lateinit(); |
|---|
| 25 | void go(); |
|---|
| 26 | }; |
|---|
| 27 | |
|---|
| 28 | extern ParamEntry NI_StdUNeuron_tab[]; |
|---|
| 29 | |
|---|
| 30 | class NI_StdUNeuron: public NI_StdNeuron |
|---|
| 31 | { |
|---|
| 32 | public: |
|---|
| 33 | NI_StdUNeuron() |
|---|
| 34 | {paramentries=NI_StdUNeuron_tab;} |
|---|
| 35 | NeuroImpl* makeNew(){return new NI_StdUNeuron();} // for NeuroFactory |
|---|
| 36 | void calcOutput(); |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | class NI_Const: public NeuroImpl |
|---|
| 40 | { |
|---|
| 41 | public: |
|---|
| 42 | NeuroImpl* makeNew(){return new NI_Const();} // for NeuroFactory |
|---|
| 43 | int lateinit() |
|---|
| 44 | { |
|---|
| 45 | neuro->state=newstate=1.0; |
|---|
| 46 | simorder=0; |
|---|
| 47 | return 1; |
|---|
| 48 | } |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | class NI_Diff : public NeuroImpl |
|---|
| 52 | { |
|---|
| 53 | double previous; |
|---|
| 54 | public: |
|---|
| 55 | NeuroImpl* makeNew() { return new NI_Diff(); }; |
|---|
| 56 | |
|---|
| 57 | void go() |
|---|
| 58 | { |
|---|
| 59 | double s=getWeightedInputSum(); |
|---|
| 60 | setState(s-previous); |
|---|
| 61 | previous=s; |
|---|
| 62 | } |
|---|
| 63 | int lateinit() |
|---|
| 64 | { |
|---|
| 65 | NeuroImpl::lateinit(); |
|---|
| 66 | previous=neuro->state; |
|---|
| 67 | return 1; |
|---|
| 68 | } |
|---|
| 69 | }; |
|---|
| 70 | |
|---|
| 71 | class NI_Random : public NeuroImpl |
|---|
| 72 | { |
|---|
| 73 | public: |
|---|
| 74 | NeuroImpl* makeNew() { return new NI_Random(); }; |
|---|
| 75 | void go() {setState(rnd01*2.0-1.0);} |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | extern ParamEntry NI_Sinus_tab[]; |
|---|
| 79 | |
|---|
| 80 | class NI_Sinus : public NeuroImpl |
|---|
| 81 | { |
|---|
| 82 | public: |
|---|
| 83 | double f0,t; |
|---|
| 84 | NeuroImpl* makeNew() { return new NI_Sinus(); }; |
|---|
| 85 | NI_Sinus():f0(0),t(0) |
|---|
| 86 | {paramentries=NI_Sinus_tab;} |
|---|
| 87 | void go() |
|---|
| 88 | { |
|---|
| 89 | t+=f0+getWeightedInputSum(); |
|---|
| 90 | setState(sin(t)); |
|---|
| 91 | } |
|---|
| 92 | }; |
|---|
| 93 | |
|---|
| 94 | #endif |
|---|
| 95 | |
|---|