Skip to content

Commit

Permalink
Merge pull request #202 from DimitriPlotnikov/master
Browse files Browse the repository at this point in the history
Restructure model artifacts. Increase development version.
  • Loading branch information
Plotnikov authored Jun 30, 2016
2 parents 7331da0 + b3223cf commit 4d468f6
Show file tree
Hide file tree
Showing 44 changed files with 101 additions and 111 deletions.
2 changes: 1 addition & 1 deletion docker/DockerfileRelease
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ENV MAVEN_HOME /usr/share/maven

# Define working directory.
WORKDIR /data
RUN wget https://github.com/nest/nestml/releases/download/0.0.4/nestml.jar
RUN wget https://github.com/nest/nestml/releases/download/0.0.5/nestml.jar

# create a non-root user named tester,
# give them the password "tester" put them in the sudo group
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BeginDocumentation
/*
Name: iaf_neuron - Leaky integrate-and-fire neuron model.

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

<groupId>nestml</groupId>
<artifactId>nestml-core</artifactId>
<version>0.0.5</version>
<version>0.1.0-SNAPSHOT</version>

<properties>
<!-- .. Libraries ..................................................... -->
Expand Down
32 changes: 1 addition & 31 deletions src/main/java/org/nest/codegeneration/NESTCodeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,37 +218,7 @@ private void generateModuleCodeForNeurons(
cmakeModuleClass,
neurons.get(0)); // an arbitrary AST to match the signature

final Path makefileFile = Paths.get("Makefile.am");
generator.generate(
"org.nest.nestml.module.Makefile",
makefileFile,
neurons.get(0)); // an arbitrary AST to match the signature

final Path bootstrappingFile = Paths.get("bootstrap.sh");
generator.generate(
"org.nest.nestml.module.Bootstrap",
bootstrappingFile,
neurons.get(0)); // an arbitrary AST to match the signature

final Path configureFile = Paths.get("configure.ac");
generator.generate(
"org.nest.nestml.module.Configure",
configureFile,
neurons.get(0)); // an arbitrary AST to match the signature

final Path moduleClass = Paths.get(moduleName + "Config.cpp");
generator.generate(
"org.nest.nestml.module.ModuleClass",
moduleClass,
neurons.get(0)); // an arbitrary AST to match the signature

final Path moduleHeader = Paths.get( moduleName + "Config.h");
generator.generate(
"org.nest.nestml.module.ModuleHeader",
moduleHeader,
neurons.get(0)); // an arbitrary AST to match the signature

final Path initSLI = Paths.get( moduleName + "-init.sli");
final Path initSLI = Paths.get("sli", moduleName + "-init.sli");
generator.generate(
"org.nest.nestml.module.SLI_Init",
initSLI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String convertFunctionCall(final ASTFunctionCall astFunctionCall) {
if (functionName.contains(PredefinedFunctions.EMIT_SPIKE)) {
return "set_spiketime(nest::Time::step(origin.get_steps()+lag+1));\n" +
"nest::SpikeEvent se;\n" +
"network()->send(*this, se, lag);";
"nest::kernel().event_delivery_manager.send(*this, se, lag);";
}

final Optional<MethodSymbol> functionSymbol = NESTMLSymbols.resolveMethod(astFunctionCall);
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/nest/nestml/_cocos/UsesOnlyComponents.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public void check(final ASTUSE_Stmt use) {

final Optional<NeuronSymbol> neuronType = scope.resolve(typeName, NeuronSymbol.KIND);

if (neuronType.isPresent() && !neuronType.get().getType().equals(NeuronSymbol.Type.COMPONENT)) {
final String msg = errorStrings.getErrorMsgOnlyComponentsForComponents(this, typeName);
if (neuronType.isPresent()) {
if (!neuronType.get().getType().equals(NeuronSymbol.Type.COMPONENT)) {
final String msg = errorStrings.getErrorMsgOnlyComponentsForComponents(this, typeName);
Log.error(msg, use.get_SourcePositionStart());

}

Log.error(msg, use.get_SourcePositionStart());
}
// Undefined type of the name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
@result TODO
-->
<#if ast.isCurrent()>
get_${ast.getName()}().add_value(e.get_rel_delivery_steps( network()->get_slice_origin()),
get_${ast.getName()}().add_value(e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin()),
weight * current );
</#if>
8 changes: 4 additions & 4 deletions src/main/resources/org/nest/nestml/buffer/SpikeBufferFill.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
-->
<#if ast.isSpike()>
// TODO do i need this?
//get_${ast.getName()}().add_value(e.get_rel_delivery_steps( network()->get_slice_origin()),
//get_${ast.getName()}().add_value(e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin()),
// weight * multiplicity );
<#if bufferHelper.isVector(ast)>
// 1
for (size_t i=0; i < P_.${bufferHelper.vectorParameter(ast)}; i++)
{
if (B_.receptor_types_${ast.getName()}[i] == e.get_rport()) {
get_${ast.getName()}()[i].add_value(e.get_rel_delivery_steps(network()->get_slice_origin()),
get_${ast.getName()}()[i].add_value(e.get_rel_delivery_steps(nest::kernel().simulation_manager.get_slice_origin()),
e.get_weight() * e.get_multiplicity());
}

Expand All @@ -29,14 +29,14 @@
<#if bufferHelper.isExcitatory(ast)>
if ( weight >= 0.0 ) // excitatory
{
get_${ast.getName()}().add_value(e.get_rel_delivery_steps( network()->get_slice_origin()),
get_${ast.getName()}().add_value(e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin()),
weight * multiplicity );
}
</#if>
<#if bufferHelper.isInhibitory(ast)>
if ( weight < 0.0 ) // inhibitory
{
get_${ast.getName()}().add_value(e.get_rel_delivery_steps( network()->get_slice_origin()),
get_${ast.getName()}().add_value(e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin()),
weight * multiplicity );
}
</#if>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<#--Dynamics implements BodyElement = "dynamics" (MinDelay | TimeStep) "(" Parameter ")"
BLOCK_OPEN! Block BLOCK_CLOSE!;-->
assert(to >= 0 && (nest::delay) from < nest::Scheduler::get_min_delay());
assert(from < to);

double t;
for ( nest::long_t lag = from ; lag < to ; ++lag ) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/org/nest/nestml/module/CMakeLists.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ cmake_minimum_required( VERSION 2.8.12 )
set( SHORT_NAME ${moduleName} )

# the complete module name is here:
set( MODULE_NAME ${r"$"}{SHORT_NAME}module )
set( MODULE_NAME ${r"$"}{SHORT_NAME} )

# 2) Add all your sources here
set( MODULE_SOURCES
${moduleName}.h ${moduleName}.cpp
<#list neurons as neuron>
${neuron.getName()}.cpp ${neuron.getName()}.h <#if neuron_has_next>\</#if>
${neuron.getName()}.cpp ${neuron.getName()}.h <#if neuron_has_next> </#if>
</#list>
)

Expand Down
24 changes: 16 additions & 8 deletions src/main/resources/org/nest/nestml/neuron/NeuronClass.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@
*
*/

