[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon, 19 Apr 2004 08:13:07 +0000 (UTC) 
Subject:Re: What should I do as the simulation is run forever? 
From:A . Sloman 
Volume-ID: 

Jenab.

Glad to see you solved your previous problem using INDATA

> Hello.
> I would like, my simulation is run several times automatically(for example
> 100 times) and its results are printed at an output file.
> I use
> run_simulation(sim_setup_info, 300, mintracevars);

Is thre any reason why you cannot do

repeat 100 times
    run_simulation(sim_setup_info, 300, mintracevars);
endrepeat;

This works for example if you do

    uses newkit

    teach sim_feelings


then in Ved
    ENTER l1

then
    repeat 10 times
       run_simulation(sim_setup_info, 3, []);
    endrepeat

When it starts each run it pauses till you press RETURN
(to give you a chance to re-arrange the layout of objects
on the screen).

Using [] as the final argument turns off all tracing and
pausing during the run, apart from the graphical movements
displayed.

The procedure run_simulation is defined in
    LIB sim_harness

You can copy it and edit that procedure to make it do different things
(e.g. remove the call of 'readline() ->;' if you don't want it to pause
at the beginning).

You can copy and edit the whole library file to make different
things happen when you run sim_agent.

(Use ENTER showlib to read a library file. Use ENTER name
to rename it so that you have your own editable copy
Then change your code to compile your version instead of the
library version.)

> What should I do as the simulation is run forever?

You can just use repeat:

    repeat
       run_simulation(sim_setup_info, 3, []);
    endrepeat


> (for stop simulation I use sim_stopping_scheduler).

That will only stop the *current* run of sim_run_agent (invoked
by run_simulation).

If you do everything inside a procedure called 'my_program'
then you can use

    exitfrom(myprogram);

or, if you prefer

    exitto(myprogram);

The latter will allow extra code to be run in myprogram before
it finally finishes.

See
    HELP CONTROL (section 7).

Or
    REF procedure/'Calling and Chaining'

Aaron