Stefan Scherfke | 2 Feb 09:32
Picon

Re: A new approach for monitoring simulation data

Hello Rayene,

Am 2010-01-20 um 12:23 schrieb Rayene Ben Rayana:
> 
> Yeah, it is ugly :)
> Does ('name', lambda: self.name) work ?

Yep, seems to work:

>>> class A(object):
   ...     foo = 3
   ... 
>>> a = A()
>>> f = lambda: a.foo
>>> f()
   3
>>> a.foo = 4
>>> f()
   4
>>> 

>>> Other things to think of :
>>> 
>>> 1. An easy way to obtain a throughput plot (delta_value/delta_time)
>>> 2. Checking if the monitored data changed since last time. If not, give the user the possibility
>>> to skip the storage of that line.
>>> 
>>> example : 
>>> Instead of :
>>> 
(Continue reading)

Rayene Ben Rayana | 2 Feb 11:00
Picon
Gravatar

Re: A new approach for monitoring simulation data

Hello Stefan,

On 2 févr. 2010, at 09:32, Stefan Scherfke wrote:

> Hello Rayene,
> 
> 
> Am 2010-01-20 um 12:23 schrieb Rayene Ben Rayana:
>> 
>> Yeah, it is ugly :)
>> Does ('name', lambda: self.name) work ?
> 
> Yep, seems to work:
> 
>>>> class A(object):
>   ...     foo = 3
>   ... 
>>>> a = A()
>>>> f = lambda: a.foo
>>>> f()
>   3
>>>> a.foo = 4
>>>> f()
>   4
>>>> 
> 
> 
>>>> Other things to think of :
>>>> 
>>>> 1. An easy way to obtain a throughput plot (delta_value/delta_time)
(Continue reading)

Stefan Scherfke | 2 Feb 12:40
Picon

Re: A new approach for monitoring simulation data

Hi Rayene,

> 
>> Maybe we can add a method like ``Monitor.last()`` which returns a tuple
>> with the last monitored values, so you can check for yourself:
>> 
>> 	if self.monitor.last() != (self.x , self.y):
>> 		self.monitor()
> 
> You don't need to add it, self.monitor[-1] will do the trick !

Nope, ``self.monitor[-1]`` will give you [y_0, y_1, ..., y_n], since 
``self.monitor`` itself is something like this:

	(
		[x_0, ..., x_n],
		[y_0, ..., y_n],
	)

To get (x_n, y_n) you need ``list(zip(self.monitor))[-1]``  (or something 
that might be more performant ;-))

Cheers,
Stefan

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
(Continue reading)

Stefan Scherfke | 2 Feb 13:33
Picon

Re: A new approach for monitoring simulation data

Hi Klaus,

Am 2010-01-20 um 15:32 schrieb Klaus G. Muller:

> Stefan, Ontje,
> a great idea, but not as a REPLACEMENT of monitors/tallies.
> 
> Here are my reasons:
> 
> 1) Simplicity
> Monitors/Tallies are easy to use, even by Python newbies. Your monitoring
> construct requires potentially advanced programming.

We thinks our Monitor is at least as easily usable as the one provided
with SimPy, but it optionally offers more advanced ways to use it for
more advanced developers. ;-)

> 2) "SimPy comes with batteries"
> SimPy Monitors/Tallies are ready-made data collection/analysis/display
> tools, out-of-the-box. Your construct requires additional tools for analysis
> and display.

Ok, if this is really important for you, Monitor/Tally cannot be replaced
by our Monitor since our focus was on removing some batteries. ;-)

But we think, you can assume that NumPy/Matplotlib/SciPy are available
on a computer used for scientific research and so we thought, we could
omit that to have less code, less bugs and less to work. :)

> 3) Internal wiring
(Continue reading)

Stefan Scherfke | 2 Feb 13:13
Picon

Re: A new approach for monitoring simulation data

Hi Klaus,

Am 2010-01-20 um 15:32 schrieb Klaus G. Muller:

> Stefan, Ontje,
> a great idea, but not as a REPLACEMENT of monitors/tallies.
> 
> Here are my reasons:
> 
> 1) Simplicity
> Monitors/Tallies are easy to use, even by Python newbies. Your monitoring
> construct requires potentially advanced programming.

We thinks our Monitor is at least as easily usable as the one provided
with SimPy, but it optionally offers more advanced ways to use it for
more advanced developers. ;-)

> 2) "SimPy comes with batteries"
> SimPy Monitors/Tallies are ready-made data collection/analysis/display
> tools, out-of-the-box. Your construct requires additional tools for analysis
> and display.

Ok, if this is really important for you, Monitor/Tally cannot be replaced
by our Monitor since our focus was on removing some batteries. ;-)

But we think, you can assume that NumPy/Matplotlib/SciPy are available
on a computer used for scientific research and so we thought, we could
omit that to have less code, less bugs and less to work. :)

> 3) Internal wiring
(Continue reading)

Ruby Stevenson | 3 Feb 22:48
Picon

process synchronization question

hi, all

I have a question on process synchronization:

two process A and B are defined, there is a one-to-one mapping between
the two: meaning one instance of A talks to one instance of B, only.

- A submitted bunch of jobs to B
- A then wait until B finishes to proceed.

What is the best way for an instance of B to notify A that the job is done?

>From what I can gather, A could define a SimEvent, and B use "signal"
method to notify A. The problem is it seems I need to encode instance
name of A (or something unique) into this event for B to precisely
signal this instance of A only, is this the case? Encoding a name then
parsing it to verify seems awkward though. Are there are better ways
of achieving this?

Thanks for help

Ruby

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
(Continue reading)

Klaus G. Muller | 9 Feb 13:14
Picon
Picon
Favicon

Re: A new approach for monitoring simulation data

Stefan,
I agree that your proposed new Monitor is powerful and very flexible to 
use. However, I don't think that it is as simple and/or intuitive as the 
Monitor now in SimPy.

Yes, numpy/scipy/matplotlib are standard fare for many scientific Python 
users. SimPy users, however, often come from the Operations Research 
side and are not necessarily experienced scientific Python users. Would 
you believe that many newbie SimPy users already have difficulties with 
SimPy installation? Expecting them to install numpy/scipy/matplotlib 
just to get SimPy going might just be to steep a learning curve.

I would be very happy if you could develop your new Monitor as an 
optional SimPy library/module and publish it, together with sufficient 
user documentation with examples. Give it a name other than Monitor, though.

Regards,

Klaus Müller

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Vivek Nallur | 10 Feb 14:06
Picon
Picon
Favicon

figure out which event signalled me

Hi,

Is it possible to figure out which event signalled a process, if it was 
doing a waitevent on a tuple of events?

So, if a process were to have in its pem, the following code:

yield, waitevent, self, (Event_A, Event_B, Event_C)
# do stuff depending on which event signalled

Using signalparam would require the process to know which event fired, 
wouldn't it?

Is there a facility in SimPy to do this, or an idiom (perhaps)?

regs
Vivek

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
Klaus G. Muller | 10 Feb 15:02
Picon
Picon
Favicon

Re: figure out which event signalled me

Hi Vivek,
yes, there is a facility, namely self.eventsFired, which returns a list 
of references to event which have been signaled. You can find it easily 
in the SimPy Cheatsheet which is part of the documentation included in 
the distribution.

Here is a script illustrating the use:

from SimPy.Simulation import *

class Firer(Process):
    def fire(self,mySignals):
        yield hold,self,10
        for s in mySignals:
            s.signal()

class Waiter(Process):
    def await(self):
        while True:
            yield waitevent,self,[aSig,bSig,cSig]
            print "time: %s event(s) fired: %s"%(now(), [x.name for x in 
self.eventsFired])

aSig = SimEvent("aSig")
bSig = SimEvent("bSig")
cSig = SimEvent("cSig")

initialize()
fa = Firer("aFirer")
activate(fa,fa.fire(mySignals=[aSig]))
(Continue reading)

Vivek Nallur | 10 Feb 18:29
Picon
Picon
Favicon

Re: figure out which event signalled me

Many thanks, Klaus! That helps greatly!

regs
Vivek

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev

Gmane