Virgil Stokes | 4 Dec 16:26
Picon
Picon
Favicon
Gravatar

Code for a G/G/c/K queueing system

I have attached a Python file (GGcI.py) that uses SimPy to simulate a 
G/G/c/K queueing system. It could be useful for teaching/tutorial 
purposes when studying queueing systems. Any feedback (positive or 
negative) would be appreciated.

V. Stokes
"""GGcI.py

This is a SimPy implementation for a general G/G/c/K queueing system. The main
 purpose is to show how to produce a file containing state changes that occur 
 during a simulation (state transition matrix). In addition is shows how balking
 and reneging in queueing systems can be handled.

System under study
 Customers arrive at random to a c-server queueing system (bank) and have service
 times from an exponential distribution. A single FIFO queue can form when all 
 tellers (slots for resource) are busy. The number of customers in the system is
 limited to K (if BALK = True).

Note:
  1) The output file produced (ASCII format) has a default name statematrix.txt. 
     This output file can be used as input to other Python programs for additional
     processing. Example, QueueAnimatorD.py, uses this state transistion matrix to
     animate queueing systems. 
  2) Balking and reneging are allowable states. The balking rule is based on the
     the number in the system when a new customer arrives. When the number of
     customers in the system is more than LMAX_B, then balking can occur. That is,
     K = LMAX_B. Reneging will occur when the 2nd, or 3rd, or ... customer in the 
(Continue reading)

Srikanth | 21 Dec 08:00
Picon

SimPy waitevent activations

Hello,
I am a newbie user of SimPy and am new to simulation in general. I have written a small SimPy program to understand how the signalling via waitevent works. The following is the program:
#-------------------------------begin code --------------------------------------------------
from SimPy.Simulation import *

class Responder(Process) :
    def respond(self,ev):
        while True:
            print "Inside respond() of %s"%self.name
            yield waitevent,self,ev       

class Scheduler(Process):
    def schedule(self):
        resp1 = Responder("Responder 1")
        resp2 = Responder("Responder 2")
        resp3 = Responder("Responder 3")
        sig = SimEvent()
        while True:
            activate(resp1,resp1.respond(sig))
            activate(resp2,resp2.respond(sig))
            activate(resp3,resp3.respond(sig))
            sig.signal ()
            print "Sent a signal %s" %sig.name
            yield hold,self,1
       
def execute():
    print "\n"*5
    print "-"*10
    initialize()
    s = Scheduler()
    activate(s,s.schedule())
    simulate(until=1)

if __name__ == '__main__':
    execute()
#-------------------------------end code -----------------------------------------------------

For the sake of simplicity, I ran the simulation for one time click, however, the results look similar for other iterations, too.
The following is the output
#-----------------------------------begin output---------------------------------------------
Inside respond() of Responder 1
Inside respond() of Responder 1
Inside respond() of Responder 2
Inside respond() of Responder 3

Sent a signal a_SimEvent

Inside respond() of Responder 3
Inside respond() of Responder 2
Inside respond() of Responder 1

#-----------------------------------end output------------------------------------------------

My question is this: why does the process execution method (PEM) of the Responder 1 object get called twice the first time - I expected it to be called only once. Any explanation that anyone on the list can provide is greatly appreciated.
Thanks in advance.
Srikanth.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
kgmuller | 21 Dec 14:07
Picon
Picon
Favicon

Re: SimPy waitevent activations

Srikanth,
you get this from the multiple activation of the Responder processes. You should activate a Process instance only once.
 
So, here is a better structure for your test:
 
from SimPy.Simulation import *
 
class Responder(Process) :
    def respond(self,ev):
        while True:
            print "Inside respond() of %s"%self.name
            yield waitevent,self,ev
            print "%s got signal"%self.name
 
class Scheduler(Process):
    def schedule(self,ev):
 
        while True:
            ev.signal ()
            print "Sent a signal %s" %ev.name
            yield hold,self,1
 
def execute():
    print "\n"*5
    print "-"*10
    initialize()
    resp1 = Responder("Responder 1")
    resp2 = Responder("Responder 2")
    resp3 = Responder("Responder 3")
    sig = SimEvent()
    activate(resp1,resp1.respond(sig))
    activate(resp2,resp2.respond(sig))
    activate(resp3,resp3.respond(sig))
    s = Scheduler()
    activate(s,s.schedule(sig))
    simulate(until=1)
 
if __name__ == '__main__':
    execute()
When run, you get:
 
----------
Inside respond() of Responder 1
Inside respond() of Responder 2
Inside respond() of Responder 3
Sent a signal a_SimEvent
Responder 3 got signal
Inside respond() of Responder 3
Responder 2 got signal
Inside respond() of Responder 2
Responder 1 got signal
Inside respond() of Responder 1
Sent a signal a_SimEvent
Responder 1 got signal
Inside respond() of Responder 1
Responder 2 got signal
Inside respond() of Responder 2
Responder 3 got signal
Inside respond() of Responder 3
 
Which is perfectly ok.
 
Klaus

From: simpy-users-bounces <at> lists.sourceforge.net [mailto:simpy-users-bounces <at> lists.sourceforge.net] On Behalf Of Srikanth
Sent: Friday, December 21, 2007 8:01 AM
To: simpy-users <at> lists.sourceforge.net
Subject: [Simpy-users] SimPy waitevent activations

Hello,
I am a newbie user of SimPy and am new to simulation in general. I have written a small SimPy program to understand how the signalling via waitevent works. The following is the program:
#-------------------------------begin code --------------------------------------------------
from SimPy.Simulation import *

class Responder(Process) :
    def respond(self,ev):
        while True:
            print "Inside respond() of %s"%self.name
            yield waitevent,self,ev       

class Scheduler(Process):
    def schedule(self):
        resp1 = Responder("Responder 1")
        resp2 = Responder("Responder 2")
        resp3 = Responder("Responder 3")
        sig = SimEvent()
        while True:
            activate(resp1,resp1.respond(sig))
            activate(resp2,resp2.respond(sig))
            activate(resp3,resp3.respond(sig))
            sig.signal ()
            print "Sent a signal %s" %sig.name
            yield hold,self,1
       
def execute():
    print "\n"*5
    print "-"*10
    initialize()
    s = Scheduler()
    activate(s,s.schedule())
    simulate(until=1)

if __name__ == '__main__':
    execute()
#-------------------------------end code -----------------------------------------------------

For the sake of simplicity, I ran the simulation for one time click, however, the results look similar for other iterations, too.
The following is the output
#-----------------------------------begin output---------------------------------------------
Inside respond() of Responder 1
Inside respond() of Responder 1
Inside respond() of Responder 2
Inside respond() of Responder 3

Sent a signal a_SimEvent

Inside respond() of Responder 3
Inside respond() of Responder 2
Inside respond() of Responder 1

#-----------------------------------end output------------------------------------------------

My question is this: why does the process execution method (PEM) of the Responder 1 object get called twice the first time - I expected it to be called only once. Any explanation that anyone on the list can provide is greatly appreciated.
Thanks in advance.
Srikanth.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Simpy-users mailing list
Simpy-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simpy-users
kgmuller | 23 Dec 08:05
Picon
Picon
Favicon

Beta-release of SimPy version 1.9

All:
It is our pleasure to announce the beta-release of SimPy 1.9. This is for
testing only. 
SimPy 1.8 is still the stable/production version.

Please, download, test and report any problems (or maybe even positive
feedback) to this list.

This release makes improvements to event handling which should result 
in significantly shorter execution times for large models (thousands of
processes) 
and models with a high percentage of cancel and passivate statements. 

The ideas for speed improvement came from three contributors:

* Norm Matloff, (and his group of students) who, in a SimPy performance
  improvement study, proposed removing the dictionary from the event list.

* Tony Vignaux, who proposed marking and subsequently ignoring cancelled
event notices.

* Klaus Müller, who found the Python package "heapq" to give the best event
list
  handling performance for a wide range of model types.

We want to thank all the SimPy users who helped with testing and profiling
the new event handler. 1.9 would not have been possible without out you!

=============================
Release notes for SimPy 1.9
============================= 

Additions
=========

- ``start``, a new method of activating processes.

- a standard identifier, ``ACTIONS`` for Process Execution methods
  to  allows a succinct use of ``start``.

- A method returning the time-weighted variance of observations 
  has been added to classes ``Monitor`` and ``Tally``.

- ``TheBank2`` tutorial has been extended to give a model of
  ``interrupt``.

Changes to code and documentation
================================= 

- The event scheduler has been completely re-designed to speed up 
  event handling. 

- The Manual has edited  to use a more readable notation.

Repairs
=======

- The tracing of ``activate`` statements by ``SimuLationTrace.py`` 
  has been enabled again.

------------------------------------------------------------------------
(end of Release Notes)

Enjoy!

Best wishes for happy, productive SimPying in 2008!

Klaus Muller    TonyVignaux     Bob Helmbold 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane