NAME
Sim - Simulator engine for discrete events
VERSION
This document describes Sim 0.03 released on 2 June, 2007.
SYNOPSIS
use Sim;
Sim->schedule(
0.2 => sub { print "Hi\n" },
0.4 => sub {
Sim->schedule(
0.5 => sub { print "Wow!\n" },
Sim->now + 0.2 => sub { print "Hello!\n" },
);
},
0.5 => sub { print "now is ", Sim->now, "\n"; },
);
Sim->run( duration => 1.0 ); # upper-limit for simulation time
# OR: Sim->run( fires => 15 ); # upper-limit for number of event fires
print "now is ", Sim->now, "\n"; # now is 0.6
DESCRIPTION
Sim is a general-purpose discrete event simulator engine written in pure Perl. It was originally developed as the run-core of a sequential/conbinational logic circuit simulator named Tesla.
The Sim class is just a static class wrapping around a Sim::Dispatcher instance and a Sim::Clock instance. I used AUTOLOAD to do the magic instead of writing a lot of boring code. It's expected that using Sim::Dispatcher directly can be a bit faster but is certainly less convenient.
If you want to use a different clock model with vectorized time read, say a [sec, delta], which is found in a lot of EDA simulators, then you should use Sim::Dispatcher instead of Sim and define your clock class yourself.
See Sim::Dispatcher for more information.
STATIC METHODS
All the methods of Sim::Dispatcher are available for this class, but they are exposed as static methods only :)
TODO
Add cookbooks for M/M/1 and M/M/m queueing problems.
Add support for vectorized timestamp (i.e. something like 3 sec + 3 * delta).
Add missing features compared to SimPy in the Python world.
BUGS
There must be some serious bugs lurking somewhere; if you find one, please consider firing off a report to http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sim.
VERSION CONTROL
You can always get the latest version of the source from the following Subversion repository:
http://svn.openfoundry.org/sim/
which has anonymous access to all.
If you do want a commit bit and become a coauthor, please let me know :)
CODE COVERAGE
I use Devel::Cover to test the code coverage of the test suite:
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
blib/lib/Sim.pm 100.0 50.0 66.7 100.0 n/a 5.7 91.7
blib/lib/Sim/Clock.pm 100.0 83.3 n/a 100.0 100.0 9.0 97.3
blib/lib/Sim/Dispatcher.pm 94.6 75.0 100.0 100.0 100.0 31.1 92.2
---------------------------- ------ ------ ------ ------ ------ ------ ------
AUTHOR
Agent Zhang <agentzh@gmail.com>
COPYRIGHT
Copyright 2006, 2007 by Agent Zhang. All rights reserved.
This library is free software; you can modify and/or modify it under the same terms as Perl itself.