Ejemplo n.º 1
0
func (this *SpikingNeuron) ScopedSimulation(I float64, i int, t, T1, tau float64, uu []float64, neuronManager *group.NeuronManager) {
	// Lock...
	if neuronManager != nil {
		// Increment to number of neurons...
		// fmt.Println("Neuron", this.GetId(), "incremented the wait counter...");
		time.Sleep(time.Millisecond)
		neuronManager.GetInnerWaitGroup().Add(1)
		defer neuronManager.GetInnerWaitGroup().Done()
		// fmt.Println("Neuron", this.GetId(), "grabbed the lock...");
		time.Sleep(time.Millisecond)
		neuronManager.OuterLock()
	}

	// Get all the outputs from each connection.
	if this.GetInputPredicate()(i, t, T1, this) {
		I = this.GetInputSuccess()(i, t, T1, this)
	} else {
		I = this.GetInputFail()(i, t, T1, this)
	}

	this.SetV(this.GetV() + tau*(vars.GetConstantV1()*(this.GetV()*this.GetV())+vars.GetConstantV2()*this.GetV()+vars.GetConstantV3()-this.GetU()+I))
	this.SetU(this.GetU() + tau*this.GetA()*(this.GetB()*this.GetV()-this.GetU()))

	if this.GetPredicate()(t, i, this) {
		this.GetSuccess()(t, i, this)
		// Default results.
		this.SetV(this.GetC())
		this.SetU(this.GetU() + this.GetD())
	} else {
		// Don't Fire...
		this.GetFail()(t, i, this)
	}

	uu[i] = this.GetU()
}