MASON-INTEREST-L Archives

September 2012

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:
Chris Hollander <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Wed, 26 Sep 2012 12:46:35 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (113 lines)
If I understand what you're asking right, the simulation loop that
normally gets used is simple enough to rewrite yourself. For the work
that I do I actually have Scala scripts that automate the simulation
runs so that I can do multiple experiments and replications and
collect additional data. They make use of an "Experiment" class I
wrote.

Here the code for my experiment class and run loop. It's based on my
needs though, but there's no reason you couldn't add in debugging
information to pull information from the actual simulation.




public void run(MersenneTwisterFast seedGenerator, int[][]
experiments, int replications, long maxRuntime) {

        String experimentID;

        for (int e = 0; e < experiments.length; e++) {

            // We store the id as a binary number so its easier to
match up configurations with
            // MINITAB experiment ordering. All we have to do is
translate the binary number to
            // a decimal number and match. This is much less error
prone than using raw binary.
            experimentID =
Functions.padBinary(this.getExperimentID(experiments[e]), 6);


            // For each replication
            long seed;
            long step;
            long startTime;
            long stopTime;

            long maxTime;

            for (int i = 0; i < replications; i++) {
                System.out.print("Processing replication " + (i + 1) +
" on experiment configuration ");
                System.out.println(experimentID);

                seed = seedGenerator.nextLong();
                Simulation simObject = new Simulation(seed);
                simObject.nameThread();
                simObject.random = seedGenerator;

                //simObject.setSeed(seed);
                //simObject.setUserSeed(true);

                // Configure specific experimental settings
                ics.configureSimulation(simObject, experiments, e);
                simObject.outputFileId = experimentID + "_" + i + "_data";

                // Adjust max run time to account for the stability tolerance
                maxTime = maxRuntime;

                // Run the experiment
                startTime = System.nanoTime();

                simObject.setJob(i);
                simObject.start();

                while ((step = (long) simObject.schedule.getSteps())
<= maxTime) {
                    if (!simObject.schedule.step(simObject)) {
                        break;
                    }
                    if (step % 1000 == 0) {
                        System.out.println("Time Step (in Experiment):
" + step);
                    }
                }

                simObject.finish();
                stopTime = System.nanoTime();

                // Calculate the total runtime of the experiment in seconds
                double runtime = (double) (stopTime - startTime) / 1000000000.0;

                System.out.println("Replication " + (i + 1) + " of
Experiment " + experimentID + " ended after " + runtime + " seconds");
            } // end replication loop
        } // end experiment loop

    }



On Wed, Sep 26, 2012 at 8:54 AM, Richard O. Legendi <[log in to unmask]> wrote:
> Just a minor question: is it possible to turn off Mason's output(*)? It
> makes it a bit hard to find an issue in tests where a modell is running in
> the background.
>
> Thanks in advance!
>
> (*) =
> MASON Version 16.  For further options, try adding ' -help' at end.
>     Job: 0 Seed: 15
>     Starting ...
>
> Best,
> Richard
>
> --
> Richard O. Legendi
> Software developer
> Intelligent Applications and Web Services
> AITIA International, Inc.
> http://people.inf.elte.hu/legendi/

ATOM RSS1 RSS2