// C++ includes:
#include <limits>

// Includes from libnestutil:
#include "numerics.h"

// Includes from nestkernel:
#include "exceptions.h"
#include "network.h"
#include "kernel_manager.h"
#include "universal_data_logger_impl.h"

// Includes from sli:
#include "dict.h"
#include "integerdatum.h"
#include "doubledatum.h"
#include "dictutils.h"
#include "numerics.h"
#include "universal_data_logger_impl.h"
#include "doubledatum.h"
#include "integerdatum.h"
#include "lockptrdatum.h"

#include <limits>
<#assign stateSize = body.getEquations()?size>
#include "${simpleNeuronName}.h"

<#assign stateSize = body.getEquations()?size>
/* ----------------------------------------------------------------
* Recordables map
* ---------------------------------------------------------------- */
Expand Down Expand Up @@ -318,7 +326,7 @@ ${simpleNeuronName}::handle(nest::SpikeEvent &e)
if ( B_.receptor_types_${spikeBuffer.getName()}[ i ] == e.get_rport() )
{
B_.${spikeBuffer.getName()}[i].add_value(
e.get_rel_delivery_steps( network()->get_slice_origin() ),
e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin() ),
e.get_weight() * e.get_multiplicity() );
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/org/nest/nestml/neuron/NeuronHeader.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@
#include <gsl/gsl_odeiv.h>
</#if>

#include "nest.h"
#include "event.h"
// Includes from nestkernel:
#include "archiving_node.h"
#include "connection.h"
#include "event.h"
#include "nest_types.h"
#include "ring_buffer.h"
#include "universal_data_logger.h"

// Includes from sli:
#include "dictdatum.h"

/* BeginDocumentation
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/nest/base/ModelbasedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public class ModelbasedTest {
protected static final Path OUTPUT_FOLDER = Paths.get("target");
protected static final Path TEST_MODEL_PATH = Paths.get("src/test/resources/");
protected static final Path TEST_MODEL_PATH = Paths.get("models");
protected final NESTMLParser parser = new NESTMLParser(TEST_MODEL_PATH);
protected final NESTMLScopeCreator scopeCreator = new NESTMLScopeCreator(TEST_MODEL_PATH);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class NESTCodeGeneratorTest extends GenerationBasedTest {
private static final Path OUTPUT_DIRECTORY = Paths.get("target", "build");
private static final PSCMock pscMock = new PSCMock();

private static final String PSC_MODEL_WITH_ODE = "src/test/resources/codegeneration/iaf_psc_alpha.nestml";
private static final String PSC_MODEL_WITH_ODE = "models/iaf_psc_alpha.nestml";
private static final String PSC_MODEL_IMPERATIVE = "src/test/resources/codegeneration/imperative/iaf_psc_alpha_imperative.nestml";
private static final String COND_MODEL_IMPLICIT = "src/test/resources/codegeneration/iaf_cond_alpha_implicit.nestml";
private static final String COND_MODEL_IMPLICIT = "models/iaf_cond_alpha_implicit.nestml";

@Test
public void testPSCModelWithoutOde() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author plotnikov
*/
public class AliasInverterTest extends GenerationBasedTest {
private static final String PSC_MODEL_WITH_ODE = "src/test/resources/codegeneration/iaf_psc_alpha.nestml";
private static final String PSC_MODEL_WITH_ODE = "models/iaf_psc_alpha.nestml";

@Test
public void testComputationOfInverseFunction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
public class ExpressionFolderTest extends ModelbasedTest {
private static final ExpressionsPrettyPrinter printer = new ExpressionsPrettyPrinter();

private static final String MODEL_FILE_PATH = "src/test/resources/codegeneration/iaf_psc_alpha.nestml";
private final static Path STATE_VARIABLES_FILE = Paths.get("src/test/resources/codegeneration/sympy/psc/",
private static final String MODEL_FILE_PATH = "models/iaf_psc_alpha.nestml";
private final static Path STATE_VARIABLES_FILE = Paths.get(
"src/test/resources/codegeneration/sympy/psc/",
LinearSolutionTransformer.STATE_VARIABLES_FILE);
private final static Path STATE_UPDATE_STEPS_FILE = Paths.get("src/test/resources/codegeneration/sympy/psc/",
private final static Path STATE_UPDATE_STEPS_FILE = Paths.get(
"src/test/resources/codegeneration/sympy/psc/",
LinearSolutionTransformer.STATE_VECTOR_UPDATE_STEPS_FILE);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class LinearSolutionTransformerTest extends ModelbasedTest {
LinearSolutionTransformer.STATE_VECTOR_TMP_BACK_ASSIGNMENTS_FILE);

private static final String NEURON_NAME = "iaf_psc_alpha_nestml";
private static final String MODEL_FILE_PATH = "src/test/resources/codegeneration/iaf_psc_alpha.nestml";
private static final String MODEL_FILE_PATH = "models/iaf_psc_alpha.nestml";

@Test
public void testExactSolutionTransformation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.nest.ode._ast.ASTEquation;
import org.nest.symboltable.predefined.PredefinedFunctions;
import org.nest.utils.ASTUtils;
import org.nest.utils.FilesHelper;

import java.io.IOException;
import java.io.StringReader;
Expand All @@ -32,14 +33,10 @@
* @author plotnikov
*/
public class SympyScriptGeneratorTest extends ModelbasedTest {
private static final String PATH_TO_PSC_MODEL
= "src/test/resources/codegeneration/iaf_psc_alpha.nestml";
private static final String PATH_TO_PSC_DELTA_MODEL
= "src/test/resources/codegeneration/iaf_psc_delta.nestml";
private static final String PATH_TO_COND_MODEL
= "src/test/resources/codegeneration/iaf_cond_alpha.nestml";
private static final String PATH_TO_COND_IMPLICIT_MODEL
= "src/test/resources/codegeneration/iaf_cond_alpha_implicit.nestml";
private static final String PATH_TO_PSC_MODEL = "models/iaf_psc_alpha.nestml";
private static final String PATH_TO_PSC_DELTA_MODEL = "models/iaf_psc_delta.nestml";
private static final String PATH_TO_COND_MODEL = "models/iaf_cond_alpha.nestml";
private static final String PATH_TO_COND_IMPLICIT_MODEL = "models/iaf_cond_alpha_implicit.nestml";

private static final String OUTPUT_FOLDER = "target";
private static final Path OUTPUT_SCRIPT_DIRECTORY = Paths.get(OUTPUT_FOLDER, "sympy");
Expand Down Expand Up @@ -92,6 +89,8 @@ private void generateAndCheck(final String pathToModel) throws IOException {
final NESTMLScopeCreator nestmlScopeCreator = new NESTMLScopeCreator(TEST_MODEL_PATH);
nestmlScopeCreator.runSymbolTableCreator(root.get());

FilesHelper.deleteFilesInFolder(OUTPUT_SCRIPT_DIRECTORY);

final Optional<Path> generatedScript = generateSympyODEAnalyzer(
root.get().getNeurons().get(0),
OUTPUT_SCRIPT_DIRECTORY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
public class NESTCodeGeneratorIntegrationTest extends GenerationBasedTest {

private final List<String> pscModelsWithOde = Lists.newArrayList(
"src/test/resources/codegeneration/iaf_neuron.nestml",
"src/test/resources/codegeneration/iaf_psc_alpha.nestml",
"src/test/resources/codegeneration/iaf_psc_exp.nestml",
"src/test/resources/codegeneration/iaf_tum_2000.nestml",
"src/test/resources/codegeneration/iaf_psc_delta.nestml",
"src/test/resources/codegeneration/mat2_psc_exp.nestml"
"models/iaf_neuron.nestml",
"models/iaf_psc_alpha.nestml",
"models/iaf_psc_exp.nestml",
"models/iaf_tum_2000.nestml",
"models/iaf_psc_delta.nestml",
"models/mat2_psc_exp.nestml"
);

private final List<String> multisynapseModels = Lists.newArrayList(
"src/test/resources/codegeneration/iaf_psc_alpha_multisynapse.nestml",
"src/test/resources/codegeneration/iaf_psc_exp_multisynapse.nestml"
"models/iaf_psc_alpha_multisynapse.nestml",
"models/iaf_psc_exp_multisynapse.nestml"
);

private final List<String> imperativeModels = Lists.newArrayList(
Expand All @@ -47,15 +47,15 @@ public class NESTCodeGeneratorIntegrationTest extends GenerationBasedTest {
);

private final List<String> nestmlCondModels = Lists.newArrayList(
"src/test/resources/codegeneration/iaf_cond_alpha.nestml"
"models/iaf_cond_alpha.nestml"
);

private final List<String> nestmlCondImplicitModels = Lists.newArrayList(
"src/test/resources/codegeneration/iaf_cond_alpha_implicit.nestml",
"src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml",
"src/test/resources/codegeneration/aeif_cond_alpha_implicit.nestml",
"src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml",
"src/test/resources/codegeneration/hh_psc_alpha.nestml"
"models/iaf_cond_alpha_implicit.nestml",
"models/iaf_cond_exp_implicit.nestml",
"models/aeif_cond_alpha_implicit.nestml",
"models/aeif_cond_exp_implicit.nestml",
"models/hh_psc_alpha.nestml"

);

Expand Down Expand Up @@ -152,7 +152,7 @@ public void testGlifModel() {

@Test
public void testIzhikevich() {
final List<String> modelName = Lists.newArrayList("src/test/resources/codegeneration/izhikevich.nestml");
final List<String> modelName = Lists.newArrayList("models/izhikevich.nestml");
modelName.forEach(this::checkCocos);
modelName.forEach(this::invokeCodeGenerator);
final List<ASTNESTMLCompilationUnit> roots = modelName.stream()
Expand All @@ -164,7 +164,7 @@ public void testIzhikevich() {
@Ignore("Don't run this tests on github")
@Test
public void testManually() {
final List<String> modelName = Lists.newArrayList("src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml");
final List<String> modelName = Lists.newArrayList("models/iaf_cond_exp_implicit.nestml");
modelName.forEach(this::checkCocos);
modelName.forEach(this::invokeCodeGenerator);
final List<ASTNESTMLCompilationUnit> roots = modelName.stream()
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/nest/integration/ODEProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
* @author plotnikov
*/
public class ODEProcessorTest extends ModelbasedTest {
private static final String COND_MODEL_FILE = "src/test/resources/codegeneration/iaf_cond_alpha.nestml";
private static final String PSC_MODEL_FILE = "src/test/resources/codegeneration/iaf_neuron.nestml";
private static final String PSC_DELTA_MODEL_FILE = "src/test/resources/codegeneration/iaf_psc_delta.nestml";
private static final String COND_MODEL_FILE = "models/iaf_cond_alpha.nestml";
private static final String PSC_MODEL_FILE = "models/iaf_neuron.nestml";
private static final String PSC_DELTA_MODEL_FILE = "models/iaf_psc_delta.nestml";
private static final String PSC_NEURON_NAME = "iaf_neuron_nestml";

private final ODEProcessor testant = new ODEProcessor();
Expand Down Expand Up @@ -68,7 +68,7 @@ private Scope processModel(final String pathToModel) {
final ASTNESTMLCompilationUnit modelRoot = parseNESTMLModel(pathToModel);
scopeCreator.runSymbolTableCreator(modelRoot);
final String modelFolder = modelRoot.getFullName();
final Path outputBase = Paths.get(OUTPUT_FOLDER.toString(), Names.getPathFromQualifiedName(modelFolder));
final Path outputBase = Paths.get(OUTPUT_FOLDER.toString(), Names.getPathFromQualifiedName(pathToModel.toString()));
FilesHelper.deleteFilesInFolder(outputBase);

testant.solveODE(modelRoot.getNeurons().get(0), outputBase);
Expand Down
Loading

0 comments on commit 4d468f6

Please sign in to comment.