public void RepositionsSynapse()
        {
            RegionModel  addedRegion;
            SynapseModel addedSynapse;

            SetupRegionWithSynapse(out addedRegion, out addedSynapse);

            NeuronModel neuron1 = m_model.Regions.First().Neurons.First();
            NeuronModel neuron2 = m_model.Regions.First().Neurons.Last();

            SynapseModel synapse = m_model.Regions.First().Synapses.First();

            neuron1.Position *= 2;
            ResponseMessage diff = ModelResponseBuilder.Build(repositionedNeurons: new List <NeuronModel> {
                neuron1
            });

            ApplyModelDiff(diff);

            Assert.Equal(neuron1.Position, synapse.Position);

            neuron2.Position *= 3;
            diff              = ModelResponseBuilder.Build(repositionedNeurons: new List <NeuronModel> {
                neuron2
            });
            ApplyModelDiff(diff);

            Assert.Equal(neuron2.Position, neuron1.Position + synapse.TargetPosition);
        }
Exemplo n.º 2
0
 private void ApplyAddedSynapses(SimulationModel model, ModelResponse diff)
 {
     for (int i = 0; i < diff.AddedSynapsesLength; i++)
     {
         Synapse addedSynapse = diff.GetAddedSynapses(i);
         ProcessSynapse(model, addedSynapse, "add", (fromRegion, fromNeuron, toRegion, toNeuron) =>
         {
             var synapseModel = new SynapseModel(fromRegion, fromNeuron, toRegion, toNeuron);
             fromNeuron.Outputs[synapseModel.ToNeuron.Index] = synapseModel;
             fromRegion.AddSynapse(synapseModel);
             toNeuron.Inputs[synapseModel.FromNeuron.Index] = synapseModel;
         });
     }
 }
        private void SetupRegionWithSynapse(out RegionModel addedRegion, out SynapseModel addedSynapse)
        {
            addedRegion = SetupRegion(m_applier, m_model, 1);

            var addedNeuron1 = new NeuronModel(1, "neuronType", addedRegion, Vector3.One);
            var addedNeuron2 = new NeuronModel(2, "neuronType", addedRegion, Vector3.UnitY);

            addedSynapse = new SynapseModel(addedRegion, addedNeuron1, addedRegion, addedNeuron2);

            ResponseMessage diff = ModelResponseBuilder.Build(
                addedNeurons: new List <NeuronModel> {
                addedNeuron1, addedNeuron2
            },
                addedSynapses: new List <SynapseModel> {
                addedSynapse
            });

            ApplyModelDiff(diff);
        }