forked from Conedy/Conedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynNetwork.h
183 lines (108 loc) · 8.06 KB
/
dynNetwork.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
172
173
174
175
176
177
178
179
180
181
182
#ifndef dynNetwork_h
#define dynNetwork_h dynNetwork_h
#include "network.h"
#include "eventHandler.h"
#include "dynNode.h"
#include "globals.h"
//#include "ioNode.h"
namespace conedy
{
//! Class, which supplies network function, which control features of the network related to dynamics... setting initial conditions, parameters, starting numerical integration
class dynNetwork : public virtual network, eventHandler
{
public:
static void registerStandardValues()
{
registerGlobal<baseType>("samplingTime", 0.01);
registerGlobal<baseType>("progressVerbosity", 100.0);
globals::registerGlobal<bool> ("outputBinary", false );
}
// Functions which are reavealed to the interpreter
//! Evolve the system time from startTime to endTime
void evolve ( baseType startTime, baseType endTime );
baseType getParam(nodeDescriptor nodeNumber,string name) { return ((dynNode*) (node::theNodes[nodeNumber]))->getParam(name); }
//! return component <component> of node <node>
baseType getState (nodeDescriptor node, nodeDescriptor component = 0);
//! observe node number via an edge of type l
void observe ( nodeDescriptor number, string s,edgeBlueprint * l = stdEdge);
void observeAll ( string s, edgeBlueprint *l = stdEdge, nodeBlueprint *n = stdNode);
//! Observe all components of a node (e.g. all three variables of a roessler oscillator)
void observeComponents (nodeDescriptor n, string fileName);
void observeHist ( string s, nodeBlueprint *n);
//! wie oben. Phasen werden von Edges vom Typ l übergeben.
void observeMeanPhase ( string s, edgeBlueprint *l=stdEdge );
void observePhaseCoherence ( string s, edgeBlueprint *l = stdEdge, nodeBlueprint *n = stdNode);
//! wie oben mit links vom Typ l
void observeSum ( string s, edgeBlueprint *l = stdEdge );
//! Observe the system time
void observeTime ( string s );
//! remove all registered observables. This also closes all open files.
void removeObserver ();
//! Sets random states for all nodes in the network which match the blueprint n.
void randomizeStatesVec (nodeBlueprint *n, vector<boost::function<baseType() > >r);
//! Does the same as randomizeStatesVec. However, values are given seperately. Is used to generate function wrappers for the python interface in a simple way.
void randomizeStates ( nodeBlueprint *n, boost::function<baseType () > a1, boost::function<baseType () > a2 = NULL, boost::function<baseType () > a3 = NULL, boost::function<baseType () > a4 = NULL, boost::function<baseType () > a5 = NULL, boost::function<baseType () > a6 = NULL, boost::function<baseType () > a7 = NULL, boost::function<baseType () > a8 = NULL, boost::function<baseType () > a9 = NULL, boost::function<baseType () > a10 = NULL, boost::function<baseType () > a11 = NULL, boost::function<baseType () > a12 = NULL);
//! Set states of all nodes which match n. Values are read from a file with name fileName.
void readInitialCondition ( string fileName, nodeBlueprint * n );
//! Draw a random value for parameter s for each node in the network to which s belongs.
void randomizeParameter ( string s, boost::function<baseType () > r );
void readParameter ( string,string );
//! Print the value of all registered observables to files.
void snapshot () { callBack (0); }
void setParam (nodeDescriptor nd, string parameterName, baseType value) { ((dynNode *)node::theNodes[nd])-> setParam (parameterName, value); }
//! set state of node n with the values given in the vector <argList>
void setInitialConditionVec ( int n, vector <baseType> argList );
//! Does the same as setInitialConditionVec. However, values are given seperately. Is used to generate function wrappers for the python interface in a simple way.
void setInitialCondition ( int n, baseType a1, baseType a2 = numeric_limits<baseType>::max(), baseType a3 = numeric_limits<baseType>::max(), baseType a4 = numeric_limits<baseType>::max(), baseType a5 = numeric_limits<baseType>::max(), baseType a6 = numeric_limits<baseType>::max(), baseType a7 = numeric_limits<baseType>::max(), baseType a8 = numeric_limits<baseType>::max(), baseType a9 = numeric_limits<baseType>::max(), baseType a10 = numeric_limits<baseType>::max(), baseType a11 = numeric_limits<baseType>::max(), baseType a12 = numeric_limits<baseType>::max());
// inofficial functions (atm)
void noiseToStatesVec (nodeBlueprint *n, vector<boost::function<baseType()> >r);
//! Set states of all nodes which match n. Such that newstate = oldstate + r().
void noiseToStates ( boost::function<baseType () > r, networkElementType n = _undefinedNodeType_ );
//! obsolete ?
void startingConditionOpenWaveEnding();
//! obsolete ?
void startingConditionOpenWaveEndingMiddle();
//! obsolete ?
void smallDisturbance ( baseType radius, int posx, int posy, boost::function<baseType () > r );
//! obsolete ?
void smallDisturbance ( baseType radius, boost::function<baseType () > r ) { unsigned int size = sqrt ( numberVertices() ); smallDisturbance ( radius, size/2, size/2, r ); }
void observeEvent (string s, nodeDescriptor signature);
void observeEventTimes( string fileName,nodeDescriptor eventNumber );
void observeEventTimesEquals ( string fileName, nodeDescriptor eventNumber );
void observeEventSignatureTimes( string fileName,nodeDescriptor eventNumber );
void observeEventCounter ( string s, unsigned int signature);
//! do a snapshot of all observables in the incidence of event <eventNumber>
void snapshotAtEvent( nodeDescriptor eventNumber);
//! do a snapshot of all observables in the incidence of an event with signature <eventSignature>
void snapshotAtEventSignature( nodeDescriptor eventSignature);
//! do a snapshot of all observables in the incidence of an event with signature <eventSignature> of node <nodeNumber>
void snapshotAtEventOfNode (nodeDescriptor nodeNumber, unsigned int eventSignature);
//! rescale all nodestates of nodes which match nt, such that they have a distance of epsilon from nodestates which are read from file (filename input=ilename). Rescaling is done at every skip-th event with signature eventNumber
void realignAtEventSignature (string inputFilename, string outputFilename, networkElementType nt, baseType epsilon, unsigned int eventNumber, unsigned int skip);
//! rescale all nodestates of nodes which match nt, such that they have a distance of epsilon from nodestates which are read from file (filename input=ilename). Rescaling is done at every skip-th event with number eventNumber
void realignAtEvent (string inputFilename, string outputFilename, networkElementType nt, baseType epsilon, unsigned int eventNumber, unsigned int skip);
//! rescale all nodestates of nodes which match nt, such that they have a distance of epsilon from nodestates which are read from file (filename input=ilename). Rescaling is done whenever distance reaches epsilon * mult. This is checked at every periodic snapshot of observables.
void realignWhenDistant (string inputFilename, string outputFilename, networkElementType nt, baseType epsilon, unsigned int eventNumber, unsigned int multi);
void setTime( baseType newTime) { dynNode::time = newTime; eventHandler::registerCallBack ( _ioNode_, dynNode::time + getGlobal<baseType> ("samplingTime") ); }
//! return the system time.
baseType time () { return dynNode::time; }
void dynamics (nodeDescriptor n);
//! Event-callback function, we use here _ioNode_ for snapshot of observables.
virtual baseType callBack ( unsigned int eventSignature );
virtual unsigned int numberOfEvents() const { return 3; }
virtual void clear();
dynNetwork() {};
dynNetwork ( const dynNetwork &b);
void evolveFor ( baseType duration );
protected:
//! Evolve the system time for a time of length duration
nodeDescriptor addStreamOutNode (string s);
virtual void clean ();
void evolveAll ( baseType );
private:
// integer, which counts the number of periodical observations of the network.
static unsigned int observationCounter;
};
double readDouble (istream *is);
}
#endif