Tour of Ptolemy II
If you are viewing this from within Vergil, the graphical
editor for Ptolemy II, then
many of the following links will open models that highlight the
key features of Ptolemy II. If you are using an ordinary
web browser, then you will see the XML definition of the models.
To run the models in Vergil,
click on the red triangle in the toolbar. The
diagrams are fully editable, so feel free to explore.
You can also access the complete list of demos
. Contents:
Ptolemy II can be used to build sophisticated application domain-specific modeling capabilities
and frameworks. These frameworks can be packaged as separate executable
applications (e.g. HyVisual or VisualSense)
or accessed from within Ptolemy II. Here, we illustrate some such frameworks.
-
Stochastic hybrid systems:
Noise
(see also
IncreasingRatePoisson,
HysteresisWithRandomDelay,
Brownian
).
Stochastic hybrid systems add random behavior to continuous-time models mixed
with discrete events. The
Noise
(and Noise
Spectrum
,
Sinusoid
In Noise
) models
show bandlimited Gaussian noise processe.
IncreasingRatePoisson
models spontaneous mode transitions governed by a Poisson process.
The HysteresisWithRandomDelay
example uses similar spontaneous mode transitions to model random delay in mode transitions.
The Brownian example
models a stochastic differential equation describing a random walk process.
- Signal Processing:
MaximumEntropySpectrum
(See also
LMSAdaptive,
SynthesizedVoice,
FourierSeries, and
SoundSpectrum)
Ptolemy II includes an extensive library and models of computation suitable for
digital signal processing, communication systems design, and image and video processing.
The MaximumEntropySpectrum
example shows spectral estimation of sinusoids in noise.
It illustrates models the use of synchronous dataflow (SDF) for signal
processing, and also shows many basic capabilities like
hierarchical models,
the Expression actor, and the signal processing actor library.
A particular capability of Ptolemy II is the ability to mix models of computation.
These examples illustrate some of these capabilities.
- Modal Models:
ModalModel
A modal model is one whose behavior depends on its "mode"
of operation. A modal model in Ptolemy II heterogeneously combines the
finite state machine (FSM) domain
combined hierarchically with other models. A state in the FSM represents
a mode of operation, and can have a refinement that gives the behavior
in that mode.
The refinement can be another FSM or some other model using some other
Ptolemy domain. The ModalModel example combines DE, FSM, and SDF to model a
system where regularly sampled signals are perturbed by irregular
events in time.
- Mixed-Signal Modeling:
SigmaDelta
This example shows how to combine continuous-time modeling
with discrete-event modeling to get mixed-signal modeling.
The example models a MEMS accelerometer where a digital circuit
implements feedback control and A/D conversion (a design due to
Mark Lemkin).
(see also
Switching Continuous
)
Many common models of computation have been implemented in
Ptolemy II. This section illustrates some of them.
- Synchronous Dataflow:
Spectrum (See also
MaximumEntropySpectrum,
FourierSeries, and
SoundSpectrum)
This example shows simple spectral estimation of the product
of two sinusoids in noise. It illustrates models the use of synchronous dataflow (SDF) for signal
processing, and also shows many basic capabilities like
hierarchical models,
the Expression actor, and the signal processing actor library.
In SDF, the firing of actors is statically scheduled, and at the start of execution,
boundedness and deadlock conditions are checked.
- Continuous-Time Modeling:
Lorenz (see also
Lorenz with DifferentialSystem,
SquareWave,
Sinusoid)
This example shows a continuous-time
nonlinear feedback system that exhibits
chaotic behavior (this system is called a Lorenz attractor).
It illustrates the continuous domain,
which uses an underlying solver for ordinary differential equations
and cleanly supports mixtures of discrete events and continuous-time
signals.
- Discrete-Event Modeling:
Inspection
(see also
QueueAndServer,
Router,
and TimingParadox
).
This example shows
a famous paradox in probability called the inspection paradox.
It illustrates use of the discrete-event (DE) domain, where
events occur on a time line and are processed chronologically.
In this example, random
data stimulates a model and statistics are collected and reported
in various ways.
- Process Networks:
OrderedMerge (see also
NondeterministicMerge,
QR).
The process networks (PN) domain follows the semantics given by Kahn and MacQueen in 1977
to get processes with their own threads of control that send messages to one another
and achieve deterministic computation.
The OrderedMerge example implements an example given by Kahn and MacQueen
that calculates numbers whose prime
factors are 2, 3, and 5, only, and produces
them in an ordered sequence.
As of version 5.0, we have extended this model of computation with a
nondeterministic merge actor, illustrated in
NondeterministicMerge.
- Rendezvous:
Barrier
(see also
ResourcePool,
ResourcePool,
WriteRegulator).
- Synchronous/Reactive Modeling:
TokenRing (see also
TrafficLight and
GuardedCount).
The synchronous/reactive (SR) domain,
which is inspired by the synchronous languages Esterel, Lustre, and Signal,
realizes a concurrency model where actors react instantaneously and simultaneously
at ticks of a logical clock.
The TokenRing
example uses the fixed-point semantics of SR to arbitrate access
to a shared medium using a token-ring protocol.
Ptolemy II models are built on an underlying framework that provides a rich
set of generic capabilities that are available in all models.
This section illustrates that infrastructure.
- The Type System:
Router.
This model illustrates the very sophisticated type system
of Ptolemy II, where type constraints propagate transparently,
actors are polymorphic, and composite types such as records and
arrays are supported.
This example illustrates composite types, where records are
constructed out of tokens with various types. Here, a record
models a packet in a packet-switched network, where variable
delays may result in out-of-order arrival of packets.
- Expression Language:
Transmission.
To simplify creating new components, Ptolemy II contains a functional
expression language. The expression language is integrated with the
type system, allowing static type checking of polymorphic expressions
with few type annotations. The expression language also allows new,
encapsulated functions, called function closures, to be defined and
passed as data. This model illustrates how function closures can be
used to make models much more compact.
- Interactive Signal Plotter:
Sketch
(see also FourierSeries).
This model illustrates the use of plotter to provide input
as well as rendering output from a model. Right click and drag
on the plot to trace out a new signal. The model runs each time you
do this.
- Matlab Integration:
MatlabExpression
(see also
Matlab in Continuous).
This example uses the Matlab interface created by
Zoltan Kemenczy and Sean Simmons, of Research in Motion Ltd.,
to plot a 3-D surface. This works only if Matlab is installed locally.
-
Classes, subclasses, and inner classes:
ClassesIllustrated (see also
Noisy sinewaves
and
Rijndael Encryption
).
Actor-oriented classes, subclasses, and
inner classes with inheritance are a special feature of Ptolemy II.
They provide modularity mechanisms analogous to those of object-oriented
design, but adapted to actor-oriented design. This capability permits, for
example, defining a class of models that can have instances and subclasses.
The instances and subclasses inherit all the features of the class, and
track any changes that are made to the class.
- Model Animations:
Bouncer
(see also
AnimateVergil
).
Ptolemy II models can, while executing, control their visual rendition
in Vergil, the visual editor for Ptolemy II.
In this example, a model alters the position in the Vergil diagram
of one of its own actors.
- Statically Checked Units System:
StaticUnits
(see also
Units, the
dynamically checked units system).
This model illustrates the use of the statically
checked units system. A unit system
defines a set of interrelated dimensions and measures. For example, in
the time dimension, we might have seconds, minutes, hours, days, weeks,
and fortnights. Ptolemy II includes two experimental units systems,
one that is statically checked and one that is dynamically checked.
- Network Integration:
Networked.
This example illustrates that models may be defined in a networked,
distributed fashion.
This model contains a component that is defined on the Ptolemy project
website. When you open the model, you will be alerted to the fact
that it requires loading a model definition from a remote source.
If you agree to proceed, then you will have a model with a remotely
defined component. The component itself is at
https://ptolemy.berkeley.edu/xml/models/Waveform.xml.
You can open that definition by clicking on the hyperlink, or by
using the "Open URL" command in the File menu.
- Audio:
KarplusStrong (see also SoundSpectrum).
Ptolemy II includes actors that interface to the audio system on
the executing machine, assuming it has one.
This example shows the Karplus-Strong algorithm, which synthesizes
a musical sound that closely resembles a plucked string instrument.
It illustrates the audio capabilities of Ptolemy II.
- Python Integration:
Ptolemnizer
(see also PythonScale).
Python is a popular interpreted programming language that has
been integrated into Ptolemy II using the jython Java implementation of Python.
This example shows that use of Python to alter a string entered by the user
to modify any word that begins with "t" so that it begins with "pt".
This leverages the excellent string processing capabilities in Python.
Python can also be used to prototype
actors by defining their functionality in Python.
- Fixed-Point Arithmetic:
FixFIR
(see also
FixPoint)
Ptolemy II data types include a fixed-point data type, where
a model can explicitly control the binary representation of numbers
and the mechanisms used to handle overflow and rounding.
Ptolemy II includes several actor libraries that provide sophisticated
functions. A few of those are illustrated by the models here.