HLA Support in a Discrete Event Simulation Language

  • Slides: 21
Download presentation
HLA Support in a Discrete Event Simulation Language C. D. Pham R. L. Bagrodia

HLA Support in a Discrete Event Simulation Language C. D. Pham R. L. Bagrodia RESAM laboratory Université Claude Bernard, Lyon FRANCE Department of Computer Science University of California, Los Angeles U. S. A. Di. S-RT’ 99, Greenbelt, MD. Friday, October 22 nd, 1999

Outline Overview of HLA and DES The main points for HLA integration into a

Outline Overview of HLA and DES The main points for HLA integration into a DES language An example with the Parsec language Conclusions

The HLA framework • Without simulations arecalls mostly independents The High. HLA, Level Architecture

The HLA framework • Without simulations arecalls mostly independents The High. HLA, Level Architecture for a federation ofand simulations to interoperability is not easy. achieve interoperability and reuse of software. 10 Rules for the federation and the federates behavior Federation Logical simulations real-time players simulator tools An Interface Specification Display, statistics. . . An Object Model Hardware, human-in-the loop Template real-time simulators to describe the Runtime Infrastructure (RTI) simulation Federation Management Declaration Management objects Object Management Ownership Management Time Management Data Distribution Management

HLA: How to interoperate? communication node throughput, position Real system Objects can have attributes

HLA: How to interoperate? communication node throughput, position Real system Objects can have attributes radio transmitter wired node power, frequency # links Interoperability is achieved by subscription and publication of object’s attributes between the federates in the federation execution.

HLA: Publication and Subscription • Publication of an attribute means a federate can produce

HLA: Publication and Subscription • Publication of an attribute means a federate can produce values for that attribute. • Subscription to an attribute means a federate wishes to receive values for that attribute. I can provide the position for mobile hosts Federate subscribe. Object. Class Attribute Federate Ambassador I want to know the position of all mobile hosts. Federate RTI Ambassador Federate Ambassador RTI Ambassador publish. Object. Class update. Attribute. Values start. Updates reflect. Attributes. Values RTI

HLA: Time management HLA includes advanced time management services with receive order and time

HLA: Time management HLA includes advanced time management services with receive order and time stamped messages Time-constrained 21 25 RO FEDERATE 23 RO RTI 27 29 Time-regulated 25 FEDERATE Lookahead = 2 25 Ask for time advance grant NO! 27 RO 29 RO RTI Compute a Lower Bound Time Stamp (LBTS)

Discrete Event Simulation • A model consists of simulation objects and events. • Only

Discrete Event Simulation • A model consists of simulation objects and events. • Only time stamped events are exchanged between objects. • Objects’ state can only be modified upon reception of an event and by the object itself. • Simulated time advances according to the timestamp of the processed events.

Support of HLA in a DES language Difficulties come from the differences in… •

Support of HLA in a DES language Difficulties come from the differences in… • the time management: HLA is still mainly oriented towards real-time while DES is mainly logical. • the way simulated objects interact: HLA is publication/subscription-based while DES is event -driven. BUT Easier to develop HLA compliant logical time simulators. Rapid porting of a large number of existing DES simulations into the HLA framework.

The solution adopted • All the HLA interface specification (v 1. 3) is supported:

The solution adopted • All the HLA interface specification (v 1. 3) is supported: users can call the RTI functions directly if needed. • Some RTI functions or set of functions are provided by additional high-level functions for sake of simplicity and transparency.

Time management • Logical time simulations are usually timeconstrained and time-regulated. • Time advancement

Time management • Logical time simulations are usually timeconstrained and time-regulated. • Time advancement is usually transparent in logical time simulations.

Time advance Simulated objects interact directly with the RTI but do not wait explicitly

Time advance Simulated objects interact directly with the RTI but do not wait explicitly for a time advance grant blocking function call Simulated object HLA_time. Advance. Grant. Request() Request and wait for a time advance grant using next. Event. Request. RTI

Translation of notifications • Each simulated object can not provide its own set of

Translation of notifications • Each simulated object can not provide its own set of callback functions. We use pre-defined generic callback functions. • A notification from the RTI is translated into a simulation message and sent back to the objects. – Need registration and multicast features. • Ensure that both TSO and RO messages can be mixed into the DES system. – RO messages have to be timestamped.

Differences introduced by callback messages • All messages are timestamped, even those that were

