SlideShare uma empresa Scribd logo
1 de 10
Introduction:
Tortuga is a software framework for discrete event simulation in Java. A Tortuga simulation can
be written either as interacting processes or as scheduled events. A Tortuga simulation can
have thousands of entities, and can be part of a larger Java system.

Why Tortuga ?:
Tortuga utilizes a programming paradigm that greatly reduces the burden on the simulation on
developer. Tortuga treats each simulation entity as a separate thread and allows to provide a run
method. This allows the developer to focus on simulation specifics and not have to worry about
littering event handler code all over the place.
Additionally, Tortuga is well-documented, well-tested, and has held up to use in some extremely
hardcore simulations.

Programming language used:
Java

Programming structure:
Aspect oriented Programming (AOP)

I/O:
1. Object Stream
2. Character stream
3. Buffer Stream
4. Byte Stream
5. Data Stream

Discrete Event Simulation in Java:
Discrete: the state changes only at discrete instances of time (event times).

1
Why Simulate In Java?:
Commercial simulation software with graphical user interfaces for model building are excellent
for creating models with moderate complexity and where the system to be modeled is a good fit
with the tools provided. For very complex models or ones that are a poor fit with simulation
tools provided, then commercial software can bring more restrictions and problems than
advantages.
The problems with commercial simulation software start when the model builder must modify or
supplement the logic provided with the built-in objects or create entirely new objects. A
programming interface is provided for this purpose by the commercial software, but this
programming environment is by its nature quite limited. The programming language will be a
standard one such as C or Java, or worse, a subset of a standard language, but in either case the
model builder will have to write this code without the use of all the programming and debugging
tools provided with modern programming languages. This situation may be acceptable if only a
few hundred lines of code are to be written. However, if thousands of lines are required to
capture the desired level of detail in the system, then the advantages of the built-in objects and
time-keeping provided by the commercial software start to seem very minor compared to the
difficulties of developing complex software without modern programming tools.

Run-time and development environment:
Tortuga simulations run on Microsoft Windows XP and Windows Vista as well as on Linux,
Mac OS, BSD and Unix. They can also be used in an applet environment, although this typically
requires a signed applet. As part of its support for simulation, Tortuga employs tools from
aspect-oriented programming, or AOP. The use of AOP in Tortuga requires more elaborate
compilation that mere javac. This has been wrapped up in an Ant task included in tortuga.jar.
This task is the reason it is assumed Tortuga-based simulations are using Ant to build.

Tortuga Programming Paradigm:
Tortuga utilizes a programming paradigm that greatly reduces the burden on the simulation on
developer. Tortuga treats each simulation entity as a separate thread and allows to provide a run
method. This allows the developer to focus on simulation specifics and not have to worry about
2
littering event handler code all over the place. Unfortunately, this means that a Tortuga
simulation is inherently limited by the number of threads the JVM is able to support.

Author and Maintainer:
Tortuga was developed by Dr. Fred Kuhl and Dr. Richard Weatherly of The MITRE Corporation
in 2004-2006 and they continue to maintain it.

Developing simulation with Tortuga:
As part of its support for simulation, Tortuga employs tools from aspect-oriented programming,
or AOP. Simulation classes are written in standard Java. However, the use of AOP in Tortuga
requires more elaborate compilation that mere javac. This has been wrapped up in an Ant task
included in delegate.jar (Ant task is called "tortuga", not "delegate"). This task is the reason we
assume that are using Ant to build simulation.
Ensure JDK and Ant installed. Call the directory that contains simulation example_home. Use
the sample Ant script in the source tree; download it and put it in example_home. The example
script assumes
•
•

Source files are under src in example_home
Class files will go under classes in example_home

•

Place delegate.jar under lib in example_home

The script contains clean, build, and run targets. Modify the script to run main simulation class,
and run it like any Ant script.

