[med-svn] [cnrun] 20/25: WIP
andrei zavada
hmmr-guest at moszumanska.debian.org
Thu Nov 6 22:08:31 UTC 2014
This is an automated email from the git hooks/post-receive script.
hmmr-guest pushed a commit to branch WIP
in repository cnrun.
commit da7b8bfe02babdd2fb4f6a94bcfd324e17da84f7
Author: andrei zavada <andrei.zavada at massivesolutions.eu>
Date: Fri Oct 3 19:37:19 2014 +0300
WIP
---
upstream/Makefile.am | 7 +-
upstream/configure.ac | 1 +
upstream/data/Makefile.am | 7 ++
upstream/data/lua/cnrun.lua | 197 +++++++++++++++++++++++++++++++++++++++++
upstream/man/cnrun.1.in | 94 +++-----------------
upstream/src/cnrun/commands.cc | 50 +++++------
6 files changed, 249 insertions(+), 107 deletions(-)
diff --git a/upstream/Makefile.am b/upstream/Makefile.am
index 163a08f..be32637 100644
--- a/upstream/Makefile.am
+++ b/upstream/Makefile.am
@@ -1,13 +1,16 @@
ACLOCAL_AMFLAGS := -I m4
-SUBDIRS := src doc
+
+SUBDIRS := src doc data
EXTRA_DIST = \
ChangeLog \
autogen.sh \
- acinclude.m4
+ acinclude.m4 \
+ make_version
man_MANS = \
man/cnrun.1
+
if DO_TOOLS
man_MANS += \
man/varfold.1 \
diff --git a/upstream/configure.ac b/upstream/configure.ac
index 9851d4e..e6c2515 100644
--- a/upstream/configure.ac
+++ b/upstream/configure.ac
@@ -93,6 +93,7 @@ AC_OUTPUT([
src/libstilton/Makefile
src/libcn/Makefile
src/cnrun/Makefile
+ data/Makefile
doc/Makefile
man/cnrun.1
man/spike2sdf.1
diff --git a/upstream/data/Makefile.am b/upstream/data/Makefile.am
new file mode 100644
index 0000000..5345ca9
--- /dev/null
+++ b/upstream/data/Makefile.am
@@ -0,0 +1,7 @@
+luaincdir := $(datadir)/${PACKAGE}/lua
+
+luainc_DATA := \
+ lua/cnrun.lua
+
+EXTRA_DIST := \
+ $(luainc_DATA)
diff --git a/upstream/data/lua/cnrun.lua b/upstream/data/lua/cnrun.lua
new file mode 100644
index 0000000..963608b
--- /dev/null
+++ b/upstream/data/lua/cnrun.lua
@@ -0,0 +1,197 @@
+-- ; -*- mode: Lua -*-
+-- First, you collect necessary pieces
+local A, F = ...
+
+-- (1) A is an opaque structure representing our interpreter host side;
+-- all you need to do with it is pass it as the first arg to all calls
+-- of Fi and Fo (see below).
+
+-- (2) F, a CFunction, is the proxy to get any data across.
+-- It has the signature (think syscall):
+-- F( A, opcode, arg1, arg2, ...)
+-- where opcode is a string id of a host function.
+
+-- Here are wrappers of the CNrun interpreter API:
+
+-- common notes:
+-- (a) on error, F returns {false, error_string}; else, results as described below;
+-- (b) all page parameters are 1-based.
+
+function new_model (mname)
+ -- returns:
+ return F (A, "new_model", mname)
+end
+
+function delete_model (mname)
+ -- returns:
+ return F (A, "delete_model", mname)
+end
+
+function import_nml (mname, fname)
+ -- returns:
+ return F (A, "import_nml", mname, fname)
+end
+
+function export_nml (mname, fname)
+ -- returns:
+ return F (A, "export_nml", mname, fname)
+end
+
+function reset_model (mname)
+ -- returns:
+ return F (A, "reset_model", mname)
+end
+
+function cull_deaf_synapses (mname)
+ -- returns:
+ return F (A, "cull_deaf_synapses", mname)
+end
+
+function describe_model (mname)
+ -- returns:
+ return F (A, "describe_model", mname)
+end
+
+function get_model_parameter (mname, pname)
+ -- returns:
+ return F (A, "get_model_parameter", mname, pname)
+end
+
+function set_model_parameter (mname, pname, value)
+ -- returns:
+ return F (A, "set_model_parameter", mname, pname, value)
+end
+
+function advance (mname, time_to_go)
+ -- returns:
+ return F (A, "advance", mname, time_to_go)
+end
+
+function advance_until (mname, end_time)
+ -- returns:
+ return F (A, "advance_until", end_time)
+end
+
+
+function new_neuron (mname, ntype, label)
+ -- returns:
+ return F (A, "new_neuron", mname, ntype, label)
+end
+
+function new_synapse (mname, ytype, source, dest, g)
+ -- returns:
+ return F (A, "new_synapse", mname, ytype, source, dest, g)
+end
+
+function get_unit_properties (mname, label)
+ -- returns:
+ return F (A, "get_unit_properties", mname, label)
+end
+
+function get_unit_parameter (mname, label, pname)
+ -- returns:
+ return F (A, "get_unit_parameter", mname, label, pname)
+end
+
+function set_unit_parameter (mname, label, pname, value)
+ -- returns:
+ return F (A, "set_unit_parameter", mname, label, pname, value)
+end
+
+function get_unit_vars (mname, label, vname)
+ -- returns:
+ return F (A, "get_unit_vars", mname, label, vname)
+end
+
+function reset_unit (mname, label)
+ -- returns:
+ return F (A, "reset_unit", mname, label)
+end
+
+
+function get_units_matching (mname, pattern)
+ -- returns:
+ return F (A, "get_units_matching", mname, pattern)
+end
+
+function get_units_of_type (mname, tname)
+ -- returns:
+ return F (A, "get_units_of_type", mname, tname)
+end
+
+function set_matching_neuron_parameter (mname, pattern, parameter, value)
+ -- returns:
+ return F (A, "set_matching_neuron_parameter", mname, pattern, parameter, value)
+end
+
+function set_matching_synapse_parameter (mname, source_pattern, dest_pattern, parameter, value)
+ -- returns:
+ return F (A, "set_matching_synapse_parameter", mname, source_pattern, dest_pattern, parameter, value)
+end
+
+function revert_matching_unit_parameters (mname, pattern)
+ -- returns:
+ return F (A, "revert_matching_unit_parameters", mname, pattern)
+end
+
+function decimate (mname, pattern, fraction)
+ -- returns:
+ return F (A, "decimate", mname, pattern, fraction)
+end
+
+function putout (mname, pattern)
+ -- returns:
+ return F (A, "putout", mname, pattern)
+end
+
+
+function new_tape_source (mname, sname, fname, is_looping)
+ -- returns:
+ return F (A, "new_tape_source", mname, sname, fname, is_looping)
+end
+
+function new_periodic_source (mname, sname, fname, is_looping, period)
+ -- returns:
+ return F (A, "new_periodic_source", mname, sname, fname, is_looping, period)
+end
+
+function new_noise_source (mname, sname, min, max, sigma, distribution)
+ -- returns:
+ return F (A, "new_noise_source", mname, sname, min, max, sigma, distribution)
+end
+
+function get_sources (mname)
+ -- returns:
+ return F (A, "get_sources", mname)
+end
+
+function connect_source (mname, label, parameter, sname)
+ -- returns:
+ return F (A, "connect_source", mname, label, parameter, sname)
+end
+
+function disconnect_source (mname, label, parameter, sname)
+ -- returns:
+ return F (A, "disconnect_source", mname, label, parameter, sname)
+end
+
+
+function start_listen (mname, pattern)
+ -- returns:
+ return F (A, "start_listen", mname, pattern)
+end
+
+function stop_listen (mname, pattern)
+ -- returns:
+ return F (A, "stop_listen", mname, pattern)
+end
+
+function start_log_spikes (mname, pattern)
+ -- returns:
+ return F (A, "start_log_spikes", mname, pattern)
+end
+
+function stop_log_spikes (mname, pattern)
+ -- returns:
+ return F (A, "stop_log_spikes", mname, pattern)
+end
diff --git a/upstream/man/cnrun.1.in b/upstream/man/cnrun.1.in
index 510d60b..0359ac3 100644
--- a/upstream/man/cnrun.1.in
+++ b/upstream/man/cnrun.1.in
@@ -2,19 +2,18 @@
.SH NAME
CNrun -- a neuronal network simulator
.SH SYNOPSIS
- cnrun \fB\-h\fR | \fB\-U\fR | \fB\-e\fR \fIscript\fR [\fBOPTION\fR ...]
+ cnrun \fB\-h\fR | \fB\-U\fR | \fIscript\fR [\fBOPTION\fR ...]
.B
.PP
.SH DESCRIPTION
.PP
-\fBCNrun\fR is a neuronal network simulator, similar to NEURON or
-GENESIS, but without provision for unit compartments. It reads the
-network topology in NeuroML format as exported, f.i., by
-neuroConstruct. Unit types are determined by the \(oqcell_type\(cq
-attribute in the .nml definitions.
+\fBCNrun\fR is a conductance- and rate-based neuronal network
+simulator with a capability for scripting plastic processes (in Lua)
+and NeuroML support.
-Available neuron types, by the corresponding \(oqcell_type\(cq string, include:
+Available neuron types, by the corresponding \(oqcell_type\(cq string,
+include:
.IP \(bu
\fIHH\fR and \fIHHRate\fR, conductance\- and rate\-based Hodgkin\-Huxley
neurons (Traub & Miles, 1991);
@@ -29,78 +28,21 @@ synapses as described in Rall et al, 1967 (\fIRall\fR) and Destexhe et
al, 1994 (\fIAB\fR).
.PP
-Unit parameters can be set via a \fBset_parm_*\fR command (see \fBSCRIPTING\fR
-below); values can be set once before the simulation, or continuously
-or periodically per user\-defined schedule.
-
A 6\-5\-order Runge\-Kutta integration method is used to compute state
variables. These (membrane potential E or instantaneous firing rate R
for neurons, neurotransmitter release S for synapses) as well as spike
-times can be logged.
+times can be logged for further visualisation.
-Scripting support in CNrun includes commands for creating and
-populating a model, setting parameters for single units or groups
-selected based on regex matching. Variables (\(oqa = 1; b = a +
-2\(cq) and arithmetic expressions (\(oq\-\(cq, \(oq+\(cq, \(oq*\(cq,
-\(oq/\(cq, \(oq()\(cq ) are supported.
+Scripting in CNrun is implemented in Lua. Model simulator functions
+available for use in scripts include those for reading state variables
+and setting parameters for specific (regex-matched groups of) units;
+creating and connecting new units; modifying input sources feeding
+into units.
.SH OPTIONS
\fB\-C\fR \fIdir\fR
chdir to \fIdir\fR before running.
.TP
-\fB\-D\fR
-Dump all unit types in the model and exit.
-.TP
-\fB\-e\fR [\fIscript\fR]
-Execute \fIscript\fR. If this option is given without a file name (or
-not given at all), start an interactive interpreter.
-.TP
-\fB\-s\fR
-Sort units (mostly useful with verbose output).
-.TP
-\fB\-L\fR[1dbxL]
-For all listeners:
-.RS 4
-.IP d
-Defer writing to disk until done rather than write continuously
-(speeds up the simulation but you can\(cqt watch the progress live
-with gnuplot)
-.IP 1
-Only log the first variable (appropriate for the HH model, which units
-have in excess the three uninteresting gating parameters).
-.IP b
-Write in native binary form rather than in ASCII. This will speed up
-viewing the (now label.varx files) with gnuplot. Do your plotting
-with \(lqbinary format="%lf%lf"\(rq to achieve this.
-
-These options can also be set using command \fBlisten_mode\fR (which see, below).
-.IP L
-log integrator dt.
-.RE
-.TP
-\fB\-E\fR \fIdouble\fR
-Listen at this interval (default 1 msec; set to
-0 to listen every cycle, which can slow cnrun down considerably).
-Also available as command \fBlisten_dt\fR.
-.TP
-\fB\-k\fR[l|0]
-Write a model\-wide log of spiking neurons, using labels (\(oql\(cq) or unit ids (\(oq0\(cq).
-.TP
-\fB\-e \fIuint\fR
-Set precision for all output (default 8).
-.TP
-\fB\-iT\fIdouble\fR
-dt_max (default 0.5).
-.TP
-\fB\-it\fIdouble\fR
-dt_min (default 1e\-05).
-.TP
-\fB\-ix\fIdouble\fR
-Cap dt increase by current dt value x this (default 5).
-.TP
-\fB\-nc\fR
-Disable synapse coalescing (for benchmarking).
-.TP
\fB\-v \fIint\fR
Set verbosity level (default 1; values up to 7 are meaningful).
Use a negative value to show the progress percentage only,
@@ -112,13 +54,9 @@ List all available units.
\fB\-h\fR
Print the overview of command\-line options.
-Space is optional between the option letter and argument for
-single\-letter options. In all two\-letter options taking an argument
-though, make sure there is no space in between.
-
.SH SCRIPTING
-Commands are delimited by a colon or new\-line. Comments are lines
-starting with #. The following commands are available:
+In your Lua scripts, include the boilerplate from @datadir@/cnrun.lua.
+This makes available the following CNrun functions:
.TP
\fBnew_model\fR NAME
Create a new model called NAME. Existing model is deleted.
@@ -290,10 +228,6 @@ identify a synapse, you need to specify its source and target).
The command\-line option \fB\-nc\fR can be used to disable coalescing.
-.SH FILES
-.TP
-\fI.cnrun\-history\fR, a per\-directory history of entered commands.
-
.SH EXAMPLE
In @docdir@/ratiocoding, there is a working example of cnrun
setup which reproduces some of the results presented in Zavada et al
diff --git a/upstream/src/cnrun/commands.cc b/upstream/src/cnrun/commands.cc
index 20e1a62..c67c032 100644
--- a/upstream/src/cnrun/commands.cc
+++ b/upstream/src/cnrun/commands.cc
@@ -38,9 +38,9 @@ inline const char* es(int x) { return (x == 1) ? "" : "s"; }
vp( 0, F"() takes %d arg%s, called with %zu", N, es(N), aa.size()); \
return R.result = TCmdResult::bad_arity, move(R); \
} \
- const char *model = aa[0].vs.c_str(); \
+ const string& model = aa[0].vs; \
if ( models.find(model) == models.end() ) { \
- vp( 0, F"(): no such model: \"%s\"", model); \
+ vp( 0, F"(): no such model: \"%s\"", model.c_str()); \
return R.result = TCmdResult::logic_error, move(R); \
} \
auto& M = *models.at(model);
@@ -90,7 +90,7 @@ cmd_delete_model( const TArgs& aa)
CMD_PROLOG (1, "delete_model");
delete &M;
- models.erase(aa[0].vs.c_str());
+ models.erase( model);
return move(R);
}
@@ -596,8 +596,8 @@ cmd_get_units_matching( const TArgs& aa)
{
CMD_PROLOG (2, "get_units_matching")
- const string &label = aa[1].vs;
- auto L = M.list_units( label);
+ const string &pattern = aa[1].vs;
+ auto L = M.list_units( pattern);
for ( auto& U : L )
R.values.emplace_back( SArg (U->label()));
@@ -630,12 +630,12 @@ cmd_set_matching_neuron_parameter( const TArgs& aa)
CMD_PROLOG (4, "set_matching_neuron_parameter")
const string
- &label = aa[1].vs,
+ &pattern = aa[1].vs,
¶m = aa[2].vs;
const double
&value = aa[3].vg;
- list<CModel::STagGroupNeuronParmSet> tags {CModel::STagGroupNeuronParmSet (label, param, value)};
+ list<CModel::STagGroupNeuronParmSet> tags {CModel::STagGroupNeuronParmSet (pattern, param, value)};
R.values.push_back(
SArg ((int)M.process_paramset_static_tags(
tags)));
@@ -675,9 +675,9 @@ cmd_revert_matching_unit_parameters( const TArgs& aa)
CMD_PROLOG (4, "revert_matching_unit_parameters")
const string
- &label = aa[1].vs;
+ &pattern = aa[1].vs;
- auto L = M.list_units( label);
+ auto L = M.list_units( pattern);
size_t count = 0;
for ( auto& U : L ) {
U->reset_params();
@@ -697,14 +697,14 @@ cmd_decimate( const TArgs& aa)
{
CMD_PROLOG (3, "decimate")
- const string &label = aa[1].vs;
+ const string &pattern = aa[1].vs;
const double& frac = aa[2].vg;
if ( frac < 0. || frac > 1. ) {
vp( 0, stderr, "decimate(%g): Decimation fraction outside [0..1]", frac);
return R.result = TCmdResult::bad_value, move(R);
}
- list<CModel::STagGroupDecimate> tags {{label, frac}};
+ list<CModel::STagGroupDecimate> tags {{pattern, frac}};
R.values.push_back(
SArg ((int)M.process_decimate_tags(
tags)));
@@ -720,9 +720,9 @@ cmd_putout( const TArgs& aa)
{
CMD_PROLOG (2, "putout")
- const string &label = aa[1].vs;
+ const string &pattern = aa[1].vs;
- list<CModel::STagGroup> tags {{label, CModel::STagGroup::TInvertOption::no}};
+ list<CModel::STagGroup> tags {{pattern, CModel::STagGroup::TInvertOption::no}};
R.values.push_back(
SArg ((int)M.process_putout_tags(
tags)));
@@ -925,9 +925,9 @@ cmd_start_listen( const TArgs& aa)
CMD_PROLOG (2, "start_listen")
const string
- &label = aa[1].vs;
+ &pattern = aa[1].vs;
list<CModel::STagGroupListener> tags {CModel::STagGroupListener (
- label, (0
+ pattern, (0
| (M.options.listen_1varonly ? CN_ULISTENING_1VARONLY : 0)
| (M.options.listen_deferwrite ? CN_ULISTENING_DEFERWRITE : 0)
| (M.options.listen_binary ? CN_ULISTENING_BINARY : CN_ULISTENING_DISK)),
@@ -947,13 +947,13 @@ cmd_stop_listen( const TArgs& aa)
CMD_PROLOG (2, "stop_listen")
const string
- &label = aa[1].vs;
+ &pattern = aa[1].vs;
list<CModel::STagGroupListener> tags {{
- label, (0
- | (M.options.listen_1varonly ? CN_ULISTENING_1VARONLY : 0)
- | (M.options.listen_deferwrite ? CN_ULISTENING_DEFERWRITE : 0)
- | (M.options.listen_binary ? CN_ULISTENING_BINARY : CN_ULISTENING_DISK)),
- CModel::STagGroup::TInvertOption::yes}};
+ pattern, (0
+ | (M.options.listen_1varonly ? CN_ULISTENING_1VARONLY : 0)
+ | (M.options.listen_deferwrite ? CN_ULISTENING_DEFERWRITE : 0)
+ | (M.options.listen_binary ? CN_ULISTENING_BINARY : CN_ULISTENING_DISK)),
+ CModel::STagGroup::TInvertOption::yes}};
R.values.push_back(
SArg ((int)M.process_listener_tags(
tags)));
@@ -972,9 +972,9 @@ cmd_start_log_spikes( const TArgs& aa)
vp( 1, "SDF parameters not set up, will only log spike times");
const string
- &label = aa[1].vs;
+ &pattern = aa[1].vs;
list<CModel::STagGroupSpikelogger> tags {{
- label,
+ pattern,
M.options.sxf_period, M.options.sdf_sigma, M.options.sxf_start_delay,
CModel::STagGroup::TInvertOption::no}};
R.values.push_back(
@@ -992,9 +992,9 @@ cmd_stop_log_spikes( const TArgs& aa)
CMD_PROLOG (2, "start_log_spikes")
const string
- &label = aa[1].vs;
+ &pattern = aa[1].vs;
list<CModel::STagGroupSpikelogger> tags {{
- label,
+ pattern,
M.options.sxf_period, M.options.sdf_sigma, M.options.sxf_start_delay,
CModel::STagGroup::TInvertOption::yes}};
R.values.push_back(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/cnrun.git
More information about the debian-med-commit
mailing list