Skip to content

Commit

Permalink
Merge pull request #258 from DimitriPlotnikov/master
Browse files Browse the repository at this point in the history
Improve stabilit of the symboltable infrastructure and use the latest MC version.
  • Loading branch information
Plotnikov authored Sep 13, 2016
2 parents 1583161 + 4ad73f5 commit c0e83a2
Show file tree
Hide file tree
Showing 36 changed files with 593 additions and 489 deletions.
148 changes: 74 additions & 74 deletions models/iaf_psc_exp.nestml
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
/*
Name: iaf_psc_exp_nestml - Leaky integrate-and-fire neuron model with exponential
PSCs.

Description:
iaf_psc_exp_nestml is an implementation of a leaky integrate-and-fire model
with exponential shaped postsynaptic currents (PSCs) according to [1].
Thus, postsynaptic currents have an infinitely short rise time.

The threshold crossing is followed by an absolute refractory period (t_ref)
during which the membrane potential is clamped to the resting potential
and spiking is prohibited.

The linear subthresold dynamics is integrated by the Exact
Integration scheme [2]. The neuron dynamics is solved on the time
grid given by the computation step size. Incoming as well as emitted
spikes are forced to that grid.

An additional state variable and the corresponding differential
equation represents a piecewise constant external current.

The general framework for the consistent formulation of systems with
neuron like dynamics interacting by point events is described in
[2]. A flow chart can be found in [3].

Remarks:
The present implementation uses individual variables for the
components of the state vector and the non-zero matrix elements of
the propagator. Because the propagator is a lower triangular matrix
no full matrix multiplication needs to be carried out and the
computation can be done "in place" i.e. no temporary state vector
object is required.

The template support of recent C++ compilers enables a more succinct
formulation without loss of runtime performance already at minimal
optimization levels. A future version of iaf_psc_exp_nestml will probably
address the problem of efficient usage of appropriate vector and
matrix objects.

Remarks: If tau_m is very close to tau_syn_ex or tau_syn_in, the model
will numerically behave as if tau_m is equal to tau_syn_ex or
tau_syn_in, respectively, to avoid numerical instabilities.
For details, please see IAF_Neruons_Singularity.ipynb in the
NEST source code (docs/model_details).

iaf_psc_exp_nestml can handle current input in two ways: Current input
through receptor_type 0 are handled as stepwise constant current
input as in other iaf models, i.e., this current directly enters
the membrane potential equation. Current input through
receptor_type 1, in contrast, is filtered through an exponential
kernel with the time constant of the excitatory synapse,
tau_syn_ex. For an example application, see [4].

References:
[1] Misha Tsodyks, Asher Uziel, and Henry Markram (2000) Synchrony Generation
in Recurrent Networks with Frequency-Dependent Synapses, The Journal of
Neuroscience, 2000, Vol. 20 RC50 p. 1-5
[2] Rotter S & Diesmann M (1999) Exact simulation of time-invariant linear
systems with applications to neuronal modeling. Biologial Cybernetics
81:381-402.
[3] Diesmann M, Gewaltig M-O, Rotter S, & Aertsen A (2001) State space
analysis of synchronous spiking in cortical neural networks.
Neurocomputing 38-40:565-571.
[4] Schuecker J, Diesmann M, Helias M (2015) Modulated escape from a
metastable state driven by colored noise.
Physical Review E 92:052119

Sends: SpikeEvent

Receives: SpikeEvent, CurrentEvent, DataLoggingRequest

SeeAlso: iaf_psc_exp_ps

FirstVersion: March 2006
Author: Moritz Helias
Name: iaf_psc_exp_nestml - Leaky integrate-and-fire neuron model with exponential
PSCs.

Description:
iaf_psc_exp_nestml is an implementation of a leaky integrate-and-fire model
with exponential shaped postsynaptic currents (PSCs) according to [1].
Thus, postsynaptic currents have an infinitely short rise time.

The threshold crossing is followed by an absolute refractory period (t_ref)
during which the membrane potential is clamped to the resting potential
and spiking is prohibited.

The linear subthresold dynamics is integrated by the Exact
Integration scheme [2]. The neuron dynamics is solved on the time
grid given by the computation step size. Incoming as well as emitted
spikes are forced to that grid.

An additional state variable and the corresponding differential
equation represents a piecewise constant external current.

The general framework for the consistent formulation of systems with
neuron like dynamics interacting by point events is described in
[2]. A flow chart can be found in [3].

Remarks:
The present implementation uses individual variables for the
components of the state vector and the non-zero matrix elements of
the propagator. Because the propagator is a lower triangular matrix
no full matrix multiplication needs to be carried out and the
computation can be done "in place" i.e. no temporary state vector
object is required.

The template support of recent C++ compilers enables a more succinct
formulation without loss of runtime performance already at minimal
optimization levels. A future version of iaf_psc_exp_nestml will probably
address the problem of efficient usage of appropriate vector and
matrix objects.

Remarks: If tau_m is very close to tau_syn_ex or tau_syn_in, the model
will numerically behave as if tau_m is equal to tau_syn_ex or
tau_syn_in, respectively, to avoid numerical instabilities.
For details, please see IAF_Neruons_Singularity.ipynb in the
NEST source code (docs/model_details).

iaf_psc_exp_nestml can handle current input in two ways: Current input
through receptor_type 0 are handled as stepwise constant current
input as in other iaf models, i.e., this current directly enters
the membrane potential equation. Current input through
receptor_type 1, in contrast, is filtered through an exponential
kernel with the time constant of the excitatory synapse,
tau_syn_ex. For an example application, see [4].

References:
[1] Misha Tsodyks, Asher Uziel, and Henry Markram (2000) Synchrony Generation
in Recurrent Networks with Frequency-Dependent Synapses, The Journal of
Neuroscience, 2000, Vol. 20 RC50 p. 1-5
[2] Rotter S & Diesmann M (1999) Exact simulation of time-invariant linear
systems with applications to neuronal modeling. Biologial Cybernetics
81:381-402.
[3] Diesmann M, Gewaltig M-O, Rotter S, & Aertsen A (2001) State space
analysis of synchronous spiking in cortical neural networks.
Neurocomputing 38-40:565-571.
[4] Schuecker J, Diesmann M, Helias M (2015) Modulated escape from a
metastable state driven by colored noise.
Physical Review E 92:052119

Sends: SpikeEvent

Receives: SpikeEvent, CurrentEvent, DataLoggingRequest

SeeAlso: iaf_psc_exp_ps

FirstVersion: March 2006
Author: Moritz Helias
*/
neuron iaf_psc_exp_neuron:

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!-- Monticore versions and dependencies -->
<antlr.version>4.5</antlr.version>
<monticore.version>4.4.1</monticore.version>
<monticore.version>4.4.2</monticore.version>

<!-- .. Plugins ....................................................... -->
<compiler.plugin>3.5.1</compiler.plugin>
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/nest/nestml/_cocos/AssignmentToAlias.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2015 RWTH Aachen. All rights reserved.
*
* http://www.se-rwth.de/
*/
package org.nest.nestml._cocos;

import de.monticore.symboltable.Scope;
import org.nest.nestml._ast.ASTAliasDecl;
import org.nest.spl._ast.ASTAssignment;
import org.nest.spl._cocos.SPLASTAssignmentCoCo;
import org.nest.symboltable.symbols.VariableSymbol;

import static com.google.common.base.Preconditions.checkArgument;
import static de.se_rwth.commons.logging.Log.error;

/**
* Every alias declaration has exactly one variable
*
* @author (last commit) ippen, plotnikov
*/
public class AssignmentToAlias implements SPLASTAssignmentCoCo {

public static final String ERROR_CODE = "NESTML_Assignment";

@Override
public void check(final ASTAssignment astAssignment) {
checkArgument(astAssignment.getEnclosingScope().isPresent(), "Run symboltable creator.");

final Scope scope = astAssignment.getEnclosingScope().get();
final String variableName = astAssignment.getLhsVarialbe().toString();
final VariableSymbol lhsVariable = VariableSymbol.resolve(variableName, scope);
if (lhsVariable.isAlias()) {
String msg = CocoErrorStrings.getInstance().getErrorMsg(this, variableName);

error(msg, astAssignment.get_SourcePositionStart());
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BufferNotAssignable implements SPLASTAssignmentCoCo {
public static final String ERROR_CODE = "NESTML_SPL_BUFFER_NOT_ASSIGNABLE";

public void check(final ASTAssignment astAssignment) {
checkArgument(astAssignment.getEnclosingScope().isPresent(), "Run symboltable creator. ");
checkArgument(astAssignment.getEnclosingScope().isPresent(), "Run symboltable creator.");
final Scope enclosingScope = astAssignment.getEnclosingScope().get();
final String varName = astAssignment.getLhsVarialbe().toString();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/nest/nestml/_cocos/CocoErrorStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,8 @@ public String getErrorMsg(final DerivativeOrderAtLeastOne coco, final String var

return DerivativeOrderAtLeastOne.ERROR_CODE + ":" + "The variable on the righthandside of an equation must be derivative variable, e.g. " + variableName + "'";
}

public String getErrorMsg(AssignmentToAlias assignmentToAlias, final String variableName) {
return AssignmentToAlias.ERROR_CODE + ":" + "You cannot assign a value to an alias: " + variableName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
* @author plotnikov
*/
public class VariableDoesNotExist implements ODEASTOdeDeclarationCoCo {

public static final String ERROR_CODE = "NESTML_VARIABLE_DOESNT_EXIST";
private static final String ERROR_MSG_FORMAT = "The variable %s is not defined in %s.";



@Override
public void check(final ASTOdeDeclaration node) {
node.getODEAliass().forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ private void registerCocos() {
final DerivativeOrderAtLeastOne derivativeOrderAtLeastOne = new DerivativeOrderAtLeastOne();
nestmlCoCoChecker.addCoCo(derivativeOrderAtLeastOne);

final AssignmentToAlias assignmentToAlias = new AssignmentToAlias();
nestmlCoCoChecker.addCoCo(assignmentToAlias);

final SPLCoCosManager splCoCosManager = new SPLCoCosManager();
splCoCosManager.addSPLCocosToNESTMLChecker(nestmlCoCoChecker);
}

public List<Finding> checkVariableUniqueness(final ASTNeuron astNeuron) {
List<Finding> checkVariableUniqueness(final ASTNeuron astNeuron) {
Log.getFindings().clear();

uniquenessChecker.addCoCo(new VariableDefinedMultipleTimes());
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/nest/nestml/_symboltable/NESTMLLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ public class NESTMLLanguage extends NESTMLLanguageTOP {
public NESTMLLanguage() {
super("NESTML Language", FILE_ENDING);

addResolver(CommonResolvingFilter.create(NeuronSymbol.class, NeuronSymbol.KIND));
addResolver(CommonResolvingFilter.create(NeuronSymbol.KIND));

addResolver(new PredefinedTypesFilter(TypeSymbol.KIND));

addResolver(new PredefinedMethodsFilter(MethodSymbol.KIND));
addResolver(new PredefinedTypesFilter());
addResolver(new PredefinedMethodsFilter());
addResolver(CommonResolvingFilter.create(MethodSymbol.KIND));

addResolver(CommonResolvingFilter.create(VariableSymbol.class, VariableSymbol.KIND));
addResolver(new PredefinedVariablesFilter(VariableSymbol.class, VariableSymbol.KIND));
addResolver(CommonResolvingFilter.create(VariableSymbol.KIND));
addResolver(new PredefinedVariablesFilter());

addResolver(CommonResolvingFilter.create(UsageSymbol.class, UsageSymbol.KIND));
addResolver(CommonResolvingFilter.create( UsageSymbol.KIND));

setModelNameCalculator(new CommonModelNameCalculator() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
import de.monticore.symboltable.resolving.ResolvingInfo;
import org.nest.symboltable.symbols.MethodSymbol;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import static org.nest.symboltable.predefined.PredefinedFunctions.getMethodSymbolIfExists;

/**
* TODO
* Returns a predefined methods if one exists: e.g. pow, exp, ...
*
* @author plotnikov
*/
public class PredefinedMethodsFilter extends CommonResolvingFilter<MethodSymbol> {

public PredefinedMethodsFilter(
final SymbolKind targetKind) {
super(targetKind);
public PredefinedMethodsFilter() {
super(MethodSymbol.KIND);


}

@Override
public Optional<Symbol> filter(ResolvingInfo resolvingInfo, String name,
List<Symbol> symbols) {
public Optional<Symbol> filter(ResolvingInfo resolvingInfo, String name, Map<String, Collection<Symbol>> symbols) {
final Optional<MethodSymbol> foundPredefinedMethod = getMethodSymbolIfExists(name);

if (foundPredefinedMethod.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,30 @@
import org.nest.symboltable.predefined.PredefinedTypes;
import org.nest.symboltable.symbols.TypeSymbol;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
* TODO
* All types in NESTML are predefined. This filter matches the type by name and returns if one exists
*
* @author plotnikov
*/
public class PredefinedTypesFilter extends CommonResolvingFilter<TypeSymbol> {
public PredefinedTypesFilter(
final SymbolKind targetKind) {
super(targetKind);
public PredefinedTypesFilter() {
super(TypeSymbol.KIND);
}

@Override
public Optional<Symbol> filter(
final ResolvingInfo resolvingInfo,
final String name,
final List<Symbol> symbols) {
public Optional<Symbol> filter(ResolvingInfo resolvingInfo, String name, Map<String, Collection<Symbol>> symbols) {
final Optional<TypeSymbol> typeSymbol = PredefinedTypes.getTypeIfExists(name);
if (typeSymbol.isPresent()) {
return Optional.of(typeSymbol.get());
}
else {
return Optional.empty();
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,23 @@
import org.nest.symboltable.predefined.PredefinedVariables;
import org.nest.symboltable.symbols.VariableSymbol;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
* TODO
* Returns a predefined variable (e.g. 't') if one exists.
*
* @author (last commit) $$Author$$
* @version $$Revision$$, $$Date$$
* @since TODO
* @author plotnikov
*/
public class PredefinedVariablesFilter extends CommonResolvingFilter<VariableSymbol> {
public PredefinedVariablesFilter(
final Class<VariableSymbol> symbolClass,
final SymbolKind targetKind) {
super(targetKind);
public PredefinedVariablesFilter() {
super(VariableSymbol.KIND);
}

@Override
public Optional<Symbol> filter(
final ResolvingInfo resolvingInfo,
final String name,
final List<Symbol> symbols) {
public Optional<Symbol> filter(ResolvingInfo resolvingInfo, String name, Map<String, Collection<Symbol>> symbols) {
final Optional<VariableSymbol> predefinedVariable = PredefinedVariables.getVariableIfExists(name);
if (predefinedVariable.isPresent()) {
return Optional.of(predefinedVariable.get());
Expand Down
Loading

0 comments on commit c0e83a2

Please sign in to comment.