Michael McCracken | 1 May 02:04
Picon
Gravatar

Re: Repeating simulations

Klaus, Thanks. I think this pattern will work for me.

To answer your question about the research, I'm using SimPy to study
productivity in  High-Performance Computing. We simulate the steps a
user takes to complete a computational science experiment, including
waiting in a batch queue and transferring data over a network. The
idea is to provide better estimates of overal time-to-solution for HPC
users' projects.

I cited SimPy in a recently submitted paper, and if there's a listing
of projects using SimPy somewhere, I'd be happy to add my use to it.
It's been very important in keeping my own research productivity high.

Thanks,
-mike

On 4/26/07, Klaus Muller <kgmuller <at> xs4all.nl> wrote:
> Mike,
> Your problem identification is correct: to reset the simulation environment
> for a new run, you need to reset all globals which can be assigned to in a
> run. This includes all Store, Level, and Resource instances. Thus, the
> pattern for a run must be something like:
>
>         initialize()
>         #initialize all global variables
>         #make and activate at least one Process
>         simulate(until=endtime)
>
> Don't forget, class variables are also globals:
>
(Continue reading)

Tony Vignaux | 1 May 02:19
Picon
Picon
Favicon

Re: Repeating simulations

Michael,

How about adding your application and other information to the Simpy Wiki http://www.mcs.vuw.ac.nz/cgi-bin/wiki/SimPy?

Tony  Vignaux

On 5/1/07, Michael McCracken <michael.mccracken <at> gmail.com> wrote:
Klaus, Thanks. I think this pattern will work for me.

To answer your question about the research, I'm using SimPy to study
productivity in  High-Performance Computing. We simulate the steps a
user takes to complete a computational science experiment, including
waiting in a batch queue and transferring data over a network. The
idea is to provide better estimates of overal time-to-solution for HPC
users' projects.

I cited SimPy in a recently submitted paper, and if there's a listing
of projects using SimPy somewhere, I'd be happy to add my use to it.
It's been very important in keeping my own research productivity high.

Thanks,
-mike

