source: cpp/frams/neuro/impl/neuroimpl-simple.h @ 781

Last change on this file since 781 was 726, checked in by Maciej Komosinski, 7 years ago
  • Changed Model::singleStepBuild() to Model::addFromString() to create model elements; the latter requires explicit indication of element type (P/J/N/C)
  • Removed old compatibility source (#ifdef MODEL_V1_COMPATIBLE) from f1->f0 converter and neuron definitions
  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
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
11extern ParamEntry NI_StdNeuron_tab[];
12
13class NI_StdNeuron: public NeuroImpl
14{
15  protected:
16double istate, velocity;
17void calcInternalState();
18virtual void calcOutput();
19  public:
20double inertia,force,sigmo;
21NI_StdNeuron():velocity(0),inertia(0),force(0),sigmo(0)
22        {paramentries=NI_StdNeuron_tab;}
23NeuroImpl* makeNew(){return new NI_StdNeuron();} // for NeuroFactory
24int lateinit();
25void go();
26};
27
28extern ParamEntry NI_StdUNeuron_tab[];
29
30class NI_StdUNeuron: public NI_StdNeuron
31{
32  public:
33NI_StdUNeuron()
34        {paramentries=NI_StdUNeuron_tab;}
35NeuroImpl* makeNew(){return new NI_StdUNeuron();} // for NeuroFactory
36void calcOutput();
37};
38
39class NI_Const: public NeuroImpl
40{
41public:
42NeuroImpl* makeNew(){return new NI_Const();} // for NeuroFactory
43int lateinit()
44        {
45        neuro->state=newstate=1.0;
46        simorder=0;
47        return 1;
48        }
49};
50
51class NI_Diff : public NeuroImpl
52{
53double previous;     
54  public:
55NeuroImpl* makeNew() { return new NI_Diff(); };
56
57void go()
58        {
59        double s=getWeightedInputSum();
60        setState(s-previous);
61        previous=s;
62        }
63int lateinit()
64        {
65        NeuroImpl::lateinit();
66        previous=neuro->state;
67        return 1;
68        }
69};
70
71class NI_Random : public NeuroImpl
72{
73  public:
74NeuroImpl* makeNew() { return new NI_Random(); };
75void go() {setState(rnd01*2.0-1.0);}
76};
77
78extern ParamEntry NI_Sinus_tab[];
79
80class NI_Sinus : public NeuroImpl
81{
82  public:
83double f0,t;
84NeuroImpl* makeNew() { return new NI_Sinus(); };
85NI_Sinus():f0(0),t(0)
86        {paramentries=NI_Sinus_tab;}
87void go()
88        {
89        t+=f0+getWeightedInputSum();
90        setState(sin(t));
91        }
92};
93
94#endif
95
Note: See TracBrowser for help on using the repository browser.