Executing Simulation:
Once you have compiled your simulation with the Tortuga Ant task, you can execute it like any
Java program. The Tortuga library (delegate.jar) must be included on the class path. Nothing else
is required. You can use the VM command java at the command line, or you can use the java Ant
task.

Tortuga and Eclipse:
Many Java developers find an integrated development environment like Eclipse helpful. Tortuga
simulations can be developed using Eclipse. Although Tortuga employs aspects, as mentioned
above, they do not appear in user's code. Eclipse need not be aware of them. What is required is
3
that the code be built by the Tortuga Ant task. Thus to use Tortuga with Eclipse, create an Ant
script to build code with the Tortuga task, and have Eclipse use Ant when it builds code.
Eclipse makes it convenient to use Ant. Ensure build script appears in the Package Explorer.
Right-click on it and choose "Run" from the pop-up menu. Ant will be invoked with script.
One of the most powerful features of Eclipse is its debugger. When Eclipse runs an Ant script, it
runs the script by default in a separate VM, thus making it impossible to use the debugger. One
way around this is to create a run profile for the script. The profile should execute
org.apache.tools.ant.Main, with script supplied as a program argument, like -f myscript.xml.

Compatibility:
The current Tortuga release has been tested with Eclipse 3.0.2. This version of Eclipse works
without the aspect plugin, AJDT. It also works with version 1.2.0 of the plugin.

How to model:

Tortuga affords the user four mechanisms for synchronizing entities. These are
1. simulation time,
2. action methods,
3. triggers, and
4. populations.
1 . Simulation Time
The simplest means of synchronizing the behavior of entities is through simulation time. An
entity can request to be suspended until a specified interval of simulation time has gone by.
2 . Action Methods
An action method is a user-defined method on any Entity subclass that has the side effect of
resuming the execution of the entity if it was waiting. An entity invokes an action method on a
target entity to interrupt it. An action methodinvocation may cause these calls to return before the
interval of simulation time has entirely elapsed.
An action method is distinguished from other methods on an Entity subclass by its name, which
takes the form actionX, where X is one or more characters. An action method can have any
signature. Action methods are detected, and their behavior implemented, through aspect-oriented
programming (AOP). Tortuga uses AspectJ [12], a popular implementation of AOP for
Java. The application of AOP to action methods is straightforward: a single pointcut recognizes
methods on Entity subclasses whose names begin with “action”. An “after” advice informs the
executive that an action method has been invoked. While an entity is waiting for action methods,
the invocation of any action method on the entity will cause it to return from the
4
wait call. The wait call returns information that allows the entity to determine which action
method was invoked.
3 Triggers
An action method invocation represents an interruption or event exogenous to an entity. The
Tortuga mechanism for action methods allows the entity to respond to the event and to
coordinate its response with its internal events. Triggers allow entities to tie their behavior to the
state of the simulation. A user creates a trigger by creating an implementation of the Tortugasupplied Trigger abstract class. Specifically, the user implements the condition method, which
returns a boolean and represents some predicate about the simulation’s state. An entity calls
waitForActionOrTrigger, supplying a Trigger instance. The execution of the entity will be
resumed, and the wait call will return, when the Trigger’s condition method evaluates to true.

How to code:
When an Entity is playing an active role in the simulation, it will have one or more Processes
underway. When it is playing an inactive role or is temporarily dormant, it will have no Process
underway.

