DESMO-J Distilled
Model Implementation (2) |
||
Part 2: Classes for Dynamic Model ComponentsFor each type of dynamic model component you will have to subclass one or more of DESMO-J’s abstract component classes. Depending on the modelling style you choose this means either defining subclasses of desmoj.core.simulator.SimProcess or of desmoj.core.simulator.Entity and desmoj.core.simulator.Event. Process-interaction Approach (or Process-oriented Modelling Style)Write a subclass of desmoj.core.simulator.SimProcess for each type of dynamic model component. This comprises implementing
You may download the following process class template to aid you in building your own simulation process. package <my.package.name>; // import the DESMO-J stuff import desmoj.core.simulator.*; public class <MyComponentType> extends SimProcess { // define attributes here (optional) /** constructs a process... */ public MyComponentType(MyModel model) { super (model, "<MyComponentTypeName>", true); } /** describes this process's life cycle */ public void lifeCycle() { } // define additional methods here (optional) } /* end of process class */ Event-scheduling Approach (or Event-oriented Modelling Style)Write a subclass of desmoj.core.simulator.Entity for each type of dynamic model component. This comprises defining entity-specific attributes as class fields, implementing a constructor with a call to the constructor of Entity via super() as the first statement, and implementing additional methods if necessary. The behaviour of these dynamic model components is specified in events. Write a subclass of one of the following classes (all derived from desmoj.core.simulator.AbstractEvent)
You may download the following entity class template and event class template (here, a subclass of Event, thus accepting one entity as parameter, serves as example) to aid you in building your own entities and events. package <my.package.name>; // import the DESMO-J stuff import desmoj.core.simulator.*; public class <MyEntityType> extends Entity { // define attributes here (optional) /** constructs an entity... */ public MyEntityType(MyModel model) { super (model, "<MyEntityTypeName>", true ); } // define additional methods here (optional) } /* end of entity class */ package <my.package.name>; public class <MyEventType> extends Event<MyEntity> { // define attributes here (optional) /** constructs an event... */ public MyEventType(MyModel model) { super (model, "<MyEventTypeName>", true ); } /** describes what happens during this event */ public void eventRoutine(MyEntity who) { } // define additional methods here (optional) } /* end of event class */ |
||
http://desmoj.sourceforge.net/tutorial/distilled/3.html |