Re: [Fwd: Re: Monitor.timeAverage() Bug]
Mark Elston <m.elston <at> advantest-ard.com>
2007-08-20 01:30:01 GMT
Tony,
What you proposed would work, I think. An alternative might be:
def timeAverage(self, t=None, tStart=None)
Here 't' behaves as it currently does; it determines the 'end' of the
time averaging period. If it is None then use 'now()'. The 'tStart'
parameter specifies the optional start time of the time averaging
period. If it is 'None' then the start is either 0 or the time of the
last reset.
This approach seems to have a simpler interface providing reasonable
default values to both the start and the end. Putting tStart at the
end of the calling sequence recognizes that it is the least likely to
be specified (most calls will start from 0). It looks a little odd
since the 'start' is specified after the 'end'. This might violate the
readability principle in PEP 08. I'll let others decide.
Mark
* Tony Vignaux wrote (on 8/19/2007 12:14 AM):
> Let us see if we can make the timeAverage call clearer -- or develop a
> better alternative. I hope this can be backward compatible as there are
> an awful lot of SimPy programs out there.
>
> currently:
>
> def timeAverage(self,t=None)
>
> if t==None, then t = now(). The time average is calculated from 0 to t,
> or from the time of the last reset to t. Thus, there is a "hidden"
> parameter, the start time.
>
> one alternative:
>
> def timeAverage(self,t=None,interval=[])
>
> Here interval is either [] or a two-element list, [tstart, tfinish]. If
> interval is not None, then it overrides t. tfinish could be None in
> which case it takes the value now()
>
>
> Any other ideas?
>
>
>
>
>
> On 8/19/07, *Mark Elston * <m.elston <at> advantest-ard.com
> <mailto:m.elston <at> advantest-ard.com>> wrote:
>
>
> On 17 Aug, Klaus Muller wrote:
> > ...
> >
> > You did not find a bug, but you misunderstood the semantics of
> > timeAverage's parameter "t". If you look at SimPy's Manual, you
> find:
> >
> > ...
> >
> > r.timeAverage([t]) the average of the time-weighted y graph,
> > calculated from time 0 (or the last time r.reset([t]) was called) to
> > time t (or to the current simulation time, now( ), if t is missing).
> > This is determined from the area under the graph shown in the figure,
> > divided by the total time of observation. For accurate time-average
> > results y most be piecewise constant and observed just after each
> > change in its value. (If there are no observations, the message
> > "SimPy: No observations for timeAverage". If no time has elapsed, the
> > message "SimPy: No elapsed time for timeAverage" is printed).
> >
> > ...
> >
> > /*r.timeAverage( )* is the time-weighted average of the observed y
> > values. Each y value is weighted by the time for which it exists. The
> > average is the area under the above curve divided by the total time,
> > t./
> >
> > So, parameter "t" is the *total* time. In your example, that is 4.0.
> > Calling timeAverage with another time value leads to the wrong
> > function value return.
>
> So, why allow any other value if it will lead to wrong results? I
> guess I also misunderstand this since the first paragraph indicates
> that this function returns the 'time-weighted graph, calculated from
> 0 ... to time t'. According to this Daniel is correct in what he
> expects to happen.
>
> I haven't seen any other explanation of what *is* returned if you pass
> in an actual value of 't'.
>
> Mark
>
>
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/