5
6
Tortuga Interacting Processes:
Within Tortuga framework, interacting processes are created by extending class Entity, creating
instances of those extended classes, and registering those instances with the simulation
executive. Each entity has an agenda method. The agenda iswhere simulation developers place
code to model the proactive aspects of entity behavior. The Tortuga framework provides the
usual set of services to allow an entity to sense the simulateenvironment and control the advance
of simulation time.
The simple entity depicted illustrates the major points in the control of interacting processes.
When, at time t, an instance of class MyEntity is registered with the simulation executive, the
executive invokes the agenda method. Computation at lines 3 and 4 takes place at time t. In line
4, the entity requests a delay of 5.0 simulation time units using framework method waitForTime.
Method waitForTime transfers control to the simulation executive. After simulation time
advances 5.0 time units, the executive transfers control back to line 5 where code at that point
experiences a simulation time value t + 5.0. When the agenda code is complete, control returns to
the simulation executive.
7
Simple Entity:
1 class MyEntity extends class Entity {
2 public void agenda() {
3 // time is now t
4 waitForTime(5.0);
5 // time is now t + 5.0
}
}

Waiting on Actions and Triggers:
The method waitForActionOrTrigger will return because a trigger has been satisfied, or any of
the action methods defined on the entity have been invoked, or the backstop time interval has
expired. The waitForActionOrTrigger returns a WaitResult object that can be queried to
determine the reason the method returned. Tortuga provides a tool that analyzes the user’s entity
code and generates a set of integer constants that correspond to various reasons the wait method
might have returned. This allows the user to write a clean switch statement like the following:
switch (waitForAction(4.0)) {
case actionMethodOne:
info("actionMethodOne invoked");
break;
case actionMethodTwo:
info("actionMethodTwo invoked");
break;
case WAIT_TIME_EXPIRED:
info("backstop interval expired");
break;
default:
System.out.println("Something's wrong...");
break;
}

Implementation:
Lightweight Context Switching
To minimize memory use per logical process (i.e., per simulationentity), we created a
mechanism that lets us mark a point on the execution stack (the stack of the one thread that
initiated the simulation itself), then swap logical processes in and out by copying pieces of stack
above the marked point, implementing what is commonly known as a “cactus stack”. As entity
methods execute, they push activation records onto the stack. When an entity has completed an
8
update of its state at a particular point in time, it calls one of the wait methods described earlier,
which in turn yields to the executive’s logical process. At this point, the execution stack above
the marked point is copied to a buffer, and stored with the logical process object, together with
stack pointer, instruction pointer, and registers.
Implementation of this “stack swapping” within Jikes RVM proceeded in two phases.
1. process state (storing and loading of stack segments);
2.making extensions to the garbage collection system that would enable references stored in
these dormant stack segments to be appropriately traced so that references from dormant logical
processes would not be released by the garbage collector.
The implementation of state save and restore involves a class called StackSegment; each logical
process holds a reference to a StackSegment that is used to track information about the Logical
process, including whether its state has currently been saved, andif so, a buffer that holds a copy
taken from the top of the stack of the Logical process execution context. This buffer is
dynamically sized to accommodate varying stack depths.
A StackSegmentManager maintains a list of
segments; discarded segments are removed from the list at the next garbage collection, at which
point they and associated buffers are freed. During garbage collection, an additional call is made
into the StackSegmentManager to perform a scan of segments. This involves using the garbage
collector’s normal stack scanning method for marking object and code references on a thread
stack, but modified to permit passing an offset value. The offset allows the thread scanning to
treat the saved stack buffer as if it had been moved back to its proper place on the stack during
the scan, so that addresses of object and code references can be identified and accumulated as
base registers for the garbage collector. Normal thread scanning simply uses an offset of zero.

Limitations:
•
•
•
•
•

Not yet well optimized
Takes more time to compile a large program
Byte-code interpretation is slow
Security ‘holes ’ are repeatedly found
Rapid change of tool

Platform limitations
Full environment available only for:
•
•
•

Windows 95/NT
Macintosh
Sun Solaris

Other platforms must wait for 3rd party support
9
Conclusions:
The Tortuga tool has resulted in a productive framework for simulation developers that lessens
the burden of managing synchronization in a concurrent programming domain, while avoiding
the contortions required to implement simulations in a single-threaded, event-based approach.
Through relatively small, localized additions to the Jikes RVM code, we were able to provide
specialized support for coroutines that boosted the performance of our framework to a level
suitable for large-scale simulations (hundreds of thousands to potentially millions of entities,
with concomitant high computational demands). The use of coroutines as an underlying
concurrency mechanism provides the expressive advantages of concurrency (permitting the
solution space code to reflect the problem space form), while relieving the programmer of many
concerns relating to locking and race conditions.

