Alexandre Gravier | 14 Nov 2011 11:27
Picon
Gravatar

Using SimPy to control an underlying process: how to call simulate() more than once?

Dear SimPy community,

I am using SimPy 2.2 with Python 2.7 to schedule the operation of a
"lower-level" simulation library that does not possess all the
necessary high-level discrete event simulation mechanisms I need. The
library that SimPy is "driving" in that way is PyNN, with several
possible neural simulation backends, but it's not relevant to my
issue.

My general issue is that I need to call PyNN.run(T) between each
closest events of Globals.allEventTimes(), in order to make the
underlying engine follow the SimPy time. Of course, all SimPy events
do trigger PyNN actions.

So I figured that I would just call "PyNN.run(peek()-now());
simulate(until=peek())" in a loop. The problem is that SimPy doesn't
allow me to resume the simulation; it seems to have called
stopSimulation (?) at the end of the first simulate(), as it says "Run
stopped at time ..." and now() does not progress.

I wrote a minimal example to show my issue. Am I doing something wrong?

Alternately, if someone else has got SimPy to control a continuous
process that requires a function call each time the simulated time
progresses, and found a clean solution, I'd be glad if you could share
it.

from SimPy.Simulation import *

class DummyProcess(Process):
(Continue reading)

Ontje Lünsdorf | 15 Nov 2011 11:30
Picon
Picon

Re: Using SimPy to control an underlying process: how to call simulate() more than once?

Hi Alexandre,

> So I figured that I would just call "PyNN.run(peek()-now());
> simulate(until=peek())" in a loop. The problem is that SimPy doesn't
> allow me to resume the simulation; it seems to have called
> stopSimulation (?) at the end of the first simulate(), as it says "Run
> stopped at time ..." and now() does not progress.
Simulation.simulate() is basically a wrapper around Simulation.step(). step 
will process the current event and return the time of next event or None if 
there isn't any. Instead of simulate(until=20) try something like this:

while True:
	next_timestamp = step()
	if next_timestamp is None or next_timestamp < 20:
		break

This loop won't stop the simulation and you can resume to step through the 
simulation later on.

Cheers,
Ontje

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
Alexandre Gravier | 16 Nov 2011 08:17
Picon
Gravatar

Re: Using SimPy to control an underlying process: how to call simulate() more than once?

