Hi,

I myself found the wrapper approach very convenient. Below is the code for Wrapper for a simulation of mine called ZIMarket which extends SimState. The parameters for a given run in this particular case are passed through the constructor, but you can set them after you have constructed you default simulation as well. The key part is the block from *.start() to *.finish() which steps things as long as there is anything scheduled.

Usual caveats apply: I have not used this code in a long time, but it should work.

Regards

Maciek

Code starts here:
--------------------------------------------

package homework1;

/* This is wrapper for ZIMarket, facilitating running multiple experiments. */

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class ZIMarketWrapper {


    public static void main(String[] args) {
       

        // Statistics for Buyers and Sellers will be saved in the two separate txt files.
       
        FileWriter fstream1 = null;
        FileWriter fstream2 = null;

        try {
            fstream1 = new FileWriter("outBuyers.txt");
            BufferedWriter outBuyers = new BufferedWriter(fstream1);

            fstream2 = new FileWriter("outSellers.txt ");
            BufferedWriter outSellers = new BufferedWriter(fstream2);

            // Run simulations for 300 times, with different storage ammounts.
           
            for (int n = 1; n < 100; n++) {

                for (int t = 1; t <= 5; t = t + 2) {
                    ZIMarket hhw = new ZIMarket(System.currentTimeMillis(), t, outBuyers, outSellers);
                    hhw.start();

                    while ( hhw.schedule.step(hhw)) {
                    }

                    hhw.finish();

                }

                System.out.println("N =" + n);

            }

            outBuyers.flush();
            outBuyers.close();

            outSellers.flush();
            outSellers.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

---------------------------------------------
Code ends here

On 8/20/07, Dr. Steven J. Barrett <[log in to unmask]> wrote:

Hi Ed,

...if all else fails(!), the easiest option might be to run Mason in it's batch mode (from the DOS prompt), using a DOS batch (.bat) script for the different parameterisation runs?

Rgds,

Steven



"Ed Long" <[log in to unmask]>
Sent by: "MASON Multiagent Simulation Toolkit" <[log in to unmask]>

20-Aug-2007 09:39
Please respond to "MASON Multiagent Simulation Toolkit" <[log in to unmask]>

       
To
[log in to unmask]
cc

Subject
Automating multiple runs







Hi,

I'm new to both MASON and Java programming so apologies if this is a bit
simple.

I have a simulation which runs nicely via the GUIState for single runs.  In
order to generate some data for stats analysis I'd like to get it to run
the simulation multiple times without the GUI, and also pass in an
automatically numbered filename to take output and a varying parameter
value.

From what I can see, the doLoop method is what I need but I can't seem to
get my head round the syntax.  Should I be writing the code within my
Engine (extension of SimState) class or a wrapper class which calls Engine?

Any help much appreciated!

Ed Long


-----------------------------------------------------------
This e-mail was sent by GlaxoSmithKline Services Unlimited
(registered in England and Wales No. 1047315), which is a
member of the GlaxoSmithKline group of companies. The
registered address of GlaxoSmithKline Services Unlimited
is 980 Great West Road, Brentford, Middlesex TW8 9GS.
-----------------------------------------------------------