10

Mais conteúdo relacionado

Mais procurados

Advanced junit and mockito
Advanced junit and mockitoAdvanced junit and mockito
Advanced junit and mockitoMathieu Carbou
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAhmed Ehab AbdulAziz
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesNarendra Pathai
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Google mock training
Google mock trainingGoogle mock training
Google mock trainingThierry Gayet
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocksguillaumecarre
 
Java Concurrency Starter Kit
Java Concurrency Starter KitJava Concurrency Starter Kit
Java Concurrency Starter KitMark Papis
 
Unit5 java
Unit5 javaUnit5 java
Unit5 javamrecedu
 
Class notes(week 9) on multithreading
Class notes(week 9) on multithreadingClass notes(week 9) on multithreading
Class notes(week 9) on multithreadingKuntal Bhowmick
 
Introduction To J unit
Introduction To J unitIntroduction To J unit
Introduction To J unitOlga Extone
 
Testdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockTestdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockschlebu
 
05 junit
05 junit05 junit
05 junitmha4
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 

Mais procurados (20)

Advanced junit and mockito
Advanced junit and mockitoAdvanced junit and mockito
Advanced junit and mockito
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDD
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practices
 
J Unit
J UnitJ Unit
J Unit
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocks
 
3 j unit
3 j unit3 j unit
3 j unit
 
Java Concurrency Starter Kit
Java Concurrency Starter KitJava Concurrency Starter Kit
Java Concurrency Starter Kit
 
Unit5 java
Unit5 javaUnit5 java
Unit5 java
 
Class notes(week 9) on multithreading
Class notes(week 9) on multithreadingClass notes(week 9) on multithreading
Class notes(week 9) on multithreading
 
Introduction To J unit
Introduction To J unitIntroduction To J unit
Introduction To J unit
 
Software testing basics and its types
Software testing basics and its typesSoftware testing basics and its types
Software testing basics and its types
 
Testdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockTestdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMock
 
05 junit
05 junit05 junit
05 junit
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 

Semelhante a Tortuga-A simulation software

Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresHitendra Kumar
 
MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionNarinder Kumar
 
Multithreading
MultithreadingMultithreading
Multithreadingbackdoor
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongPROIDEA
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)Nagarajan
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answersRita Singh
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101Itiel Shwartz
 
A la découverte des google/mock (aka gmock)
A la découverte des google/mock (aka gmock)A la découverte des google/mock (aka gmock)
A la découverte des google/mock (aka gmock)Thierry Gayet
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2Techglyphs
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | javaRajesh Kumar
 
maXbox Starter 45 Robotics
maXbox Starter 45 RoboticsmaXbox Starter 45 Robotics
maXbox Starter 45 RoboticsMax Kleiner
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternNishith Shukla
 

Semelhante a Tortuga-A simulation software (20)

Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data Structures
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
MC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall sessionMC0078 SMU 2013 Fall session
MC0078 SMU 2013 Fall session
 
Multithreading
MultithreadingMultithreading
Multithreading
 
concurrency
concurrencyconcurrency
concurrency
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answers
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101
 
Java 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENTJava 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENT
 
A la découverte des google/mock (aka gmock)
A la découverte des google/mock (aka gmock)A la découverte des google/mock (aka gmock)
A la découverte des google/mock (aka gmock)
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
 
maXbox Starter 45 Robotics
maXbox Starter 45 RoboticsmaXbox Starter 45 Robotics
maXbox Starter 45 Robotics
 
Distributed Tracing
Distributed TracingDistributed Tracing
Distributed Tracing
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 