Hi Ontje, thank you for the hint. I used the step() technique, as you
and Stefan advised me, and here is the full code that I end up with. I
think it may be useful to others that want to sync two simulators,
because the dirty hacks around floating point operations precision
could apply generically (although I'm sure they could be cleaner).

I hope it will help someone. It's reasonably unit-tested but there
could be bugs.

Thanks and cheers,
Alexandre

---

import pyNN.nest as pynnnimport SimPy.Simulation as sim
def optimal_rounding(timestep):
    return len(str(timestep).split('.')[1])

PYNN_TIME_STEP = pynnn.get_time_step()
PYNN_TIME_ROUNDING = optimal_rounding(PYNN_TIME_STEP)

class DummyProcess(sim.Process):
    def ACTIONS(self):
        yield sim.hold,self,0

def run_simulation(end_time = None):
    """Runs the simulation while keeping SimPy and PyNN synchronized at
    event times. Runs until no event is scheduled unless end_time is
    provided. if end_time is given, runs until end_time."""
    def run_pynn(end_t):
(Continue reading)

Neill Byrne | 22 Nov 2011 12:50
Picon

Get the average time spent waiting in a Store

Hi,
I was wondering if there was a convenient way to get the average time 
objects spent in a Store. Obviously I can get this by setting up a time 
stamp on the put and get methods, but this is cumbersome as i have many 
store items. Essentially I'm trying to find the length of time the items 
spent queueing in the Store.

Regards,
Neill

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Rachel Clarke | 1 Dec 2011 10:34
Picon

Multi process models - is there a correct approach

Hi Everyone,

I am interested in using SimPy to model a sequence of processes that take place.  The example is the sterilisation of surgical equipment. We are trying to find out the turnaround time (which we could measure), and capacity of our system (which we can't measure easily).

This is a fairly simple view of the process but it gives you the idea:

1. A pack of instruments arrives in the system at a time (given by a distribution)

2. Pack is washed (takes x minutes +- y minutes)

3. Pack is re-assembled (takes between 10-55 mins depending on complexity of pack)

4. Pack is sterilised (takes 25 mins)

5. Pack departs system

I have read through the documentation and understand the simple bank examples.  My scenario is like a customer coming into the  bank and seeing the teller at the counter, and then going to see the Bank Manager (after seeing the teller).  The Bank Manager is a different resource from the counter and has its own behaviour (and queue!).

My problem is I am not sure how to model the sequence of processes correctly. I had thought I would create a InstrumentPack class with multiple PEMs (e.g. wash, pack, sterilise) and activate the next PEM once the previous had finished but I read somewhere that a process can only have one PEM.

My resources are a dishwasher (six), some people (between two and four), and a steriliser (four).

Any pointers on the best way of doing this before I get started would be great - or to some documentation I could look at that shows this kind of model.  Apologies if the question is too basic.

Cheers,
Rachel

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
Harri Vartiainen | 1 Dec 2011 12:50
Picon
Picon
Favicon

Re: Multi process models - is there a correct approach

Why do you need multiple PEM? One method can be complex if required. If you're modifying bank example, let the source create InstrumentPacks, and instrument pack PEM contains wash, re-assembly and sterelization steps with relevant requests for dishwashers etc..
 


On Thu, Dec 1, 2011 at 11:34, Rachel Clarke <rachel <at> clarke.gen.nz> wrote:
Hi Everyone,

I am interested in using SimPy to model a sequence of processes that take place.  The example is the sterilisation of surgical equipment. We are trying to find out the turnaround time (which we could measure), and capacity of our system (which we can't measure easily).

This is a fairly simple view of the process but it gives you the idea:

1. A pack of instruments arrives in the system at a time (given by a distribution)

2. Pack is washed (takes x minutes +- y minutes)

3. Pack is re-assembled (takes between 10-55 mins depending on complexity of pack)

4. Pack is sterilised (takes 25 mins)

5. Pack departs system

I have read through the documentation and understand the simple bank examples.  My scenario is like a customer coming into the  bank and seeing the teller at the counter, and then going to see the Bank Manager (after seeing the teller).  The Bank Manager is a different resource from the counter and has its own behaviour (and queue!).

My problem is I am not sure how to model the sequence of processes correctly. I had thought I would create a InstrumentPack class with multiple PEMs (e.g. wash, pack, sterilise) and activate the next PEM once the previous had finished but I read somewhere that a process can only have one PEM.

My resources are a dishwasher (six), some people (between two and four), and a steriliser (four).

Any pointers on the best way of doing this before I get started would be great - or to some documentation I could look at that shows this kind of model.  Apologies if the question is too basic.

Cheers,
Rachel


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
Steven Kennedy | 1 Dec 2011 21:16
Picon
Gravatar

Re: Multi process models - is there a correct approach

You could also model the people as the processes, taking items from
the queues and requesting the equipment resources.

On Thu, Dec 1, 2011 at 10:50 PM, Harri Vartiainen
<harri.vartiainen <at> iki.fi> wrote:
> Why do you need multiple PEM? One method can be complex if required. If
> you're modifying bank example, let the source create InstrumentPacks, and
> instrument pack PEM contains wash, re-assembly and sterelization steps with
> relevant requests for dishwashers etc..
>
>
>
> On Thu, Dec 1, 2011 at 11:34, Rachel Clarke <rachel <at> clarke.gen.nz> wrote:
>>
>> Hi Everyone,
>>
>> I am interested in using SimPy to model a sequence of processes that take
>> place.  The example is the sterilisation of surgical equipment. We are
>> trying to find out the turnaround time (which we could measure), and
>> capacity of our system (which we can't measure easily).
>>
>> This is a fairly simple view of the process but it gives you the idea:
>>
>> 1. A pack of instruments arrives in the system at a time (given by a
>> distribution)
>>
>> 2. Pack is washed (takes x minutes +- y minutes)
>>
>> 3. Pack is re-assembled (takes between 10-55 mins depending on complexity
>> of pack)
>>
>> 4. Pack is sterilised (takes 25 mins)
>>
>> 5. Pack departs system
>>
>> I have read through the documentation and understand the simple bank
>> examples.  My scenario is like a customer coming into the  bank and seeing
>> the teller at the counter, and then going to see the Bank Manager (after
>> seeing the teller).  The Bank Manager is a different resource from the
>> counter and has its own behaviour (and queue!).
>>
>> My problem is I am not sure how to model the sequence of processes
>> correctly. I had thought I would create a InstrumentPack class with multiple
>> PEMs (e.g. wash, pack, sterilise) and activate the next PEM once the
>> previous had finished but I read somewhere that a process can only have one
>> PEM.
>>
>> My resources are a dishwasher (six), some people (between two and four),
>> and a steriliser (four).
>>
>> Any pointers on the best way of doing this before I get started would be
>> great - or to some documentation I could look at that shows this kind of
>> model.  Apologies if the question is too basic.
>>
>> Cheers,
>> Rachel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure
>> contains a definitive record of customers, application performance,
>> security threats, fraudulent activity, and more. Splunk takes this
>> data and makes sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-novd2d
>> _______________________________________________
>> Simpy-users mailing list
>> Simpy-users <at> lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/simpy-users
>>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Simpy-users mailing list
> Simpy-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simpy-users
>

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d

Gmane