On 4/26/07, Klaus Muller < kgmuller <at> xs4all.nl> wrote:
> Mike,
> Your problem identification is correct: to reset the simulation environment
> for a new run, you need to reset all globals which can be assigned to in a
> run. This includes all Store, Level, and Resource instances. Thus, the
> pattern for a run must be something like:
>
>         initialize()
>         #initialize all global variables
>         #make and activate at least one Process
>         simulate(until=endtime)
>
> Don't forget, class variables are also globals:
>
>         class Car(Process):
>                 nrCars=0
>                 . . . .
>
> What is your research about?
>
> Klaus Müller
>
>
> > -----Original Message-----
> > From: simpy-users-bounces <at> lists.sourceforge.net
> > [mailto: simpy-users-bounces <at> lists.sourceforge.net] On Behalf
> > Of Michael McCracken
> > Sent: Thursday, April 26, 2007 7:17 PM
> > To: simpy-users <at> lists.sourceforge.net
> > Subject: [Simpy-users] Repeating simulations
> >
> > Hi, I have a SimPy simulation I'm using for my research, and
> > I'm running into a problem with running multiple simulations
> > in the same program.
> >
> > I started out with one simulation run that looked like this:
> > - initialize()
> > - create Process subclass objects and tallies
> > - simulate()
> >
> > And I wanted to extend that to do many simulations in one
> > execution, so now I have something like this:
> >
> > simulations = [{},{},...] # dicts of config values
> >
> > if __name__ == "__main__":
> >     for sim in simulations:
> >        runSimulation(sim)
> >
> > def runSimulation(sim):
> >    initialize()
> >    # create Process subclass objects and tallies
> >    simulate(until=bignum)
> >
> > I still have some globals - a few Store objects are global,
> > and I think that must be where the problem is. What happens
> > is that sometimes earlier instances of the Process objects
> > get involved in later simulations.
> >
> > I guess I'd assumed that once their simulation was done, they
> > would be deleted, or at least not active anymore, but it
> > appears that they are still around and active, even if you
> > re-call initialize().
> > (Which makes sense looking at the source, since initialize()
> > doesn't do very much).
> >
> > So, my question is - is this a pattern that should work, and
> > I just need to add a step (maybe manually deleting the
> > Process objects, or getting rid of all globals and creating
> > new stores for each simulation run), or is there a better way
> > to get this behavior?
> >
> > The ultimate goal is just to run a bunch of simulations at
> > once with many parameters and get some statistics about the
> > simulation time over all of them, and some other measures.
> >
> > Thanks!
> > -mike
> >
> > --
> > Michael McCracken
> > UCSD CSE PhD Candidate
> > research: http://www.cse.ucsd.edu/~mmccrack/
> > misc: http://michael-mccracken.net/wp/
> >
> > --------------------------------------------------------------
> > -----------
> > This SF.net email is sponsored by DB2 Express Download DB2
> > Express C - the FREE version of DB2 express and take control
> > of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Simpy-users mailing list
> > Simpy-users <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/simpy-users
> >
>
>


--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/wp/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
Klaus Muller | 9 May 15:47
Picon
Picon
Favicon

Re: Repeating simulations

Hi Mike!

Your research area looks very interesting, and I hope SimPy contributes well
as a tool.

As to a list where to announce your project/application area of SimPy, I
suggest using the SimPy wiki http://www.mcs.vuw.ac.nz/cgi-bin/wiki/SimPy.

Cheers,

Klaus

> -----Original Message-----
> From: simpy-users-bounces <at> lists.sourceforge.net 
> [mailto:simpy-users-bounces <at> lists.sourceforge.net] On Behalf 
> Of Michael McCracken
> Sent: Tuesday, May 01, 2007 2:04 AM
> To: Klaus Muller
> Cc: simpy-users <at> lists.sourceforge.net
> Subject: Re: [Simpy-users] Repeating simulations
> 
> Klaus, Thanks. I think this pattern will work for me.
> 
> To answer your question about the research, I'm using SimPy 
> to study productivity in  High-Performance Computing. We 
> simulate the steps a user takes to complete a computational 
> science experiment, including waiting in a batch queue and 
> transferring data over a network. The idea is to provide 
> better estimates of overal time-to-solution for HPC users' projects.
> 
> I cited SimPy in a recently submitted paper, and if there's a 
> listing of projects using SimPy somewhere, I'd be happy to 
> add my use to it.
> It's been very important in keeping my own research productivity high.
> 
> Thanks,
> -mike
> 
> On 4/26/07, Klaus Muller <kgmuller <at> xs4all.nl> wrote:
> > Mike,
> > Your problem identification is correct: to reset the simulation 
> > environment for a new run, you need to reset all globals 
> which can be 
> > assigned to in a run. This includes all Store, Level, and Resource 
> > instances. Thus, the pattern for a run must be something like:
> >
> >         initialize()
> >         #initialize all global variables
> >         #make and activate at least one Process
> >         simulate(until=endtime)
> >
> > Don't forget, class variables are also globals:
> >
> >         class Car(Process):
> >                 nrCars=0
> >                 . . . .
> >
> > What is your research about?
> >
> > Klaus Müller
> >
> >
> > > -----Original Message-----
> > > From: simpy-users-bounces <at> lists.sourceforge.net
> > > [mailto:simpy-users-bounces <at> lists.sourceforge.net] On Behalf Of 
> > > Michael McCracken
> > > Sent: Thursday, April 26, 2007 7:17 PM
> > > To: simpy-users <at> lists.sourceforge.net
> > > Subject: [Simpy-users] Repeating simulations
> > >
> > > Hi, I have a SimPy simulation I'm using for my research, and I'm 
> > > running into a problem with running multiple simulations 
> in the same 
> > > program.
> > >
> > > I started out with one simulation run that looked like this:
> > > - initialize()
> > > - create Process subclass objects and tallies
> > > - simulate()
> > >
> > > And I wanted to extend that to do many simulations in one 
> execution, 
> > > so now I have something like this:
> > >
> > > simulations = [{},{},...] # dicts of config values
> > >
> > > if __name__ == "__main__":
> > >     for sim in simulations:
> > >        runSimulation(sim)
> > >
> > > def runSimulation(sim):
> > >    initialize()
> > >    # create Process subclass objects and tallies
> > >    simulate(until=bignum)
> > >
> > > I still have some globals - a few Store objects are global, and I 
> > > think that must be where the problem is. What happens is that 
> > > sometimes earlier instances of the Process objects get 
> involved in 
> > > later simulations.
> > >
> > > I guess I'd assumed that once their simulation was done, 
> they would 
> > > be deleted, or at least not active anymore, but it 
> appears that they 
> > > are still around and active, even if you re-call initialize().
> > > (Which makes sense looking at the source, since 
> initialize() doesn't 
> > > do very much).
> > >
> > > So, my question is - is this a pattern that should work, 
> and I just 
> > > need to add a step (maybe manually deleting the Process 
> objects, or 
> > > getting rid of all globals and creating new stores for each 
> > > simulation run), or is there a better way to get this behavior?
> > >
> > > The ultimate goal is just to run a bunch of simulations 
> at once with 
> > > many parameters and get some statistics about the simulation time 
> > > over all of them, and some other measures.
> > >
> > > Thanks!
> > > -mike
> > >
> > > --
> > > Michael McCracken
> > > UCSD CSE PhD Candidate
> > > research: http://www.cse.ucsd.edu/~mmccrack/
> > > misc: http://michael-mccracken.net/wp/
> > >
> > > --------------------------------------------------------------
> > > -----------
> > > This SF.net email is sponsored by DB2 Express Download 
> DB2 Express C 
> > > - the FREE version of DB2 express and take control of 
> your XML. No 
> > > limits. Just data. Click to get it now.
> > > http://sourceforge.net/powerbar/db2/
> > > _______________________________________________
> > > Simpy-users mailing list
> > > Simpy-users <at> lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/simpy-users
> > >
> >
> >
> 
> 
> --
> Michael McCracken
> UCSD CSE PhD Candidate
> research: http://www.cse.ucsd.edu/~mmccrack/
> misc: http://michael-mccracken.net/wp/
> 
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by DB2 Express Download DB2 
> Express C - the FREE version of DB2 express and take control 
> of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Simpy-users mailing list
> Simpy-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simpy-users
> 
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Tony Vignaux | 21 May 09:12
Picon

Re: resetting Resources, etc

When attempting to run replications of a simulation - using, perhaps, a different random number seed, you have to initialise the simulation and all the objects in it at the start of each replication.  Currently we tend to use a model() method where a simulation run is set up and executed in model()  and the model() is called within a loop (see, for example TheBank tutorial and some of the programs in the Models directory).

But how do we initialise the Resources (Levels/Stores)? These have to be accessible both from the message/customer objects and also within model() so we can, for example, make sure the system is empty and idle at the start and return or display results after the simulate(until = ...).

We can:
1. define the Resource object within model()  but must then define it as global. Messy.
2. define it within model() and pass it as an argument via the Source object to the Message objects it generates. A long way round
3. define an object of a  class outside model(). This object would have a Resource as an attribute which is defined inside model(). This is elegant and, for larger models where the environment may be complicated and the external object may have several attributes to be initialised, this may the the way to go.

As a alternative, I  suggest that a reset() method for Resources would be a simple and useful technique to initialising replications within the model() function. The Resource object could be set up outside model(), be accessible to all processes, and yet start off initialised.

Any comments?


Tony Vignaux

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
Klaus Muller | 21 May 11:59
Picon
Picon
Favicon

Re: resetting Resources, etc

Tony,
I agree, option 1 is messy; globals always are, as they lead to unnecessary coupling of components (and lovely bugs).
 
Option 2 is ok from a software engineering point of view (minimal coupling), but less clear from a modelling point. What do those Resource instances belong to? They appear from nowhere in model( ). What if you wish to simulate two banks in model( )?
 
Option 3 is the best for both the software structure and for the modeller. If the model is "A bank has one counter and a stream of customers . . . ", I would like to find this relationship back in the simulation script.
 
The reset approach is feasible, but it makes for a strange program structure:
 
# Model components
(Process classes)
# Experiment data
. . . .
# Setting up of Resource instance(s)
. . . .
# Model
def model( ):
    for i in range(nrReplications):
        initialize( )
        reset Resource instances
        construct and activate Process instances
        simulate(until=endtime)
 
Because of the Resource(s) being global, this makes for implicit coupling between the Process entities and the Resource instance(s), and the model( ) function and the Resource(s).
 
My recommendation is to use option 3, even for small programs (and in particular in tutorials where we are trying to teach SimPy and good SimPy program structure).
 
The reset() approach may reduce verbosity slightly, but it also reduces clarity in my view.
 
Klaus
 
 
 

From: simpy-users-bounces <at> lists.sourceforge.net [mailto:simpy-users-bounces <at> lists.sourceforge.net] On Behalf Of Tony Vignaux
Sent: Monday, May 21, 2007 9:12 AM
To: SimPy Users
Subject: Re: [Simpy-users] resetting Resources, etc

When attempting to run replications of a simulation - using, perhaps, a different random number seed, you have to initialise the simulation and all the objects in it at the start of each replication.  Currently we tend to use a model() method where a simulation run is set up and executed in model()  and the model() is called within a loop (see, for example TheBank tutorial and some of the programs in the Models directory).

But how do we initialise the Resources (Levels/Stores)? These have to be accessible both from the message/customer objects and also within model() so we can, for example, make sure the system is empty and idle at the start and return or display results after the simulate(until = ...).

We can:
1. define the Resource object within model()  but must then define it as global. Messy.
2. define it within model() and pass it as an argument via the Source object to the Message objects it generates. A long way round
3. define an object of a  class outside model(). This object would have a Resource as an attribute which is defined inside model(). This is elegant and, for larger models where the environment may be complicated and the external object may have several attributes to be initialised, this may the the way to go.

As a alternative, I  suggest that a reset() method for Resources would be a simple and useful technique to initialising replications within the model() function. The Resource object could be set up outside model(), be accessible to all processes, and yet start off initialised.

Any comments?


Tony Vignaux
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
m.prosperi@libero.it | 21 May 21:13
Picon
Favicon

question on a simulation approach


hi all,

in a program of mine I would find convenient a sort of 'lazy activation' of processes like the one in the
following script.

from SimPy.Simulation import *
import random

class Runner(Process):
    i=1
    def run(self):
        t=random.randint(0,5)
        yield hold,self, t
        print self.name,t
        activate(courier[self.i],courier[self.i].run())
        self.i+=1

r1=Runner(name='r1')
r2=Runner(name='r2')
r3=Runner(name='r3')
r4=Runner(name='r4')

courier=[r1,r2,r3,r4]

initialize()
activate(r1,r1.run(),at=0.0)
simulate(until=200)

It doesn't seem to work (either in my original program). Am I missing something or is it SimPy that doesn't
allow this?

Marco

------------------------------------------------------
Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
http://click.libero.it/infostrada

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Klaus Muller | 22 May 06:11
Picon
Picon
Favicon

Re: question on a simulation approach

Marco,
You use self.i, but i is a class variable. Rewrite your program as follows:

from SimPy.Simulation import *
import random

class Runner(Process):
    i=1
    def run(self):
        t=random.randint(0,5)
        yield hold,self, t
        print self.name,t
        if Runner.i<len(courier):
            activate(courier[Runner.i],courier[Runner.i].run())
            Runner.i+=1

r1=Runner(name='r1')
r2=Runner(name='r2')
r3=Runner(name='r3')
r4=Runner(name='r4')

courier=[r1,r2,r3,r4]

initialize()
activate(r1,r1.run(),at=0.0)
simulate(until=200)

When run, this yields:

r1 2
r2 0
r3 1
r4 5

So, it works.

Klaus

> -----Original Message-----
> From: simpy-users-bounces <at> lists.sourceforge.net 
> [mailto:simpy-users-bounces <at> lists.sourceforge.net] On Behalf 
> Of m.prosperi <at> libero.it
> Sent: Monday, May 21, 2007 9:14 PM
> To: simpy-users
> Subject: [Simpy-users] question on a simulation approach
> 
> 
> hi all,
> 
> in a program of mine I would find convenient a sort of 'lazy 
> activation' of processes like the one in the following script.
> 
> from SimPy.Simulation import *
> import random
> 
> 
> class Runner(Process):
>     i=1
>     def run(self):
>         t=random.randint(0,5)
>         yield hold,self, t
>         print self.name,t
>         activate(courier[self.i],courier[self.i].run())
>         self.i+=1
>         
> r1=Runner(name='r1')
> r2=Runner(name='r2')
> r3=Runner(name='r3')
> r4=Runner(name='r4')
> 
> courier=[r1,r2,r3,r4]
> 
> initialize()
> activate(r1,r1.run(),at=0.0)
> simulate(until=200)
> 
> It doesn't seem to work (either in my original program). Am I 
> missing something or is it SimPy that doesn't allow this?
> 
> Marco
> 
> 
> 
> ------------------------------------------------------
> Passa a Infostrada. ADSL e Telefono senza limiti e senza 
> canone Telecom http://click.libero.it/infostrada
> 
> 
> 
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by DB2 Express Download DB2 
> Express C - the FREE version of DB2 express and take control 
> of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Simpy-users mailing list
> Simpy-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simpy-users
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Simon Frost | 23 May 23:58
Favicon

Using new generator features in Python 2.5

Dear SimPy List,

Are there any plans to include the new generator features in Python 2.5?

http://docs.python.org/whatsnew/pep-342.html

Best
Simon

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Klaus Muller | 30 May 15:42
Picon
Picon
Favicon

Re: Using new generator features in Python 2.5

Simon,
If your question is whether there are plans to use the new (2.5) generator
features in SimPy, the answer is yes. They are very useful, e.g. the fact
that one can write "result=yield . . . " means that SimPy's yields could
return status information ("success", "failure", "timeout", . . .).

As to when the new features could be introduced, I have to  mumble a bit at
this moment. It all depends on when the SimPy community has completely gone
over to Python 2.5. We do have to worry about the installed base, so we
always trail a version or two behind. I also want to use decorators, which
means dropping support for Python version 2.3.

Klaus Müller

> -----Original Message-----
> From: simpy-users-bounces <at> lists.sourceforge.net 
> [mailto:simpy-users-bounces <at> lists.sourceforge.net] On Behalf 
> Of Simon Frost
> Sent: Wednesday, May 23, 2007 11:59 PM
> To: SimPy Users
> Subject: [Simpy-users] Using new generator features in Python 2.5
> 
> Dear SimPy List,
> 
> Are there any plans to include the new generator features in 
> Python 2.5?
> 
> http://docs.python.org/whatsnew/pep-342.html
> 
> Best
> Simon
> 
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by DB2 Express Download DB2 
> Express C - the FREE version of DB2 express and take control 
> of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Simpy-users mailing list
> Simpy-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simpy-users
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

Gmane