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 | { |
---|
23 | paramentries = NI_StdNeuron_tab; |
---|
24 | } |
---|
25 | NeuroImpl* makeNew() { return new NI_StdNeuron(); } // for NeuroFactory |
---|
26 | int lateinit(); |
---|
27 | void go(); |
---|
28 | }; |
---|
29 | |
---|
30 | extern ParamEntry NI_StdUNeuron_tab[]; |
---|
31 | |
---|
32 | class NI_StdUNeuron : public NI_StdNeuron |
---|
33 | { |
---|
34 | public: |
---|
35 | NI_StdUNeuron() |
---|
36 | { |
---|
37 | paramentries = NI_StdUNeuron_tab; |
---|
38 | } |
---|
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(rndDouble(2) - 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 | { |
---|
91 | paramentries = NI_Sinus_tab; |
---|
92 | } |
---|
93 | void go() |
---|
94 | { |
---|
95 | t += f0 + getWeightedInputSum(); |
---|
96 | setState(sin(t)); |
---|
97 | } |
---|
98 | }; |
---|
99 | |
---|
100 | #endif |
---|