Skip to content
Snippets Groups Projects
Commit f22f81ce authored by POLITO Guillermo Andres's avatar POLITO Guillermo Andres
Browse files

Replaced usages of FullExceptSelfConnection by FullConnection

parent 8406b312
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import fr.univ_lille.cristal.emeraude.n2s3.features.builder.{NeuronGroupRef, Neu ...@@ -5,7 +5,7 @@ import fr.univ_lille.cristal.emeraude.n2s3.features.builder.{NeuronGroupRef, Neu
import fr.univ_lille.cristal.emeraude.n2s3.features.builder.connection.{Connection, ConnectionPolicy} import fr.univ_lille.cristal.emeraude.n2s3.features.builder.connection.{Connection, ConnectionPolicy}
/** /**
* Created by falezp on 23/05/16. * Connects all entities inside a [[NeuronGroupRef]] to all entities inside another [[NeuronGroupRef]]
*/ */
class FullConnection(neuronConnectionConstructor : Option[() => NeuronConnection]) extends ConnectionPolicy { class FullConnection(neuronConnectionConstructor : Option[() => NeuronConnection]) extends ConnectionPolicy {
......
package fr.univ_lille.cristal.emeraude.n2s3.features.builder.connection.types
import fr.univ_lille.cristal.emeraude.n2s3.features.builder.{NeuronGroupRef, NeuronIterable, NeuronRef}
import fr.univ_lille.cristal.emeraude.n2s3.features.builder.connection.{Connection, ConnectionPolicy}
/**
* Created by falezp on 23/05/16.
*/
class FullExceptSelfConnection extends ConnectionPolicy {
def generate(from : NeuronIterable, to : NeuronIterable) = {
assert(from.size == to.size)
for {
(in, in_index) <- from.toSeq.zipWithIndex
(out, out_index) <- to.toSeq.zipWithIndex
if in_index != out_index
} yield Connection(in, out)
}
override def generate(from: NeuronGroupRef, to: NeuronGroupRef): Traversable[Connection] = {
assert(from.neuronPaths.size == to.neuronPaths.size)
for {
in <- from.neurons
out <- to.neurons
if this.connects(in, out)
} yield Connection(in.actorPath.get, out.actorPath.get)
}
/** ******************************************************************************************************************
* Testing
* *****************************************************************************************************************/
override def connects(aNeuron: NeuronRef, anotherNeuron: NeuronRef): Boolean = aNeuron.index != anotherNeuron.index
}
\ No newline at end of file
...@@ -11,12 +11,12 @@ class WinnerTakeAllConnection(inhibitoryConnection : () => NeuronConnection) ext ...@@ -11,12 +11,12 @@ class WinnerTakeAllConnection(inhibitoryConnection : () => NeuronConnection) ext
def generate(from : NeuronIterable, to : NeuronIterable) = { def generate(from : NeuronIterable, to : NeuronIterable) = {
new OneToOneConnection().generate(from, to)++ new OneToOneConnection().generate(from, to)++
new FullExceptSelfConnection().generate(to, from).map(co => Connection(co.from, co.to, Some(inhibitoryConnection()))) new FullConnection().generate(to, from).map(co => Connection(co.from, co.to, Some(inhibitoryConnection())))
} }
override def generate(from: NeuronGroupRef, to: NeuronGroupRef): Traversable[Connection] = { override def generate(from: NeuronGroupRef, to: NeuronGroupRef): Traversable[Connection] = {
new OneToOneConnection().generate(from, to)++ new OneToOneConnection().generate(from, to)++
new FullExceptSelfConnection().generate(to, from).map(co => Connection(co.from, co.to, Some(inhibitoryConnection()))) new FullConnection().generate(to, from).map(co => Connection(co.from, co.to, Some(inhibitoryConnection())))
} }
/** ****************************************************************************************************************** /** ******************************************************************************************************************
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment