-
Notifications
You must be signed in to change notification settings - Fork 373
/
Copy pathnest.h
196 lines (161 loc) · 5.91 KB
/
nest.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* nest.h
*
* This file is part of NEST.
*
* Copyright (C) 2004 The NEST Initiative
*
* NEST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* NEST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NEST_H
#define NEST_H
// C++ includes:
#include <ostream>
// Includes from libnestutil:
#include "enum_bitfield.h"
#include "logging.h"
// Includes from nestkernel:
#include "nest_datums.h"
#include "nest_time.h"
#include "nest_types.h"
// Includes from sli:
#include "arraydatum.h"
#include "dictdatum.h"
namespace nest
{
void init_nest( int* argc, char** argv[] );
void fail_exit( int exitcode );
void install_module( const std::string& module_name );
void reset_kernel();
void register_logger_client( const deliver_logging_event_ptr client_callback );
/**
* Register connection model (i.e. an instance of a class inheriting from `Connection`).
*/
template < template < typename > class ConnectorModelT >
void register_connection_model( const std::string& name );
/**
* Register node model (i.e. an instance of a class inheriting from `Node`).
*/
template < typename NodeModelT >
void register_node_model( const std::string& name, std::string deprecation_info = std::string() );
void print_nodes_to_stream( std::ostream& out = std::cout );
RngPtr get_rank_synced_rng();
RngPtr get_vp_synced_rng( size_t tid );
RngPtr get_vp_specific_rng( size_t tid );
void set_kernel_status( const DictionaryDatum& dict );
DictionaryDatum get_kernel_status();
void set_node_status( const size_t node_id, const DictionaryDatum& dict );
DictionaryDatum get_node_status( const size_t node_id );
void set_connection_status( const ConnectionDatum& conn, const DictionaryDatum& dict );
DictionaryDatum get_connection_status( const ConnectionDatum& conn );
NodeCollectionPTR create( const Name& model_name, const size_t n );
NodeCollectionPTR get_nodes( const DictionaryDatum& dict, const bool local_only );
/**
* Create bipartite connections.
*/
void connect( NodeCollectionPTR sources,
NodeCollectionPTR targets,
const DictionaryDatum& connectivity,
const std::vector< DictionaryDatum >& synapse_params );
/**
* Create tripartite connections
*
* @note `synapse_specs` is dictionary `{"primary": <syn_spec>, "third_in": <syn_spec>, "third_out": <syn_spec>}`; all
* entries are optional.
*/
void connect_tripartite( NodeCollectionPTR sources,
NodeCollectionPTR targets,
NodeCollectionPTR third,
const DictionaryDatum& connectivity,
const DictionaryDatum& third_connectivity,
const std::map< Name, std::vector< DictionaryDatum > >& synapse_specs );
/**
* @brief Connect arrays of node IDs one-to-one
*
* Connects an array of sources to an array of targets, with weights and
* delays from specified arrays, using the one-to-one
* rule. Additional synapse parameters can be specified with p_keys and p_values.
* Sources, targets, weights, delays, and receptor types are given
* as pointers to the first element. All arrays must have the same length,
* n. Weights, delays, and receptor types can be unspecified by passing a
* nullptr.
*
* The p_keys vector contains keys of additional synapse parameters, with
* associated values in the flat array p_values. If there are n sources and targets,
* and M additional synapse parameters, p_keys has a size of M, and the p_values array
* has length of M*n.
*/
void connect_arrays( long* sources,
long* targets,
double* weights,
double* delays,
std::vector< std::string >& p_keys,
double* p_values,
size_t n,
std::string syn_model );
ArrayDatum get_connections( const DictionaryDatum& dict );
void disconnect( const ArrayDatum& conns );
void simulate( const double& t );
/**
* @fn run(const double& time)
* @brief Run a partial simulation for `time` ms
*
* Runs a partial simulation for `time` ms
* after a call to prepare() and before a cleanup().
* Can be called multiple times between a prepare()/cleanup()
* pair to divide a simulation into multiple pieces with access
* to the API in between.
*
* Thus, simulate(t) = prepare(); run(t/2); run(t/2); cleanup()
*
* @see prepare()
* @see cleanup()
*/
void run( const double& t );
/**
* @fn prepare()
* @brief do calibrations for network, open files, ... before run()
*
* Prepares a simulation before calling any number of run(t_n)
* calls to actually run the simulation
*
* @see run()
* @see cleanup()
*/
void prepare();
/**
* @fn cleanup()
* @brief do cleanup after a simulation, such as closing files
*
* Do cleanup to end a simulation using run() commands.
* After calling cleanup(), further run() calls must only happen
* after another call to prepare()
*
* @see run()
* @see prepare()
*/
void cleanup();
void copy_model( const Name& oldmodname, const Name& newmodname, const DictionaryDatum& dict );
void set_model_defaults( const std::string model_name, const DictionaryDatum& );
DictionaryDatum get_model_defaults( const std::string model_name );
ParameterDatum create_parameter( const DictionaryDatum& param_dict );
double get_value( const ParameterDatum& param );
bool is_spatial( const ParameterDatum& param );
std::vector< double > apply( const ParameterDatum& param, const NodeCollectionDatum& nc );
std::vector< double > apply( const ParameterDatum& param, const DictionaryDatum& positions );
Datum* node_collection_array_index( const Datum* datum, const long* array, unsigned long n );
Datum* node_collection_array_index( const Datum* datum, const bool* array, unsigned long n );
}
#endif /* NEST_H */