Brainsimulation
Simulation of the human brain.
definitions.h
Go to the documentation of this file.
1 #ifndef DEFINITIONS_H
2 #define DEFINITIONS_H
3 
4 #ifdef _WIN32
5 #include <Windows.h>
6 #else
7 
8 #include <pthread.h>
9 
10 #endif
11 
17 #ifndef MULTITHREADING
18 
21 #define MULTITHREADING 1
22 #endif
23 
24 #ifndef THREADFACTOR
25 
29 #define THREADFACTOR 1
30 #endif
31 
32 #ifndef D_NEIGHBORFACTOR
33 
37 #define D_NEIGHBORFACTOR 1
38 #endif
39 
40 #ifndef ID_NEIGHBORFACTOR
41 
45 #define ID_NEIGHBORFACTOR 1
46 #endif
47 
48 #ifndef DAMPING
49 
54 #define DAMPING 0.001
55 #endif
56 
57 #ifndef ENERGY_FACTOR
58 
62 #define ENERGY_FACTOR 1
63 #endif
64 
65 #ifndef ENERGY_WEIGHT
66 
70 #define ENERGY_WEIGHT 1
71 #endif
72 
73 #ifndef DELTA_FACTOR
74 
78 #define DELTA_FACTOR 1
79 #endif
80 
81 #ifndef SLOPE_FACTOR
82 
86 #define SLOPE_FACTOR 1
87 #endif
88 
89 #ifndef SLOPE_WEIGHT
90 
94 #define SLOPE_WEIGHT 1
95 #endif
96 
97 //types
98 
102 #ifdef _WIN32
103 typedef HANDLE threadhandle_t;
104 #else
105 typedef pthread_t threadhandle_t;
106 #endif
107 
111 #ifdef _WIN32
112 typedef SYNCHRONIZATION_BARRIER threadbarrier_t;
113 #else
114 typedef pthread_barrier_t threadbarrier_t;
115 #endif
116 
120 typedef double nodeval_t;
121 
126 typedef struct {
130  int x_index;
134  int y_index;
144 }
146 
151 typedef struct {
155  int x_index;
159  int y_index;
169 }
171 
175 typedef struct {
184 }
185  nodestate_t;
186 
190 typedef int(*kernelfunc_t)(nodeval_t *, int, int, nodeval_t **, int, int);
191 
196 typedef struct {
197 
202 
206  double tick_ms;
207 
212 
217 
222 
227 
232 
238 
244 
251 
256 
261 
266 
271 
276 
282 
288 
296 
301 }
303 
304 #endif
int num_obervationnodes
The number of nodes to observe.
Definition: definitions.h:221
Struct to store the input for the simulation for a single node.
Definition: definitions.h:151
nodeval_t * timeseries
Series of observed node energy levels.
Definition: definitions.h:139
int thread_start_x
Node x index at which to start working in this thread (inclusive).
Definition: definitions.h:255
kernelfunc_t id_ptr
Function pointer pointing to the kernel function for the indirect neighborhood.
Definition: definitions.h:270
pthread_t threadhandle_t
Platform-independent thread handle.
Definition: definitions.h:105
nodeval_t * timeseries
Series of energy levels to be added at the specified node at the given tick.
Definition: definitions.h:164
nodeval_t ** new_state
2D array of nodes with the new energy level.Values will be overwritten.Size number_nodes_x * number_n...
Definition: definitions.h:237
int num_ticks
Number of ticks in the simulation.
Definition: definitions.h:201
nodeinputseries_t ** partial_inputs
Points the the inputs in the sub-grid of this partial simulation.
Definition: definitions.h:295
pthread_barrier_t threadbarrier_t
Platform-independent thread barrier.
Definition: definitions.h:114
int number_partial_inputs
Number of inputs in the sub-grid of this partial simulation.
Definition: definitions.h:287
double nodeval_t
Type that the nodes in the brainsimulation use to store their energy level.
Definition: definitions.h:120
int thread_end_x
Node x index at which to stop working in this thread (exclusive).
Definition: definitions.h:260
int timeseries_ticks
Length of timeseries.
Definition: definitions.h:143
nodeinputseries_t * global_inputs
Contains information about the coordinates and the values of all input nodes to be changed during exe...
Definition: definitions.h:281
nodeval_t slope
Slope of node.
Definition: definitions.h:183
Struct to store the results of a simulation for a single observed node.
Definition: definitions.h:126
int number_nodes_y
The number of total nodes in the second dimension of nodes.
Definition: definitions.h:216
kernelfunc_t d_ptr
Function pointer pointing to the kernel function for the direct neighborhood.
Definition: definitions.h:265
nodetimeseries_t * observationnodes
Timeseries to write the observations into.
Definition: definitions.h:226
int timeseries_ticks
Length of timeseries.
Definition: definitions.h:168
nodeval_t ** old_state
2D array of nodes with their current energy level.Size number_nodes_x * number_nodes_y.
Definition: definitions.h:231
int x_index
x index of the node.
Definition: definitions.h:130
nodeval_t act
Energy-level of node.
Definition: definitions.h:179
int(* kernelfunc_t)(nodeval_t *, int, int, nodeval_t **, int, int)
Definition of the kernel-function interface.
Definition: definitions.h:190
int number_nodes_x
The number of total nodes in the first dimension of nodes.
Definition: definitions.h:211
nodeval_t **** kernels
2D array containing the kernels of each node at each index.Each index node points to an array contain...
Definition: definitions.h:250
double tick_ms
Milliseconds in between each simulation tick.
Definition: definitions.h:206
int y_index
y index of the node.
Definition: definitions.h:159
Struct to pass all execution information to a new thread for executing a tick (or parts thereof)...
Definition: definitions.h:196
nodeval_t ** slopes
2D array of nodes with their slope from the last tick iteration level.
Definition: definitions.h:243
int number_global_inputs
Number of inputs on the entire node grid.
Definition: definitions.h:275
Struct to store the status of one node.
Definition: definitions.h:175
int y_index
y index of the node.
Definition: definitions.h:134
int x_index
x index of the node.
Definition: definitions.h:155
threadbarrier_t * barrier
Barrier to wait at.
Definition: definitions.h:300