February 2014


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

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

Print Reply
Ernesto Carrella <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Tue, 11 Feb 2014 11:09:36 -0600
text/plain (1959 bytes) , text/html (9 kB)
Just to add on the previous answer.

The simplest way to run the model 300 times and run each model for 10000

public static void main(String[] args){
  final int NUMBER_OF_RUNS = 300;
  final int STEPS_PER_RUN = 10000;

  for(int run =0; run < NUMBER_OF_RUNS; run++)
      private MySimState model = new MySimState(....);
      for(int i=0; i< STEPS_PER_RUN; i++)


Now if you want to run it multithreaded, the simplest way to do it is this:

private static class OneRunOfTheModel implements Runnable

        public void run() {

            MacroII model = new MacroII(System.currentTimeMillis());
            for(int i=0; i< STEPS_PER_RUN; i++)

public static void main(String[] args) throws ExecutionException,
InterruptedException {
        ExecutorService executor = Executors.newCachedThreadPool();
        List<Future> receipts = new ArrayList<>(NUMBER_OF_RUNS);

        for(int i=0; i< NUMBER_OF_RUNS; i++)
            Future receipt = executor.submit(new OneRunOfTheModel());

        //here we make sure every run was completed
        for(Future receipt : receipts)


Notice that this is clearly not a good way to multithread. The runnables
are all potentially very long. Rather, you'd want the runnable to be just a
model step and build the whole blocking queue infrastructure; but hey, one
thing at a time.


On Tue, Feb 11, 2014 at 2:59 AM, Mac Van Vien <[log in to unmask]> wrote:

> Hi every body,
> I need to run MaSon model more than 300 times to take data farming.
> Therefore, I want kick off this model one time and then it  can run several
> times sequncetly or parallelly. Please show me how to do it.
> I am looking forward to here from you soon.
> Thank you very much
> Your sincerely
> Mac Van Vien