Brainsimulation
Simulation of the human brain.
Functions
brainsimulation.h File Reference

Main entry points for the brainsimultion. More...

#include "definitions.h"
#include "utils.h"
Include dependency graph for brainsimulation.h:

Go to the source code of this file.

Functions

unsigned int simulate (double tick_ms, int num_ticks, int number_nodes_x, int number_nodes_y, nodeval_t **nodes, int num_obervationnodes, nodetimeseries_t *oberservationnodes, int number_inputs, nodeinputseries_t *inputs)
 Simulates the brain. More...
 
unsigned int execute_simulation_multithreaded (executioncontext_t *executioncontext, int num_ticks, double tick_ms, int number_nodes_x, int number_nodes_y, int num_obervationnodes, nodetimeseries_t *observationnodes, nodeval_t **old_state, nodeval_t **new_state, nodeval_t **slopes, nodeval_t ****kernels, kernelfunc_t d_ptr, kernelfunc_t id_ptr, int number_global_inputs, nodeinputseries_t *global_inputs)
 Executes the inner simulation in a multithreaded fashion. More...
 
unsigned int execute_simulation_singlethreaded (executioncontext_t *executioncontext, int num_ticks, double tick_ms, int number_nodes_x, int number_nodes_y, int num_obervationnodes, nodetimeseries_t *observationnodes, nodeval_t **old_state, nodeval_t **new_state, nodeval_t **slopes, nodeval_t ****kernels, kernelfunc_t d_ptr, kernelfunc_t id_ptr, int number_global_inputs, nodeinputseries_t *global_inputs)
 Executes the inner simulation in a singlethreaded fashion. More...
 
unsigned int execute_partial_simulation (partialsimulationcontext_t *context)
 Executes a partial simulation, as defined by a partial simulation context. More...
 
unsigned int execute_partial_tick (partialsimulationcontext_t *context)
 Executes a partial tick of the simulation. More...
 
void extract_observationnodes (int ticknumber, int num_obervationnodes, nodetimeseries_t *observationnodes, nodeval_t **state)
 Extracts and stores/saves the information into the specified observation nodes. More...
 
void process_global_inputs (int tick_number, double tick_ms, nodeval_t **state, int number_global_inputs, nodeinputseries_t *global_inputs)
 Adds the influence of the defined input nodes to the current state. More...
 
void process_partial_inputs (int tick_number, double tick_ms, nodeval_t **state, int number_partial_inputs, nodeinputseries_t **partial_inputs)
 Adds the influence of the defined input nodes to the current state. More...
 
void process_input (int tick_number, double tick_ms, nodeval_t **state, nodeinputseries_t *input)
 Adds the influence of the defined input node to the current state. More...
 

Detailed Description

Main entry points for the brainsimultion.

Function Documentation

unsigned int execute_partial_simulation ( partialsimulationcontext_t context)

Executes a partial simulation, as defined by a partial simulation context.

Usually executed in a separate thread. Executes the entire simulation on a bounded subset of the node-field.

Parameters
contextThe partial context to handle in this call.
Returns
Return-codes, usually 0.
unsigned int execute_partial_tick ( partialsimulationcontext_t context)

Executes a partial tick of the simulation.

Usually executed in a separate thread.

Parameters
contextThe partial context to handle in this call.
Returns
Return-codes, usually 0.
unsigned int execute_simulation_multithreaded ( executioncontext_t executioncontext,
int  num_ticks,
double  tick_ms,
int  number_nodes_x,
int  number_nodes_y,
int  num_obervationnodes,
nodetimeseries_t observationnodes,
nodeval_t **  old_state,
nodeval_t **  new_state,
nodeval_t **  slopes,
nodeval_t ****  kernels,
kernelfunc_t  d_ptr,
kernelfunc_t  id_ptr,
int  number_global_inputs,
nodeinputseries_t global_inputs 
)

Executes the inner simulation in a multithreaded fashion.

Called after setup of nodes, inputs, etc.

Parameters
executioncontextThe technical gobal context of the simulation. Contains information on threading settings, etc.
num_ticksThe number of ticks in the simulation.
tick_msMilliseconds in between each simulation tick.
number_nodes_xThe number of nodes in the first dimension of nodes.
number_nodes_yThe number of nodes in the second dimension of nodes.
num_obervationnodesThe number of nodes to observe.
observationnodesPointers to the timeseries for the nodes to observe. Observations are written here.
old_state2D array of nodes with their current energy level. Size number_nodes_x * number_nodes_y.
new_state2D array of nodes with the new energy level. Values will be overwritten. Size number_nodes_x * number_nodes_y.
slopes2D array of nodes with their slope from the last tick iteration level. Size number_nodes_x * number_nodes_y.
kernels4D array containing the kernels of each node at each index. Each index node points to an array containing (currently) two kernels, each (currently) containing 4 neighbouring noides. Dimensions: number_nodes_x * number_nodes_y * 2 * 4.
d_ptrFunction pointer pointing to the kernel function for the direct neighborhood.
id_ptrFunction pointer pointing to the kernel function for the indirect neighborhood.
number_global_inputsNumber of global inputs.
global_inputsInputs on the entire node field. Length: number_global_inputs
Returns
Return-codes.
unsigned int execute_simulation_singlethreaded ( executioncontext_t executioncontext,
int  num_ticks,
double  tick_ms,
int  number_nodes_x,
int  number_nodes_y,
int  num_obervationnodes,
nodetimeseries_t observationnodes,
nodeval_t **  old_state,
nodeval_t **  new_state,
nodeval_t **  slopes,
nodeval_t ****  kernels,
kernelfunc_t  d_ptr,
kernelfunc_t  id_ptr,
int  number_global_inputs,
nodeinputseries_t global_inputs 
)

