MASON-INTEREST-L Archives

August 2014

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Fri, 1 Aug 2014 22:43:33 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (56 lines)
Simone, I suggest you do not write your own loop, period.  Instead, use doLoop().

All initialization (or re-initialization) of your model should be done in start().  

There is no need for schedule.getTime()==-1 (and you should not use -1 anyway, use a proper constant), since start() is always called before the simulation, you know, starts.

Sean

On Aug 1, 2014, at 6:22 PM, Simone Gabbriellini <[log in to unmask]> wrote:

> Hello,
> 
> I need to setup my agents before entering the big loop, and I am wondering where to call an initialize() method... right now I have this code:
> 
> public void start() {
>         super.start(); //use the previously defined code, then we add our own.
>         if(schedule.getTime()==-1){
>             initialize();
>         }
>         mach();
>         totcredit();
> }
> 
> is there a better approach to this? I tried this in my main, but initialize() is not called:
> 
> static void main(String[] args) throws Exception {
>         SimulationEnvironment state = new SimulationEnvironment(System.currentTimeMillis());
>         state.nameThread();
>         for (int job = 0; job < MC; job++) {
>             state.setJob(job);
>             state.initialize();
>             state.start();
>             do {
>                 if (!state.schedule.step(state)) {
>                     break;
>                 }
>             } while (state.schedule.getSteps() < T);
>             state.finish();
>         }
>         System.exit(0);
>     }
> 
> best,
> Simone
> -- 
> -----------------------------------------------------------------
> 
> Simone Gabbriellini, PhD
> 
> Post-doctoral Researcher
> ANR founded research project "DIFFCERAM"
> GEMASS, CNRS & Paris-Sorbonne.
> 
> mobile: +39 340 39 75 626
> email: [log in to unmask]

ATOM RSS1 RSS2