MASON-INTEREST-L Archives

April 2007

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:
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Sun, 15 Apr 2007 10:21:47 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (86 lines)
Hello,

My main question is how do you stop a schedule.scheduleRepeating()?? or 
is there something better to use for what i want to do??

I am new to MASON and agent based programming in general, so I am sorry 
if this is a basic problem but I have spent about 12 hours almost 
straight on this now and have not got anywhere :-(

What I want to do is run a simulation until a flag = true store that 
result and then run the same simulation again (x number of times). 
Preferably with the results at the end of each simulation being 
displayed in a chart. (simulations could run one after another or all 
together should not matter that much, would maybe like to have an option 
for either though if one is not a lot more complex than the other.

The problem I am getting at the moment is stopping the 
schedule.scheduleRepeating() I just cant do it! think i have tried 
everything but it does not seem to stop.

I have included part of my code so you can see what I am trying to do 
better:

/*** MODEL CLASS ***/

 public void start()
        {
            super.start(); 
            grid = new IntGrid2D(N, N);
            grid = new IntGrid2D(gridWidth, gridHeight);
  
         NKSpace_Gen nkGen = new NKSpace_Gen(System.currentTimeMillis());
         nkGen.Build_Space();
         nkGen.printAllFiles();

*// ** I basically want to get this **bit below **to repeat x number of 
time and then get it to stop when the agent flags a variable in the 
agents step method to be true ***

         Agent agent1 = new Agent(System.currentTimeMillis());
         agent1.selectPoint();
         agent1.getOneMutantNeighbours();

         schedule.scheduleRepeating(agent1);
}

/*** AGENT CLASS ***/

    public void step(SimState state)
    {
        if (mutantNeighbours.numObjs > 0 && higherFitness == false)
        {
            walkLandscape();
   
            if (higherFitness == true)
            {
                higherFitness = false;
                getOneMutantNeighbours();
            }
        }
        else
        {
            System.out.println(" Higher Fitness Values Found ");
            System.out.println("Fitness Value: "+ localPeak);
            peakFound = true;            *//** this is where I set 
peakFound to true and where I want to store the localPeak value and stop 
that agent at present it just keeps printing the two system.out.println 
to the console forever. (note they are only there for debug I actually 
will have a graphics showing the values. *
        }
       
        if (peakFound == false)
        {
        System.out.println("*** Current Fitness Searched ***");
        System.out.println("Fitness Value: "+ currentFitness);
       
        }
   
   }

ANY HELP or comments would be MUCH APPRECIATED!!

Many Thanks

Rick

ATOM RSS1 RSS2