Executes the inner simulation in a singlethreaded fashion.

Called after setup of nodes, inputs, etc.

Parameters
executioncontextThe technical gobal context of the simulation. Contains information on threading settings, etc.
num_ticksThe number of ticks in the simulation.
tick_msMilliseconds in between each simulation tick.
number_nodes_xThe number of nodes in the first dimension of nodes.
number_nodes_yThe number of nodes in the second dimension of nodes.
num_obervationnodesThe number of nodes to observe.
observationnodesPointers to the timeseries for the nodes to observe. Observations are written here.
old_state2D array of nodes with their current energy level. Size number_nodes_x * number_nodes_y.
new_state2D array of nodes with the new energy level. Values will be overwritten. Size number_nodes_x * number_nodes_y.
slopes2D array of nodes with their slope from the last tick iteration level. Size number_nodes_x * number_nodes_y.
kernels4D array containing the kernels of each node at each index. Each index node points to an array containing (currently) two kernels, each (currently) containing 4 neighbouring noides. Dimensions: number_nodes_x * number_nodes_y * 2 * 4.
d_ptrFunction pointer pointing to the kernel function for the direct neighborhood.
id_ptrFunction pointer pointing to the kernel function for the indirect neighborhood.
number_global_inputsNumber of global inputs.
global_inputsInputs on the entire node field. Length: number_global_inputs
Returns
Return-codes.
void extract_observationnodes ( int  ticknumber,
int  num_obervationnodes,
nodetimeseries_t observationnodes,
nodeval_t **  state 
)

Extracts and stores/saves the information into the specified observation nodes.

Parameters
ticknumberThe current tick number, i.e., the tick number to store.
num_obervationnodesThe number of observation nodes.
observationnodesAn array containing all observation nodes. All values in the struct elements must be already initialized. Length: num_observationnodes.
stateThe current state to store.
void process_global_inputs ( int  tick_number,
double  tick_ms,
nodeval_t **  state,
int  number_global_inputs,
nodeinputseries_t global_inputs 
)

Adds the influence of the defined input nodes to the current state.

Parameters
tick_numberThe current tick number.
tick_msMilliseconds in between each simulation tick.
state2D array of nodes with their current energy level. Size number_nodes_x * number_nodes_y.
number_global_inputsThe number of input nodes to be changed.
global_inputsContains information about the coordinates and the values of the input nodes to be changed. Length: number_inputs
void process_input ( int  tick_number,
double  tick_ms,
nodeval_t **  state,
nodeinputseries_t input 
)

Adds the influence of the defined input node to the current state.

Parameters
tick_numberThe current tick number.
tick_msMilliseconds in between each simulation tick.
state2D array of nodes with their current energy level.
inputThe single input to be updated.
void process_partial_inputs ( int  tick_number,
double  tick_ms,
nodeval_t **  state,
int  number_partial_inputs,
nodeinputseries_t **  partial_inputs 
)

Adds the influence of the defined input nodes to the current state.

Parameters
tick_numberThe current tick number.
tick_msMilliseconds in between each simulation tick.
state2D array of nodes with their current energy level. Size number_nodes_x * number_nodes_y.
number_partial_inputsThe number of input nodes to be changed.
partial_inputsContains pointers to the input nodes to be changed. Length: number_partial_inputs
unsigned int simulate ( double  tick_ms,
int  num_ticks,
int  number_nodes_x,
int  number_nodes_y,
nodeval_t **  nodes,
int  num_obervationnodes,
nodetimeseries_t oberservationnodes,
int  number_inputs,
nodeinputseries_t inputs 
)

Simulates the brain.

Parameters
tick_msMilliseconds in between each simulation tick.
num_ticksThe number of ticks to simulate. This will also be the length of all timeseries contained in the returned oberservationnodes.
number_nodes_xThe number of nodes in the first dimension of nodes.
number_nodes_yThe number of nodes in the second dimension of nodes.
nodes2D array of nodes with their starting energy level.
num_obervationnodesThe number of nodes to observe during simulation.
oberservationnodesThe nodes to observe during simulation. x_index and y_index members must be set. All other members will be overwritten with the simulation results. Must have num_obervationnodes as length.
number_inputsThe number of input nodes to be changed during execution.
inputsContains information about the coordinates and the values of the input nodes to be changed during execution. All values must be set. Length: number_inputs.
Returns
Return-codes.