Último

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Último (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

Tortuga-A simulation software

  • 1. Introduction: Tortuga is a software framework for discrete event simulation in Java. A Tortuga simulation can be written either as interacting processes or as scheduled events. A Tortuga simulation can have thousands of entities, and can be part of a larger Java system. Why Tortuga ?: Tortuga utilizes a programming paradigm that greatly reduces the burden on the simulation on developer. Tortuga treats each simulation entity as a separate thread and allows to provide a run method. This allows the developer to focus on simulation specifics and not have to worry about littering event handler code all over the place. Additionally, Tortuga is well-documented, well-tested, and has held up to use in some extremely hardcore simulations. Programming language used: Java Programming structure: Aspect oriented Programming (AOP) I/O: 1. Object Stream 2. Character stream 3. Buffer Stream 4. Byte Stream 5. Data Stream Discrete Event Simulation in Java: Discrete: the state changes only at discrete instances of time (event times). 1
  • 2. Why Simulate In Java?: Commercial simulation software with graphical user interfaces for model building are excellent for creating models with moderate complexity and where the system to be modeled is a good fit with the tools provided. For very complex models or ones that are a poor fit with simulation tools provided, then commercial software can bring more restrictions and problems than advantages. The problems with commercial simulation software start when the model builder must modify or supplement the logic provided with the built-in objects or create entirely new objects. A programming interface is provided for this purpose by the commercial software, but this programming environment is by its nature quite limited. The programming language will be a standard one such as C or Java, or worse, a subset of a standard language, but in either case the model builder will have to write this code without the use of all the programming and debugging tools provided with modern programming languages. This situation may be acceptable if only a few hundred lines of code are to be written. However, if thousands of lines are required to capture the desired level of detail in the system, then the advantages of the built-in objects and time-keeping provided by the commercial software start to seem very minor compared to the difficulties of developing complex software without modern programming tools. Run-time and development environment: Tortuga simulations run on Microsoft Windows XP and Windows Vista as well as on Linux, Mac OS, BSD and Unix. They can also be used in an applet environment, although this typically requires a signed applet. As part of its support for simulation, Tortuga employs tools from aspect-oriented programming, or AOP. The use of AOP in Tortuga requires more elaborate compilation that mere javac. This has been wrapped up in an Ant task included in tortuga.jar. This task is the reason it is assumed Tortuga-based simulations are using Ant to build. Tortuga Programming Paradigm: Tortuga utilizes a programming paradigm that greatly reduces the burden on the simulation on developer. Tortuga treats each simulation entity as a separate thread and allows to provide a run method. This allows the developer to focus on simulation specifics and not have to worry about 2
  • 3. littering event handler code all over the place. Unfortunately, this means that a Tortuga simulation is inherently limited by the number of threads the JVM is able to support. Author and Maintainer: Tortuga was developed by Dr. Fred Kuhl and Dr. Richard Weatherly of The MITRE Corporation in 2004-2006 and they continue to maintain it. Developing simulation with Tortuga: As part of its support for simulation, Tortuga employs tools from aspect-oriented programming, or AOP. Simulation classes are written in standard Java. However, the use of AOP in Tortuga requires more elaborate compilation that mere javac. This has been wrapped up in an Ant task included in delegate.jar (Ant task is called "tortuga", not "delegate"). This task is the reason we assume that are using Ant to build simulation. Ensure JDK and Ant installed. Call the directory that contains simulation example_home. Use the sample Ant script in the source tree; download it and put it in example_home. The example script assumes • • Source files are under src in example_home Class files will go under classes in example_home • Place delegate.jar under lib in example_home The script contains clean, build, and run targets. Modify the script to run main simulation class, and run it like any Ant script. Executing Simulation: Once you have compiled your simulation with the Tortuga Ant task, you can execute it like any Java program. The Tortuga library (delegate.jar) must be included on the class path. Nothing else is required. You can use the VM command java at the command line, or you can use the java Ant task. Tortuga and Eclipse: Many Java developers find an integrated development environment like Eclipse helpful. Tortuga simulations can be developed using Eclipse. Although Tortuga employs aspects, as mentioned above, they do not appear in user's code. Eclipse need not be aware of them. What is required is 3
  • 4. that the code be built by the Tortuga Ant task. Thus to use Tortuga with Eclipse, create an Ant script to build code with the Tortuga task, and have Eclipse use Ant when it builds code. Eclipse makes it convenient to use Ant. Ensure build script appears in the Package Explorer. Right-click on it and choose "Run" from the pop-up menu. Ant will be invoked with script. One of the most powerful features of Eclipse is its debugger. When Eclipse runs an Ant script, it runs the script by default in a separate VM, thus making it impossible to use the debugger. One way around this is to create a run profile for the script. The profile should execute org.apache.tools.ant.Main, with script supplied as a program argument, like -f myscript.xml. Compatibility: The current Tortuga release has been tested with Eclipse 3.0.2. This version of Eclipse works without the aspect plugin, AJDT. It also works with version 1.2.0 of the plugin. How to model: Tortuga affords the user four mechanisms for synchronizing entities. These are 1. simulation time, 2. action methods, 3. triggers, and 4. populations. 1 . Simulation Time The simplest means of synchronizing the behavior of entities is through simulation time. An entity can request to be suspended until a specified interval of simulation time has gone by. 2 . Action Methods An action method is a user-defined method on any Entity subclass that has the side effect of resuming the execution of the entity if it was waiting. An entity invokes an action method on a target entity to interrupt it. An action methodinvocation may cause these calls to return before the interval of simulation time has entirely elapsed. An action method is distinguished from other methods on an Entity subclass by its name, which takes the form actionX, where X is one or more characters. An action method can have any signature. Action methods are detected, and their behavior implemented, through aspect-oriented programming (AOP). Tortuga uses AspectJ [12], a popular implementation of AOP for Java. The application of AOP to action methods is straightforward: a single pointcut recognizes methods on Entity subclasses whose names begin with “action”. An “after” advice informs the executive that an action method has been invoked. While an entity is waiting for action methods, the invocation of any action method on the entity will cause it to return from the 4
  • 5. wait call. The wait call returns information that allows the entity to determine which action method was invoked. 3 Triggers An action method invocation represents an interruption or event exogenous to an entity. The Tortuga mechanism for action methods allows the entity to respond to the event and to coordinate its response with its internal events. Triggers allow entities to tie their behavior to the state of the simulation. A user creates a trigger by creating an implementation of the Tortugasupplied Trigger abstract class. Specifically, the user implements the condition method, which returns a boolean and represents some predicate about the simulation’s state. An entity calls waitForActionOrTrigger, supplying a Trigger instance. The execution of the entity will be resumed, and the wait call will return, when the Trigger’s condition method evaluates to true. How to code: When an Entity is playing an active role in the simulation, it will have one or more Processes underway. When it is playing an inactive role or is temporarily dormant, it will have no Process underway. 5
  • 6. 6
  • 7. Tortuga Interacting Processes: Within Tortuga framework, interacting processes are created by extending class Entity, creating instances of those extended classes, and registering those instances with the simulation executive. Each entity has an agenda method. The agenda iswhere simulation developers place code to model the proactive aspects of entity behavior. The Tortuga framework provides the usual set of services to allow an entity to sense the simulateenvironment and control the advance of simulation time. The simple entity depicted illustrates the major points in the control of interacting processes. When, at time t, an instance of class MyEntity is registered with the simulation executive, the executive invokes the agenda method. Computation at lines 3 and 4 takes place at time t. In line 4, the entity requests a delay of 5.0 simulation time units using framework method waitForTime. Method waitForTime transfers control to the simulation executive. After simulation time advances 5.0 time units, the executive transfers control back to line 5 where code at that point experiences a simulation time value t + 5.0. When the agenda code is complete, control returns to the simulation executive. 7
  • 8. Simple Entity: 1 class MyEntity extends class Entity { 2 public void agenda() { 3 // time is now t 4 waitForTime(5.0); 5 // time is now t + 5.0 } } Waiting on Actions and Triggers: The method waitForActionOrTrigger will return because a trigger has been satisfied, or any of the action methods defined on the entity have been invoked, or the backstop time interval has expired. The waitForActionOrTrigger returns a WaitResult object that can be queried to determine the reason the method returned. Tortuga provides a tool that analyzes the user’s entity code and generates a set of integer constants that correspond to various reasons the wait method might have returned. This allows the user to write a clean switch statement like the following: switch (waitForAction(4.0)) { case actionMethodOne: info("actionMethodOne invoked"); break; case actionMethodTwo: info("actionMethodTwo invoked"); break; case WAIT_TIME_EXPIRED: info("backstop interval expired"); break; default: System.out.println("Something's wrong..."); break; } Implementation: Lightweight Context Switching To minimize memory use per logical process (i.e., per simulationentity), we created a mechanism that lets us mark a point on the execution stack (the stack of the one thread that initiated the simulation itself), then swap logical processes in and out by copying pieces of stack above the marked point, implementing what is commonly known as a “cactus stack”. As entity methods execute, they push activation records onto the stack. When an entity has completed an 8
  • 9. update of its state at a particular point in time, it calls one of the wait methods described earlier, which in turn yields to the executive’s logical process. At this point, the execution stack above the marked point is copied to a buffer, and stored with the logical process object, together with stack pointer, instruction pointer, and registers. Implementation of this “stack swapping” within Jikes RVM proceeded in two phases. 1. process state (storing and loading of stack segments); 2.making extensions to the garbage collection system that would enable references stored in these dormant stack segments to be appropriately traced so that references from dormant logical processes would not be released by the garbage collector. The implementation of state save and restore involves a class called StackSegment; each logical process holds a reference to a StackSegment that is used to track information about the Logical process, including whether its state has currently been saved, andif so, a buffer that holds a copy taken from the top of the stack of the Logical process execution context. This buffer is dynamically sized to accommodate varying stack depths. A StackSegmentManager maintains a list of segments; discarded segments are removed from the list at the next garbage collection, at which point they and associated buffers are freed. During garbage collection, an additional call is made into the StackSegmentManager to perform a scan of segments. This involves using the garbage collector’s normal stack scanning method for marking object and code references on a thread stack, but modified to permit passing an offset value. The offset allows the thread scanning to treat the saved stack buffer as if it had been moved back to its proper place on the stack during the scan, so that addresses of object and code references can be identified and accumulated as base registers for the garbage collector. Normal thread scanning simply uses an offset of zero. Limitations: • • • • • Not yet well optimized Takes more time to compile a large program Byte-code interpretation is slow Security ‘holes ’ are repeatedly found Rapid change of tool Platform limitations Full environment available only for: • • • Windows 95/NT Macintosh Sun Solaris Other platforms must wait for 3rd party support 9
  • 10. Conclusions: The Tortuga tool has resulted in a productive framework for simulation developers that lessens the burden of managing synchronization in a concurrent programming domain, while avoiding the contortions required to implement simulations in a single-threaded, event-based approach. Through relatively small, localized additions to the Jikes RVM code, we were able to provide specialized support for coroutines that boosted the performance of our framework to a level suitable for large-scale simulations (hundreds of thousands to potentially millions of entities, with concomitant high computational demands). The use of coroutines as an underlying concurrency mechanism provides the expressive advantages of concurrency (permitting the solution space code to reflect the problem space form), while relieving the programmer of many concerns relating to locking and race conditions. 10