20 #ifndef MPILIB_MPINETWORK_CODE_HPP_
21 #define MPILIB_MPINETWORK_CODE_HPP_
40 template<
class WeightValue,
class NodeDistribution>
44 template<
class WeightValue,
class NodeDistribution>
48 template<
class WeightValue,
class NodeDistribution>
60 NodeId tempNodeId = getMaxNodeId();
61 if (_nodeDistribution.isLocalNode(tempNodeId)) {
63 NodeDistribution>(alg, nodeType, tempNodeId, _nodeDistribution,
65 _localNodes.insert(std::make_pair(tempNodeId, node));
70 nodeIdsType_[tempNodeId] = nodeType;
79 template<
class WeightValue,
class NodeDistribution>
81 NodeId first,
NodeId second,
const WeightValue& weight) {
84 if (_nodeDistribution.isLocalNode(first)) {
85 if (_localNodes.count(first) > 0) {
86 _localNodes.find(first)->second.addSuccessor(second);
88 <<
"make first input of second called first: " << first
89 <<
"; second: " << second;
91 std::stringstream tempStream;
92 tempStream <<
"the node " << first <<
"does not exist on this node";
98 if (_nodeDistribution.isLocalNode(first)) {
99 if (isDalesLawSet()) {
101 auto tempNode = _localNodes.find(first)->second;
114 if (_nodeDistribution.isLocalNode(second)) {
115 if (_localNodes.count(second) > 0) {
116 _localNodes.find(second)->second.addPrecursor(first, weight,
117 nodeIdsType_[second]);
119 std::stringstream tempStream;
120 tempStream <<
"the node " << second
121 <<
"does not exist on this node";
128 template<
class WeightValue,
class NodeDistribution>
136 _parameterSimulationRun = simParam;
138 _n_sim_steps =
static_cast<unsigned long>(simParam.
getTEnd()/simParam.
getTStep());
142 this->initializeLogStream(simParam.
getLogName());
146 for (
auto& it : _localNodes) {
147 it.second.configureSimulationRun(simParam);
153 _stateNetwork.toggleConfigured();
157 template<
class WeightValue,
class NodeDistribution>
160 if (_stateNetwork.isConfigured()) {
161 _stateNetwork.toggleConfigured();
166 long count = (_parameterSimulationRun.getTReport() < _parameterSimulationRun.getTStep()) ? \
167 static_cast<long>(_parameterSimulationRun.getTEnd()/_parameterSimulationRun.getTStep()) : \
168 static_cast<long>(_parameterSimulationRun.getTEnd()/_parameterSimulationRun.getTReport());
175 <<
"****** one evolve step finished ******";
179 updateSimulationTime();
182 for (
auto& it : _localNodes)
183 it.second.prepareEvolve();
185 Time t_current = getCurrentSimulationTime()*_parameterSimulationRun.getTStep();
187 for (
auto& it : _localNodes)
188 it.second.evolve(t_current);
191 }
while (getCurrentSimulationTime() < getCurrentReportTime()
192 && getCurrentSimulationTime() < getCurrentStateTime());
195 if (getCurrentSimulationTime() >= getCurrentReportTime()) {
204 if (getCurrentSimulationTime() >= getCurrentStateTime()) {
211 }
while (getCurrentSimulationTime() <= getEndTime());
224 << getCurrentSimulationTime() <<
"\n";
229 template<
class WeightValue,
class NodeDistribution>
235 template<
class WeightValue,
class NodeDistribution>
237 if (_nodeDistribution.isMaster()) {
242 template<
class WeightValue,
class NodeDistribution>
246 for (
auto& it : _localNodes) {
247 it.second.reportAll(type);
251 template<
class WeightValue,
class NodeDistribution>
253 const std::string & filename) {
256 if (!filename.empty()) {
257 std::shared_ptr<std::ostream> p_stream(
258 new std::ofstream(filename.c_str()));
265 template<
class WeightValue,
class NodeDistribution>
268 for (
auto& it : _localNodes) {
269 it.second.clearSimulation();
274 template<
class WeightValue,
class NodeDistribution>
279 template<
class WeightValue,
class NodeDistribution>
284 template<
class WeightValue,
class NodeDistribution>
286 _i_report += _n_report_steps;
289 template<
class WeightValue,
class NodeDistribution>
294 template<
class WeightValue,
class NodeDistribution>
296 _i_state += _n_state_steps;
299 template<
class WeightValue,
class NodeDistribution>
304 template<
class WeightValue,
class NodeDistribution>
309 template<
class WeightValue,
class NodeDistribution>
311 return _i_simulation;
314 template<
class WeightValue,
class NodeDistribution>
319 template<
class WeightValue,
class NodeDistribution>
320 std::map<NodeId, MPINode<WeightValue, NodeDistribution>>
MPINetwork<WeightValue,
321 NodeDistribution>::_localNodes;
323 template<
class WeightValue,
class NodeDistribution>
328 #endif //MPILIB_MPINETWORK_CODE_HPP_
NodeType
This determines an MPINode's type, which will be checked when Dale's law is set.
void makeFirstInputOfSecond(NodeId first, NodeId second, const WeightValue &weight)
double toEfficacy(const DelayedConnection &connection)
Indicates that Dale's law should not be checked for this node.
Class for nodes in an MPINetwork.
bool isDalesLawSet() const
bool IsExcitatory(NodeType t)
Test for excitatoryness.
Index getCurrentSimulationTime() const
int addNode(const AlgorithmInterface< WeightValue > &alg, NodeType nodeType)
void setDalesLaw(bool b_law)
void configureSimulation(const SimulationRunParameter &simParam)
bool IsInhibitory(NodeType t)
Test for inhibitoryness.
The interface for all algorithm classes.
Check Dale's law; inhibitory; additive Gaussian noise.
static void setStream(std::shared_ptr< std::ostream > pStream)
#define miind_parallel_fail(ERROR_MESSAGE)
A representation of the network class. Probably the most central class that a client will use...
std::string getLogName() const
Check Dale's law; excitatory; do not make any attempt to reinterpret input from this node...
Parameter determining how a simulation is run. Specifiying begin and end time, log file names...
void initializeLogStream(const std::string &filename)
Indicates that Dale's law should be checked and that the contribution oof this excitatory node is to ...
void collectReport(report::ReportType type)
void updateSimulationTime()
Index getCurrentReportTime() const
Index getCurrentStateTime() const
void evolve()
Envolve the network.
void incrementMaxNodeId()