public class SynapseGroup extends Group
Modifier and Type | Field and Description |
---|---|
static ConnectNeurons |
DEFAULT_CONNECTION_MANAGER
All to All.
|
static double |
DEFAULT_EXCITATORY_RATIO
The default ratio (all excitatory) for all synapse groups.
|
Constructor and Description |
---|
SynapseGroup(NeuronGroup source,
NeuronGroup target)
Creates a blank synapse group between a source and target neuron group
using the default connection manager.
|
SynapseGroup(NeuronGroup source,
NeuronGroup target,
ConnectNeurons connectionManager)
Creates a blank synapse group between a source and target neuron group.
|
Modifier and Type | Method and Description |
---|---|
void |
addExcitatorySynapseUnsafe(Synapse synapse)
|
void |
addInhibitorySynapseUnsafe(Synapse synapse)
|
void |
addNewExcitatorySynapse(Synapse synapse) |
void |
addNewInhibitorySynapse(Synapse synapse) |
void |
addNewSynapse(Synapse synapse)
Adds a new synapse (one which is "blank") to the synapse group.
|
void |
addSynapseUnsafe(Synapse synapse)
Add a synapse to this synapse group adding it to the appropriate synapse
set (excitatory or inhibitory if it's weight is above or below zero
respecively).
|
double |
calculateExcitatoryRatio()
If a randomize operation changes the ratio of excitatory to inhibitory
synapses, this method can be called to change the excitatoryRatio to
reflect this value.
|
<T> T |
checkSynapses(ConnectionUtilities.SynapseParameterGetter<T> check,
SimbrainConstants.Polarity polarity)
A generic method which takes in a functional interface and a polarity.
|
void |
clear()
Removes all synapses from this synapse group and the network.
|
static SynapseGroup |
createSynapseGroup(NeuronGroup source,
NeuronGroup target)
Completely creates a synapse group between the two neuron groups with all
default parameters.
|
static SynapseGroup |
createSynapseGroup(NeuronGroup source,
NeuronGroup target,
ConnectNeurons connectionManager)
Completely creates a synapse group with the desired parameters.
|
static SynapseGroup |
createSynapseGroup(NeuronGroup source,
NeuronGroup target,
ConnectNeurons connectionManager,
double excitatoryRatio)
Completely creates a synapse group with the desired parameters.
|
static SynapseGroup |
createSynapseGroup(NeuronGroup source,
NeuronGroup target,
ConnectNeurons connectionManager,
double excitatoryRatio,
PolarizedRandomizer exciteRand,
PolarizedRandomizer inhibRand)
Completely creates a synapse group with the desired parameters.
|
static SynapseGroup |
createSynapseGroup(NeuronGroup source,
NeuronGroup target,
double excitatoryRatio)
Completely creates a synapse group with the desired parameters.
|
void |
delete()
Perform necessary deletion cleanup.
|
java.util.List<Synapse> |
getAllSynapses() |
ConnectNeurons |
getConnectionManager() |
java.lang.Integer |
getDelay(SimbrainConstants.Polarity polarity) |
Synapse |
getExcitatoryPrototype()
Reveals the excitatory prototype synapse, allowing more detailed synapse
values to be queried at the group level.
|
PolarizedRandomizer |
getExcitatoryRandomizer() |
double |
getExcitatoryRatioParameter()
Returns the excitatory ratio parameter.
|
double |
getExcitatoryRatioPrecise() |
double[] |
getExcitatoryStrengths() |
java.util.Set<Synapse> |
getExcitatorySynapses() |
double |
getIncrement(SimbrainConstants.Polarity polarity) |
Synapse |
getInhibitoryPrototype()
Reveals the inhibitory prototype synapse, allowing more detailed synapse
values to be queried at the group level.
|
PolarizedRandomizer |
getInhibitoryRandomizer() |
double[] |
getInhibitoryStrengths() |
java.util.Set<Synapse> |
getInhibitorySynapses() |
java.lang.String |
getLearningRuleDescription(SimbrainConstants.Polarity polarity) |
double |
getLowerBound(SimbrainConstants.Polarity polarity) |
double[][] |
getNumericIndices()
A more compressed version of a weight matrix for cases where a weight
matrix is needed, but may cause memory issues if fully instantiated.
|
java.lang.Number[][] |
getNumericIndices(ConnectionUtilities.SynapseParameterGetter<java.lang.Number> getter)
A more compressed version of a weight matrix for cases where a weight
matrix is needed, but may cause memory issues if fully instantiated.
|
long[] |
getRowCompressedMatrixRepresentation() |
NeuronGroup |
getSourceNeuronGroup() |
java.util.List<Neuron> |
getSourceNeurons()
Return a list of source neurons associated with the synapses in this
group.
|
java.lang.String |
getSpikeResponderDescription(SimbrainConstants.Polarity polarity) |
NeuronGroup |
getTargetNeuronGroup() |
java.util.List<Neuron> |
getTargetNeurons()
Return a list of target neurons associated with the synapses in this
group.
|
java.lang.String |
getUpdateMethodDesecription()
Returns a description of this group's update method, which is displayed
in the update manager panel.
|
double |
getUpperBound(SimbrainConstants.Polarity polarity) |
double[][] |
getWeightMatrix()
For large, sparse synapse groups this will cause a heap overflow.
|
double[] |
getWeightVector()
Return weight strengths as a double vector.
|
boolean |
hasExcitatory() |
boolean |
hasInhibitory() |
void |
initializeSynapseVisibility()
Determine whether this synpasegroup should initially have its synapses
displayed.
|
boolean |
isDisplaySynapses() |
boolean |
isEmpty()
Whether this group is empty or not.
|
java.lang.Boolean |
isEnabled(SimbrainConstants.Polarity polarity) |
java.lang.Boolean |
isFrozen(SimbrainConstants.Polarity polarity) |
boolean |
isRecurrent()
Check whether this synapse group connects a neuron group to itself.
|
boolean |
isUseFullRepOnSave() |
boolean |
isUseGroupLevelSettings() |
void |
makeConnections()
The "build" method which actually constructs the group in terms of
populating it with synapses.
|
void |
postSaveReInit()
A post initialization which must be done if the user wants to save the
network, but continue using the network after saving (since the saving
process sets the synapse sets to null.
|
void |
postUnmarshallingInit()
Perform operations required after opening a synapse group.
|
void |
preAllocateSynapses(int expectedNumSynapses)
Pre-allocates, that is sets the initial capacity of the arraylist
containing this synapse group's synapses.
|
void |
preSaveInit()
Perform operations required before saving a synapse group.
|
void |
preSaveInitFull()
The pre-save init to be used to save all relevant synapse parameters
in the byte array.
|
void |
prune()
Removes all synapses with weight 0 from the group.
|
void |
randomizeConnectionWeights()
Randomizes all the synapses according to their corresponding randomizers.
|
void |
randomizeExcitatoryConnections()
Randomizes the weights of the excitatory connections in this group based
on the parameters of
exciteRand . |
void |
randomizeInhibitoryConnections()
Randomizes the weights of the inhibitory connections in this group based
on the parameters of
inhibRand . |
Synapse |
removeSynapse(Synapse toDelete)
Remove the provided synapse from the group, but not the network.
|
void |
revalidateSynapseSets()
If an algorithm (like training) extensively changes the polarity of the
synapses in this group, it's impractical to check every time a change is
made.
|
void |
saveToFileAsLinkedList()
See:
saveToFileAsLinkedList(String)
Uses the default name which is: label + date & time |
void |
saveToFileAsLinkedList(java.lang.String filename)
Saves the synapse group to a file in linked list format which can be
read by most graph analysis software, in particular as of 6/27/2015
the author is aware of both OSLOM and Infomap which can interpret the
linked list format.
|
void |
saveToFileAsMatrix(java.lang.String filename)
Saves the weight matrix represented by this synapse group to a file.
|
void |
setAndConformToTemplate(Synapse template,
SimbrainConstants.Polarity polarity) |
void |
setConnectionManager(ConnectNeurons connection)
Sets the connection manager for this synapse group once and only once.
|
void |
setDelay(int delay,
SimbrainConstants.Polarity polarity) |
void |
setDisplaySynapses(boolean displaySynapses) |
void |
setEnabled(boolean enabled,
SimbrainConstants.Polarity polarity) |
void |
setExcitatoryRandomizer(PolarizedRandomizer excitatoryRandomizer) |
void |
setExcitatoryRatio(double excitatoryRatio)
Changes the ratio of synapses in this group that are excitatory subject
to two constraints: 1) If neurons in the source neuron group have
their own polarity ratio, the desired excitatoryRatio may not be
possible.
|
void |
setFrozen(boolean frozen,
SimbrainConstants.Polarity polarity) |
void |
setIncrement(double increment,
SimbrainConstants.Polarity polarity) |
void |
setInhibitoryRandomizer(PolarizedRandomizer inhibitoryRandomizer) |
void |
setLearningRule(SynapseUpdateRule sur,
SimbrainConstants.Polarity polarity) |
void |
setLowerBound(double lowerBound,
SimbrainConstants.Polarity polarity) |
void |
setRandomizers(PolarizedRandomizer excitatoryRandomizer,
PolarizedRandomizer inhibitoryRandomizer) |
void |
setSpikeResponder(SpikeResponder spr,
SimbrainConstants.Polarity polarity) |
void |
setStrength(double strength,
SimbrainConstants.Polarity polarity) |
<T> void |
setSynapses(ConnectionUtilities.SynapseParameterSetter<T> set,
T val,
SimbrainConstants.Polarity polarity)
A generic method that takes in a functional interface, a value and a
polarity.
|
boolean |
setSynapseStrength(Synapse synapse,
double newWeight)
Sets the strength of a single synapse in the group specified as a
parameter.
|
void |
setUpperBound(double upperBound,
SimbrainConstants.Polarity polarity) |
void |
setUseFullRepOnSave(boolean useFullRepOnSave) |
void |
setUseGroupLevelSettings(boolean useGroupLevelSettings) |
int |
size() |
java.lang.String |
toString() |
void |
update()
Update group.
|
getId, getLabel, getParentGroup, getParentNetwork, getStateInfo, hasParentGroup, isMarkedForDeletion, isTopLevelGroup, recursivelySetIds, setId, setLabel, setMarkedForDeletion, setParentGroup, setStateInfo
public static final double DEFAULT_EXCITATORY_RATIO
public static final ConnectNeurons DEFAULT_CONNECTION_MANAGER
public SynapseGroup(NeuronGroup source, NeuronGroup target)
makeConnections()
is
called this group will be empty and will not be added to the source or
target neuron groups' respective outgoing and incoming synapse group
sets.source
- the source neuron group.target
- the target neuron group.public SynapseGroup(NeuronGroup source, NeuronGroup target, ConnectNeurons connectionManager)
makeConnections()
is called this group will be empty and
will not be added to the source or target neuron groups' respective
outgoing and incoming synapse group sets.source
- source neuron grouptarget
- target neuron groupconnectionManager
- a connection object which builds this grouppublic static SynapseGroup createSynapseGroup(NeuronGroup source, NeuronGroup target)
source
- the source neuron group.target
- the target neuron group.public static SynapseGroup createSynapseGroup(NeuronGroup source, NeuronGroup target, double excitatoryRatio)
source
- the source neuron group.target
- the target neuron group.
neurons in the group are connectedexcitatoryRatio
- the ratio of excitatory to inhibitory synapses
[0, 1].public static SynapseGroup createSynapseGroup(NeuronGroup source, NeuronGroup target, ConnectNeurons connectionManager)
source
- the source neuron group.target
- the target neuron group.connectionManager
- the connection manager used to establish whichpublic static SynapseGroup createSynapseGroup(NeuronGroup source, NeuronGroup target, ConnectNeurons connectionManager, double excitatoryRatio)
source
- the source neuron group.target
- the target neuron group.connectionManager
- the connection manager used to establish whichexcitatoryRatio
- the ratio of excitatory to inhibitory synapses
[0, 1].public static SynapseGroup createSynapseGroup(NeuronGroup source, NeuronGroup target, ConnectNeurons connectionManager, double excitatoryRatio, PolarizedRandomizer exciteRand, PolarizedRandomizer inhibRand)
source
- the source neuron group.target
- the target neuron group.connectionManager
- the connection manager used to establish whichexcitatoryRatio
- the ratio of excitatory to inhibitory synapses
[0, 1].exciteRand
- the randomizer to be used to determine the weights
of excitatory synapses.inhibRand
- the randomizer to be used to determine the weights of
inhibitory synapses.public void makeConnections()
public void preAllocateSynapses(int expectedNumSynapses) throws java.lang.IllegalStateException
expectedNumSynapses
- the number of synapses the connection manager
predicts will be created.java.lang.IllegalStateException
- if the synapse group has already been
initialized.public void revalidateSynapseSets()
public void update()
public int size()
public boolean isEmpty()
public java.lang.String getUpdateMethodDesecription()
getUpdateMethodDesecription
in class Group
public void initializeSynapseVisibility()
public void setDisplaySynapses(boolean displaySynapses)
displaySynapses
- the displaySynapses to setpublic boolean isDisplaySynapses()
public Synapse removeSynapse(Synapse toDelete)
toDelete
- the synapse to deletepublic void prune()
public void clear()
public void addNewSynapse(Synapse synapse)
addSynapseUnsafe(Synapse)
because it makes the added
synapse conform to the global parameters of this synapse group.synapse
- the blank synapse to be added and assigned new values
based on the parameters of this group.public void addNewExcitatorySynapse(Synapse synapse)
synapse
- the blank excitatory synapse which will be added to the
group and have its parameters set based on the parameters of this group.public void addNewInhibitorySynapse(Synapse synapse)
synapse
- the blank inhibitory synapse which will be added to the
group and have its parameters set based on the parameters of this group.public void addSynapseUnsafe(Synapse synapse)
synapse
- synapse to addpublic void addExcitatorySynapseUnsafe(Synapse synapse)
addSynapseUnsafe(Synapse)
. Same but specific to excitatory
synapses. This is even less safe however because an inhibitory synapse
could potentially be added to the excitatory set.synapse
- the synapse to add.public void addInhibitorySynapseUnsafe(Synapse synapse)
addSynapseUnsafe(Synapse)
. Same but specific to inhibitory
synapses. This is even less safe however because an excitatory synapse
could potentially be added to the inhibitory set.synapse
- the synapse to add.public void setExcitatoryRatio(double excitatoryRatio) throws java.lang.IllegalArgumentException
excitatoryRatio
- the ratio of synapses which will be made excitatory, value
must be in the range [0, 1]java.lang.IllegalArgumentException
- if the ratio is not on [0, 1].public double getExcitatoryRatioParameter()
getExcitatoryRatioPrecise()
.public double getExcitatoryRatioPrecise()
public java.util.List<Synapse> getAllSynapses()
public java.util.Set<Synapse> getExcitatorySynapses()
public java.util.Set<Synapse> getInhibitorySynapses()
public double[] getWeightVector()
public double[] getInhibitoryStrengths()
public double[] getExcitatoryStrengths()
public double[][] getWeightMatrix()
getRowCompressedMatrixRepresentation()
instead.public double[][] getNumericIndices()
public java.lang.Number[][] getNumericIndices(ConnectionUtilities.SynapseParameterGetter<java.lang.Number> getter)
public long[] getRowCompressedMatrixRepresentation()
public void saveToFileAsLinkedList(java.lang.String filename)
filename
- the name to be given to the filepublic void saveToFileAsLinkedList()
saveToFileAsLinkedList(String)
Uses the default name which is: label + date & timepublic void saveToFileAsMatrix(java.lang.String filename) throws java.lang.OutOfMemoryError
filename
- the name of the file to be usedjava.lang.OutOfMemoryError
- if getWeightMatrix()
causes an
out of memory error for being to large.public boolean setSynapseStrength(Synapse synapse, double newWeight)
synapse
- sets the strength of an individual synapse in the groupnewWeight
- the new weight to set it topublic void randomizeConnectionWeights()
randomizeExcitatoryConnections()
,
randomizeInhibitoryConnections()
public void randomizeExcitatoryConnections()
exciteRand
. Assumes that all synapses in
exSynapseSet
are--in fact--excitatory. If some action on the
synapses may have corrupted that assumption call
revalidateSynapseSets()
first.public void randomizeInhibitoryConnections()
inhibRand
. Assumes that all synapses in
inSynapseSet
are--in fact--inhibitory. If some action on the
synapses may have corrupted that assumption call
revalidateSynapseSets()
first.public void setConnectionManager(ConnectNeurons connection)
connection
- the connection manager to be used by this synapse group
for making synaptic connections.public ConnectNeurons getConnectionManager()
public void setExcitatoryRandomizer(PolarizedRandomizer excitatoryRandomizer)
excitatoryRandomizer
- the randomizer to be used to determine the weights of excitatory synapses.public void setInhibitoryRandomizer(PolarizedRandomizer inhibitoryRandomizer)
inhibitoryRandomizer
- the randomizer to be used to determine the weights of inbihitory synapses.public void setRandomizers(PolarizedRandomizer excitatoryRandomizer, PolarizedRandomizer inhibitoryRandomizer)
excitatoryRandomizer
- inhibitoryRandomizer
- public PolarizedRandomizer getExcitatoryRandomizer()
public PolarizedRandomizer getInhibitoryRandomizer()
public double calculateExcitatoryRatio()
public boolean isRecurrent()
public java.util.List<Neuron> getSourceNeurons()
public java.util.List<Neuron> getTargetNeurons()
public boolean hasExcitatory()
public boolean hasInhibitory()
public NeuronGroup getSourceNeuronGroup()
public NeuronGroup getTargetNeuronGroup()
public Synapse getExcitatoryPrototype()
#setAndConformToTemplate(Synapse, Polarity)
public Synapse getInhibitoryPrototype()
#setAndConformToTemplate(Synapse, Polarity)
public boolean isUseGroupLevelSettings()
public void setUseGroupLevelSettings(boolean useGroupLevelSettings)
useGroupLevelSettings
- public void setAndConformToTemplate(Synapse template, SimbrainConstants.Polarity polarity)
template
- the set synapse templatepolarity
- public void setDelay(int delay, SimbrainConstants.Polarity polarity)
delay
- the set delaypolarity
- public void setEnabled(boolean enabled, SimbrainConstants.Polarity polarity)
enabled
- polarity
- public void setFrozen(boolean frozen, SimbrainConstants.Polarity polarity)
frozen
- polarity
- public void setIncrement(double increment, SimbrainConstants.Polarity polarity)
increment
- polarity
- public void setLearningRule(SynapseUpdateRule sur, SimbrainConstants.Polarity polarity)
sur
- polarity
- public void setLowerBound(double lowerBound, SimbrainConstants.Polarity polarity)
lowerBound
- polarity
- public void setSpikeResponder(SpikeResponder spr, SimbrainConstants.Polarity polarity)
spr
- polarity
- public void setStrength(double strength, SimbrainConstants.Polarity polarity)
strength
- polarity
- public void setUpperBound(double upperBound, SimbrainConstants.Polarity polarity)
upperBound
- polarity
- public java.lang.Integer getDelay(SimbrainConstants.Polarity polarity)
polarity
- public java.lang.Boolean isEnabled(SimbrainConstants.Polarity polarity)
polarity
- public java.lang.Boolean isFrozen(SimbrainConstants.Polarity polarity)
polarity
- public double getIncrement(SimbrainConstants.Polarity polarity)
polarity
- public java.lang.String getLearningRuleDescription(SimbrainConstants.Polarity polarity)
polarity
- public double getLowerBound(SimbrainConstants.Polarity polarity)
polarity
- public java.lang.String getSpikeResponderDescription(SimbrainConstants.Polarity polarity)
polarity
- public double getUpperBound(SimbrainConstants.Polarity polarity)
polarity
- public <T> T checkSynapses(ConnectionUtilities.SynapseParameterGetter<T> check, SimbrainConstants.Polarity polarity)
T
- check
- polarity
- public <T> void setSynapses(ConnectionUtilities.SynapseParameterSetter<T> set, T val, SimbrainConstants.Polarity polarity)
T
- set
- val
- polarity
- public boolean isUseFullRepOnSave()
public void setUseFullRepOnSave(boolean useFullRepOnSave)
public void preSaveInit()
public void preSaveInitFull()
public void postSaveReInit()
public void postUnmarshallingInit()