Klaus G. Muller | 3 Sep 15:01
Picon
Picon
Favicon

SimPy under Jython 2.5.1rc1

Hi all,
I just downloaded and installed Jython 2.5.1rc1.

Naturally, I installed and tested SimPy (2.0.1) under Jython right away.

I was pleasantly surprised: it ran all SimPy examples, with the 
exception of the SimGUI and SimPlot ones (Tkinter is not installed under 
Jython). The execution speed seems to be somewhat slower than that of 
Python 2.5. Still . . .

Has any of you worked with SimPy under Jython?

Klaus Muller

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
Klaus G. Muller | 7 Sep 12:55
Picon
Picon
Favicon

SimPy Recipe library started

All:
I have started a SimPy Recipes library on http://simpy.sourceforge.net.

At the moment, it is tiny., but it will grow with your help. You are all 
invited to contribute recipes -- you all have SimPy expertise to share, 
I am sure.

The SimPy web site describes the submission procedure and provides a 
template for recipe submissions.

Let me have your comments, PLEASE! And, above all, contribute your recipes!

Klaus Muller

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
Mike Luntz | 10 Sep 00:28

Memory usage vs simulation approach question

I am a newbie trying to learn both python and SimPy and have been
looking at some of the examples in the documentation. My question
relates to the program organization and how that affects the required
memory. In the bank09 and bank10 examples in the documentation, at a top
level the approach is to:

1. Create a customer class that services customer visits.
2 Create a source class that creates and activates each customer.
The source is activated at the start of the simulation.

If I attempt to simulate 10000 individual customer visits, there will be
10000 instances of the customer class existing at the end of the
simulation.

An alternative that I originally generated before I found the bank
example was to create a source class that generated arrivals and sent
them to a consumer class that processed them. The switching back and
forth between the 2 classes was done using passivate and reactivate. In
this approach there were only 2 instances of a class existing.

I must say that the bank example was much more straightforward to read
and understand than my initial approach, but I am wondering whether the
memory requirements are significantly greater with the bank example
approach.

Any insight into the memory requirements for these 2 approaches that
someone can give me will be much appreciated.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
(Continue reading)

James | 10 Sep 05:29

Multi class work loads across queues

I am trying to solve a problem that I have already done with PDQ but wanted to
do with SimPy just to help me better learn the package. I originally got the
problem out of "Performance By Design" (chapter 5: Case Study I: A Database
Service) and wrote up a PDQ-R solution and when I found out about SimPy I
decided to follow up with a SimPy solution.

Here is the basic scenario. I have a database server with one CPU and two hard
drives. There are three different classifications of work that occur on this
server that have their own demand on CPU and both hard drives.

My SimPy code is not matching my PDQ output and it really has wondering what I
might be doing wrong and thought that the more seasoned SimPy users might see
what I am doing wrong.

In my code I call WorkStream process for each work class that executes at the
rate passed to it.

>From inside WorkStream I make a call WorkNodes which does the individual calls
to WorkNode for the yield request/hold/release on the resource that is passed
with the call.

AFAIK the code looks good to me, but I can't put my finger on what I might be
doing wrong.

Here is the code that I am working with right now:

I'd be grateful if anybody could look over my shoulder and point out where I
might be going astray.

Thanks!
(Continue reading)

Steven H. Rogers | 10 Sep 14:53
Favicon

Re: Memory usage vs simulation approach question

On 09/09/2009 04:28 PM, Mike Luntz wrote:
> I am a newbie trying to learn both python and SimPy and have been
> looking at some of the examples in the documentation. My question
> relates to the program organization and how that affects the required
> memory. In the bank09 and bank10 examples in the documentation, at a top
> level the approach is to:
>
> 1. Create a customer class that services customer visits.
> 2 Create a source class that creates and activates each customer.
> The source is activated at the start of the simulation.
>
> If I attempt to simulate 10000 individual customer visits, there will be
> 10000 instances of the customer class existing at the end of the
> simulation.
>
> An alternative that I originally generated before I found the bank
> example was to create a source class that generated arrivals and sent
> them to a consumer class that processed them. The switching back and
> forth between the 2 classes was done using passivate and reactivate. In
> this approach there were only 2 instances of a class existing.
>
> I must say that the bank example was much more straightforward to read
> and understand than my initial approach, but I am wondering whether the
> memory requirements are significantly greater with the bank example
> approach.
>
> Any insight into the memory requirements for these 2 approaches that
> someone can give me will be much appreciated.
>
>    
(Continue reading)

Klaus G. Muller | 10 Sep 16:11
Picon
Picon
Favicon

Re: Multi class work loads across queues

James,
what exactly are the differences between the PDQ and the SimPy results??

Klasu

