exiting model simulation run (in batch mode)based on a condition other than number of time ticks

13 views
Skip to first unread message

Rupinder Paul

unread,
Jan 21, 2010, 5:19:42 PM1/21/10
to SPARK Users Group

Hi ,

few more questions:
1. Is it possible to exit model simulation run (BATCH RUN MODE )
based some other user-defined property/condition other than the number
of ticks , which I specify through spark-pl source code or other-
wise .


2. Can I execute batch runs in background or kill all graphics
windows, because I have a scenario where I will be required to run
more than 1 simulation, although I can kill other gui windows but the
main model window still hangs around, which as my batches runs
increase (~500-750)can be a serious performance issue.

In other words in some cases where I am using the SPARK I don't need
to see the model looks or is doing, I just want the output of some
data field, and with higher number of batch runs it seems rather time
consuming.

3. Is it possible to run/execute scripts or managed code from SPARK.
--- Even though this is not an immediate concern to me. I was just
curious about interoperability.

thank you all for your help

regards
Rupen

Alexey

unread,
Jan 22, 2010, 3:55:27 PM1/22/10
to SPARK Users Group
1. It is possible to end a simulation from a SPARK-PL code. There are
two special functions 'begin-step' and 'end-step' which can be defined
for a model. This functions may return boolean values. If the returned
value is 'true' then a simulation will be terminated.
Right now, there are some problems with batch run processes. If you
terminate a simulation from a SPARK-PL code, then a whole batch
process will be stopped. It is a bug, and I'm going to correct it
soon. I'll post a message to this group when this bug will be
resolved.

2. There is no way to completely turn off graphics now. In fact, it is
very simple to implement, and I'll add this feature soon.

3. SPARK-PL is not the only way of writing SPARK models. The most
flexible way is to use Java directly. There is no proper documentation
about programming SPARK models in Java, so it is not as easy as in
SPARK-PL. Using Java, it is possible to do much more than in SPARK-PL.

I'm working on a new version of SPARK-PL where it will be possible to
extend it by writing new commands directly in Java.

Best,
Alexey

Rupinder Paul

unread,
Jan 22, 2010, 6:46:35 PM1/22/10
to SPARK Users Group
Hi Alexey,

Can you elaborate on the following


>on a new version of SPARK-PL where it will be possible to

>extend it by writing **new commands** directly in Java.

these "new commands" are in what context of extensibility?

thank you

regards
Rupen

Alexey

unread,
Jan 22, 2010, 7:04:43 PM1/22/10
to SPARK Users Group
Hi Rupen,

All functionality of SPARK-PL is based on commands. If you want to
move an agent you call the command 'move' (or 'move-at'). If you want
to count the number of agents at some location you call the command
'agents-at'. And so on. The SPARK-PL translator converts each SPARK-PL
command into some Java code, and then a Java compiler is invoked to
obtain executable byte code. Whenever you write something like

to do-something
end

in SPARK-PL, you define a new command. But you are limited here and
can use only predefined SPARK-PL commands. You cannot write a command
which calls an external Java function (for some statistical
computations, for example). I'm planning to introduce a mechanism
which will allow calling native Java functions from SPARK-PL.

Alexey

Rupinder Paul

unread,
Jan 22, 2010, 8:59:24 PM1/22/10
to SPARK Users Group

Hmm...As I understand , from the User docs the SPARK-pl -> is
*translated to **Java source code -> compiled to Machine Code ->
executed by "SPARK Simulation Engine"

When you say "You cannot write a command which calls an external Java
function (for some statistical computations, for example)"..

Do you mean this scenario : where in **Java source code that I have
written (without the need of *translating step) for a SPARK model, I
ADD some more bit of code with has nothing to do with SPARK framework/
model , runs some independent logic/code based on data values/
variables that currently being modified in SPARK simulation process --
and then use it to
a. store those values to file
b. or call another program

so the "SPARK Simulation Engine" complain about it?

I hope I am not being vague; But was curious because I observed that :
In the source codes of (toyInfection) SPARK model, you include/import
the JAVA System libraries such as util.ArrayList ; the simulation
engine doesn't complain about it. I was just wondering if I can
similarly use some other constructs (or perhaps functions) from JAVA
library-> if thats possible then it should be okay to execute
independent code.

regards
Rupen

Alexey

unread,
Jan 24, 2010, 6:47:16 PM1/24/10
to SPARK Users Group
Hi Rupen,

Initially, Toy Infection Model was implemented for SPARK in Java.
There was no SPARK-PL at that time. Later, when SPARK-PL was
implemented, I translated this model into SPARK-PL but I left the
existing Java code inside SPARK-PL files for comparison reasons. If
you look at any source code file of Toy Infection Model, then you will
find that the SPARK-PL code and the Java code are separated by the
following combination of symbols @#$#@#$#@. This combination of
symbols means the end of file for SPARK-PL translator, so it is not
reading anything after these symbols (alternatively, it is possible to
write ***end***). Right now, there is no straightforward way to use
Java inside SPARK-PL.

Alexey

Reply all
Reply to author
Forward
0 new messages