forked from Conedy/Conedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
specialNodes.h
171 lines (125 loc) · 4.33 KB
/
specialNodes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#ifndef specialNodes_h
#define specialNodes_h specialNodes_h
#include "dynNode.h"
#include "eventHandler.h"
#include <complex>
namespace conedy
{
class eventCountNode : public nodeVirtualEdges<dynNode>
{
private:
unsigned int signature;
public:
virtual bool timeEvolution() { return 0; }
virtual const nodeInfo getNodeInfo() { nodeInfo n = {_eventCountNode_,_outNode_,"eventCountNode"}; return n; };
virtual const unsigned int dimension() const{ return 0;}
node * construct () { return new eventCountNode ( *this ); }
eventCountNode(unsigned int theSignature) : nodeVirtualEdges<dynNode> ( _eventCountNode_ ), signature(theSignature){};
virtual void clean () {};
virtual baseType getState()
{
baseType res = eventHandler::eventCount[signature];
eventHandler::eventCount[signature] = 0;
return res;
}
};
//! Node, der die momentane Integrationszeit als status zurückgibt
template <typename T>
class timeNode : public nodeVirtualEdges<dynNode>
{
public:
virtual bool timeEvolution() { return 0; }
virtual const nodeInfo getNodeInfo() { nodeInfo n = {_timeNode_,_outNode_ , "timeNode"}; return n; };
virtual const unsigned int dimension() const{ return 0;}
node * construct () { return new timeNode (*this); }
timeNode() : nodeVirtualEdges<dynNode> ( _timeNode_ ) {};
virtual void clean () {};
virtual T getState()
{
return this->time;
}
};
//!
//
//
//
//
template <typename T>
class phaseCorrelation : public dynNode
{
list <pair <nodeDescriptor, nodeDescriptor> >el;
public:
virtual bool timeEvolution() { return 0; }
virtual const nodeInfo getNodeInfo() { nodeInfo n = {_phaseCorrelation_,_dynNode_,"phaseCorrelation"}; return n; };
virtual const unsigned int dimension() const{ return 0;}
phaseCorrelation( ) : dynNode ( _phaseCorrelation_ ) {};
void setList (network::edgeList * newEdgeList) {
network::edgeIterator ei;
for (ei = newEdgeList->begin(); ei != newEdgeList->end();ei ++)
el.push_back(std::make_pair<nodeDescriptor, nodeDescriptor> (ei->first, node::theNodes[ei->first] ->getTarget(ei->second) ));
}
virtual void clean () {};
virtual T getState()
{
list <pair <nodeDescriptor,nodeDescriptor> >::iterator ei;
baseType d;
complex<double> sum (( double)0, (double)0);
for (ei = el.begin(); ei != el.end();ei ++)
{
d = (dynNode::lookUp(ei->first)-> getState() ) - ( dynNode::lookUp(ei->second) ->getState() );
complex<double> dummy (( double)0, d * 2 * M_PI);
sum = sum + exp (dummy);
}
return abs(sum);
}
};
//
//
template <typename T>
class phaseDistance : public dynNode
{
list <pair <nodeDescriptor, nodeDescriptor> >el;
public:
virtual bool timeEvolution() { return 0; }
virtual const nodeInfo getNodeInfo() { nodeInfo n = {_phaseDistance_,_dynNode_,"phaseDistance"}; return n; };
virtual const unsigned int dimension() const{ return 0;}
phaseDistance( ) : dynNode ( _phaseDistance_ ) {};
void setList (network::edgeList * newEdgeList) {
network::edgeIterator ei;
for (ei = newEdgeList->begin(); ei != newEdgeList->end();ei ++)
el.push_back(std::make_pair<nodeDescriptor, nodeDescriptor> (ei->first, node::theNodes[ei->first] ->getTarget(ei->second) ));
}
virtual void clean () {};
virtual T getState()
{
list <pair <nodeDescriptor,nodeDescriptor> >::iterator ei;
baseType d;
baseType sum = 0;
for (ei = el.begin(); ei != el.end();ei ++)
{
d = (dynNode::lookUp(ei->first)->getState() - dynNode::lookUp(ei->second)->getState());
if (abs(d) < abs(1.0-abs(d)))
d = abs(d);
else
d = abs(1.0 - abs(d));
sum += d;
}
return sum;
}
};
//! Knoten, dessen getState-Funktion zufällige Zahlen ausspuckt.
template <typename T>
class randomNode : public dynNode
{
function<T () > r;
public:
virtual const unsigned int dimension() const{ return 0;}
virtual const nodeInfo getNodeInfo() { nodeInfo n = {_randomNode_,_dynNode_|_inNode_}; return n; };
randomNode ( boost::function <double() > noise ) : dynNode ( _randomNode_ ), r ( noise ) {};
virtual void clean () {};
virtual void printStatistics() {cout << "randomNode" << endl;this->printStatistics();}
virtual T getState() {return r();}
virtual bool timeEvolution () {return 0;}
};
}
#endif