James wrote:
> I am trying to solve a problem that I have already done with PDQ but wanted to
> do with SimPy just to help me better learn the package. I originally got the
> problem out of "Performance By Design" (chapter 5: Case Study I: A Database
> Service) and wrote up a PDQ-R solution and when I found out about SimPy I
> decided to follow up with a SimPy solution.
>
> Here is the basic scenario. I have a database server with one CPU and two hard
> drives. There are three different classifications of work that occur on this
> server that have their own demand on CPU and both hard drives.
>
> My SimPy code is not matching my PDQ output and it really has wondering what I
> might be doing wrong and thought that the more seasoned SimPy users might see
> what I am doing wrong.
>
> In my code I call WorkStream process for each work class that executes at the
> rate passed to it.
>
> >From inside WorkStream I make a call WorkNodes which does the individual calls
> to WorkNode for the yield request/hold/release on the resource that is passed
> with the call.
>
> AFAIK the code looks good to me, but I can't put my finger on what I might be
> doing wrong.
>
(Continue reading)

Klaus G. Muller | 10 Sep 16:25
Picon
Picon
Favicon

Re: Memory usage vs simulation approach question

Mike,
there is no memory problem here: only instances of customers which are 
either queuing or being served take up memory, A customer who has 
completed his visit does not take up memory -- his instance gets garbage 
collected. I can't see a situation where 10000 customers are in the 
system simultaneously. So where is the problem?

Why do you worry about memory? The "one customer instance per customer" 
(the process-oriented approach) gives the cleanest, simplest program 
design. I suggest that you leave any memory optimization (or any other 
optimization) alone until you have a problem. Early optimization is the 
most frequent cause of programming difficulties.

Klaus

Mike Luntz wrote:
> I am a newbie trying to learn both python and SimPy and have been
> looking at some of the examples in the documentation. My question
> relates to the program organization and how that affects the required
> memory. In the bank09 and bank10 examples in the documentation, at a top
> level the approach is to:
>
> 1. Create a customer class that services customer visits.
> 2 Create a source class that creates and activates each customer.
> The source is activated at the start of the simulation.
>
> If I attempt to simulate 10000 individual customer visits, there will be
> 10000 instances of the customer class existing at the end of the
> simulation.
>
(Continue reading)

Picon

Re: Multi class work loads across queues

James wrote:
> I am trying to solve a problem that I have already done with PDQ but wanted to
> do with SimPy just to help me better learn the package. I originally got the
> problem out of "Performance By Design" (chapter 5: Case Study I: A Database
> Service) and wrote up a PDQ-R solution and when I found out about SimPy I
> decided to follow up with a SimPy solution.
...<cut>...

I have no access to the book, so I try to guess from the code.
- CPU, HD1 and HD2 subtasks are handled in parallel in your simulation,
so the response time whole task will be the maximum of any of the
subtasks( E[R]=E[max(R_CPU,R_HD1,R_HD2)] ),
- but you calculate the response time as in sequential ordering of
subtasks (E[R]=E[R_CPU]+E[R_HD1]+E[R_HD2]

Could you change

print "\tResponse Time = %0.3f"% \
     (G.CPU_R[i].mean() + G.HD1_R[i].mean() + G.HD2_R[i].mean(),)

   to

R_samples = [max(x1, x2, x3) for x1, x2, x3 in \
     zip(G.CPU_R[i].yseries(), \
         G.HD1_R[i].yseries(), \
         G.HD2_R[i].yseries())]
print "\tResponse Time = %0.3f" % sum(R_samples)/len(R_samples))

   and check with PDQ values?

(Continue reading)

Mike Luntz | 10 Sep 23:26

Re: Memory usage vs simulation approach question

Klaus,

My sincere thanks for your very informative answer. That was just the
information that I was interested in.

As I mentioned in my original post, I am just learning SimPy. My first
approach was not an attempt to optimize memory but simply a naive
approach to coding a sample problem. After seeing the different way of
approaching the same problem, I had a general question regarding memory
usage with the generation of multiple instances.

Mike

On Thu, 2009-09-10 at 16:25 +0200, Klaus G. Muller wrote:
> Mike,
> there is no memory problem here: only instances of customers which are 
> either queuing or being served take up memory, A customer who has 
> completed his visit does not take up memory -- his instance gets garbage 
> collected. I can't see a situation where 10000 customers are in the 
> system simultaneously. So where is the problem?
> 
> Why do you worry about memory? The "one customer instance per customer" 
> (the process-oriented approach) gives the cleanest, simplest program 
> design. I suggest that you leave any memory optimization (or any other 
> optimization) alone until you have a problem. Early optimization is the 
> most frequent cause of programming difficulties.
> 
> Klaus
> 
> 
(Continue reading)

Mike Luntz | 11 Sep 01:19

Re: Memory usage vs simulation approach question

Klaus,

On Aug 5 you replied to a comment stating:

All:
I would not do it this way -- it is much slower then scheduling an
event.

Klaus Muller

Michael Antonov wrote: 
> >  Is it possible to signal SimEvents at some specific time?
> 

[the rest is cut]

My question is "How does one schedule an event to occur at a specific
time?"

Mike

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

Gmane