Skip to content
Romain Franceschini edited this page Apr 27, 2020 · 7 revisions

Quartz features a multiscale representation of simulated time, as described in the following paper. The approach addresses the drawbacks of fixed-point or floating-point numbers while having restrained performances penalty compared to full arbitrary-precision approaches.

Without going into too much details, the idea is that the simulator keeps a reference to a precise representation of the current simulated time while models perceive and express time relative to their associated precision level, with duration values.

A precise point in simulated time is implemented as an arbitrary-precision integer under the TimePoint class. Its main purpose is to describe event times as offsets from a common reference point and it is meant to be used internally. The modeller should not directly manipulate such values. Instead, modellers may perturbate simulated time through Duration values.

Duration

A Duration is a fixed-point time data type which encapsulates a multiplier and a precision level (a Scale value).

Models express time values relative to the current simulated time. If an event is measured from the most recent past event, a duration value can express the elapsed time since this past event. Similarly, a duration can represent a time value from the current point in simulated time to an imminent future event, a.k.a. as a planned duration.

Scale

Scale values are used to represent the precision level at which a Model is able to process inputs, as well as express the duration of its internal state. It is an approximation of the degree to which Duration values are altered.

The multiscale time representation rely on a base-1000 SI time unit, which is used to represent one scale from the next. Scale values store precision levels with a Int8 integer, which means scales can go from 1000^-128 to 1000^127. The base scale is 1000^0.

Convenient constants are defined for common scales, ranging from zepto (1000^-7) to zetta (1000^7), e.g. Scale::ZEPTO, ..., Scale::MILLI, Scale::BASE, Scale::KILO, ..., Scale::ZETTA. Otherwise, scale values can be initialized with an integer, e.g. Scale.new(-3).

Clone this wiki locally