Differences introduced by callback messages • All messages are timestamped, even those that were initially of the RO type. • The handling of the callback functions is done by the object itself: – direct access to the object’s variables

Registration and callback masks • Simulated objects can register to receive a given set

Registration and callback masks • Simulated objects can register to receive a given set of notification types callback masks. RTI c 1. a 1 callback • Callback messages of a given type are multicasted to the simulated objects c 1. a 1 h reflect. Attribute. Values has subscribed to c 1. a 1 #define DECLARATION_MANAGEMENT_SET start. Registration. For. Object. Class| has registered to reflect 1 stop. Registration. For. Object. Class| 3 and discover turn. Interactions. On| turn. Interactions. Off 2 has subscribed to c 1. a 1 has registered to reflect and discover HLA_register. Entity( Receive the notification self, message reflect | discover);

Advantages of multicasting In HLA • Replicated simulated objects in a simulation Callback notifications

Advantages of multicasting In HLA • Replicated simulated objects in a simulation Callback notifications are sent on a federate basis: one notification of a given usually have identical behavior. type per federate. Not well-suited for • The multicast mechanism allows each object multiple objects simulations to take independent actions. More knowledge is put in callback • The complexity is put in the simulated functions to call the appropriate object ’s object rather than in the callback functions. processing function. Practically, there as many if statements as the number of – an object knows exactly which classes it has object ’s classes the federate has subscribed to. susbscribed to.

The PARSEC language Message-based, process-interaction approach LP are programmed as an actor or entity

The PARSEC language Message-based, process-interaction approach LP are programmed as an actor or entity all activities of an entity are initiated on message receipts An LP cannot directly modify the state of another LP Event are represented by message communications e(t, p, a): send message m(e) at time t to LP p On receiving m(e), p executes actions a change its state represented by local variables schedule events (messages) at time >=t LPs are scheduled with a large variety of algorithms Conservative with null-messages, conditional events, synchronous, optimistic and adaptive algorithms.

The pc. Hello example • Similar to the Hello. World but. . . –

The pc. Hello example • Similar to the Hello. World but. . . – Event-driven instead of time-stepped • Defines a country with a name and an initial population. • Each country publishes its name and population and subscribes to the same attributes. • The population increases periodically.

Initialization of the federate 1 2 3 4 5 6 7 8 9 10

Initialization of the federate 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 entity driver(int argc, char **argv) { rti. Amb = HLA_create. Ambassador(); RTI_RTIambassador_create. Federation. Execution( &ex, rti. Amb, "Hello. World", "hello. World. fed"); country. Id = new Country(self, argv[1], argv[2]); while (!Joined && (num. Tries++ < 20)) { RTI_RTIambassador_join. Federation. Execution( &ex, ms_rti. Amb, "USA", "Hello. World", HLACallback. Struct); HLA_enable. Time. Constrained(); HLA_enable. Time. Regulation(0. 0, 1. 0); }

Main simulation loop 94 95 96 97 98 99 100 101 102 103 104

Main simulation loop 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 receive (HLACallback m) { switch (m. type) { case discover. Object. Instance: if (m. the. Object. Class. Handle == ms_country. Type. Id) { /* creates new structures, saves the object handle */ } break; case reflect. Attribute. Values: p = Country_Find(m. the. Object. Handle); if (p) Country_Update. Remote(p. Country, m. the. Attribute. Handle. Value. Pair. Set); break; case receive. Interaction: if (m. the. Interaction. Class. Handle == ms_comm. Type. Id) Country_Update. Interaction( m. the. Parameter. Handle. Value. Pair. Set); break; . . .

Main simulation loop (con’t) 118 119 120 121 122 123 124 125 126 127

Main simulation loop (con’t) 118 119 120 121 122 123 124 125 126 127 128 129 130 case turn. Updates. On. For. Object. Instance: if (m. the. Object. Class. Handle == ms_country. Type. Id) Country_Set. Update. Control(RTI_Boolean_RTI_TRUE, m. the. Attribute. Handle. Set); break; . . . } or timeout after(0) {} /* Here we update the country state */ receive (Survey the. Survey) { Country. Update. Time(); } HLA callback messages are checked first

Conclusions • HLA support in a DES language enables a rapid development of HLA-compliant

Conclusions • HLA support in a DES language enables a rapid development of HLA-compliant logical time simulators. • We have presented some general design issues, and an implementation within the Parsec language. • Future work: more transparency regarding the time advance mechanism.