private void ApplyObservers(SimulationModel model, ModelResponse diff) { for (int i = 0; i < diff.ObserverResultsLength; i++) { ObserverResult observerData = diff.GetObserverResults(i); NeuronId neuronId = observerData.Observer.NeuronId; var definition = new ObserverDefinition(neuronId.Neuron, neuronId.Region, observerData.Observer.Type); model.Observers[definition] = new ObserverData( CopyObserverArrayData(observerData.MetadataLength, (n => observerData.GetMetadata(n))), observerData.GetPlainDataBytes()?.ToArray(), CopyObserverArrayData(observerData.FloatDataLength, (n => observerData.GetFloatData(n)))); } }
private void ApplyRemovedNeurons(SimulationModel model, ModelResponse diff) { for (int i = 0; i < diff.RemovedNeuronsLength; i++) { NeuronId neuronId = diff.GetRemovedNeurons(i); RegionModel region; if (!model.Regions.TryGetModel(neuronId.Region, out region)) { LogNeuronNotProcessed(neuronId, "remove", "Region not found"); continue; } if (!region.Neurons.ContainsKey(neuronId.Neuron)) { LogNeuronNotProcessed(neuronId, "remove", "Neuron not found"); continue; } region.Neurons.Remove(neuronId.Neuron); } }
private void LogNeuronNotProcessed(NeuronId neuronId, string action, string reason) { Log.Warn( "Cannot " + action + " neuron with id {neuronIndex} in region {regionIndex}: {reason}", neuronId.Neuron, neuronId.Region, reason); }