modeling and simulation
modelin" rel="nofollow">ing and simulation
Order Description
DEVSJAVA
Write a DEVS model for the ?Bridge Segment? ?Besides the ?Bridge Segment? atomic model, also write two ?car generator? atomic models (one to generate cars comin" rel="nofollow">ing from
the west, and the other to generate cars comin" rel="nofollow">ing from the east), and then couple the three models togetherto test your ?Bridge Segment? model.?Fin" rel="nofollow">inally, couple the car
generators and the three ?Bridge Segments? as shown below to form a traffic system. (Assumethe roadsegments between two bridge segments have zero travel time and
in" rel="nofollow">infin" rel="nofollow">inite capacity.)?You need to package all your source code in" rel="nofollow">into a package hierarchy named ?Homework2016.BridgeSegment.XXX?, where XXX is your first name in" rel="nofollow">initial plus
last name.For example, if your name is Peisheng Wu, the package name should be Homework2016.BridgeSegment.PWu. Note that to make the package work, you will need to
create a directory Homework2016, and then a directory BridgeSegment under Homework2016, and then PWuunder BridgeSegment.?Besides the source code, each student also
needs to turn in" rel="nofollow">in a document (no more than two pages) to describe the design of your ?Bridge Segment? model. This should cover the basic logic of your deltext(),
deltin" rel="nofollow">int(), deltcon(), and out()functions. Your description can be anin" rel="nofollow">informal English description of themodel design, or a state diagram (similar to those in" rel="nofollow">in the DEVS
class slides)with explanations. We will use this document to help gradin" rel="nofollow">ing your model. Note that a formalanddetaileddescription of the model behavior is not needed
because we already have your source code. Place the model description document in" rel="nofollow">inside your source code directory.?Turn in" rel="nofollow">in your DEVSJAVA code and documents
throughiCollage. You should compress all your filesby zippin" rel="nofollow">ing your source code directory (e.g., the directoryof PWu in" rel="nofollow">in the above example) and upload it with a sin" rel="nofollow">ingle
zip file. (in" rel="nofollow">includin" rel="nofollow">ing a brief explanation of the design of the model and a live demo of the model).
More in" rel="nofollow">information:Two Approaches1.Model the traffic light and bridge segment together.2.Model the traffic light separately. In this case, each bridge segment is a
coupled model with a bridgeSegment and a traffic light. If you like, you may program your logic in" rel="nofollow">in a stepwise fashion(your fin" rel="nofollow">inal code should fin" rel="nofollow">inish step2):1.Step 1: As
long as the traffic light is green, a vehicle can move ahead. If the traffic light changes to red when a car is still on the bridge, the cars on the other direction
should wait until this car fin" rel="nofollow">inishes.2.Step 2: A vehicle can go through the green traffic light only when at least 10 seconds is left before the traffic light changes
to red.
Additional Requirementsof HW1:1.Download ?Homework2016.BridgeSegment?package, which contain" rel="nofollow">ins 4classes:?AbstractBridgeSystem??CarGenerator??Transducer? ?Test?Put them
to ?src/Homework2016/BridgeSegment/?In ?AbstractBridgeSystem?, the TAhas already implemented some codefor car generation and resultmain" rel="nofollow">intenance. You have to use it
(seein" rel="nofollow">instructions below), and you must not modify it, or the gradin" rel="nofollow">ing code maynotrecognize your code.2.When buildin" rel="nofollow">ing your bridge systemcoupled model, in" rel="nofollow">instead of
extendin" rel="nofollow">ing ?ViewableDigraph?, extend ?AbstractBridgeSystem?3.Use ?AbstractBridgeSystem.westCarGenerator? and ?AbstractBridgeSystem.eastCarGenerator? as your two car
generators on the west and on the east. E.g.://...// when you need to use the 2 generators, use them directly, and DO NOT create your own add
(this.westCarGenerator);add(this.eastCarGenerator);addCouplin" rel="nofollow">ing(westCarGenerator,"out",bridgeSegment3,"westbound_in" rel="nofollow">in");addCouplin" rel="nofollow">ing
(eastCarGenerator,"out",bridgeSegment1,"eastbound_in" rel="nofollow">in");//...Note: The above sample code shows how to use the two car generators. You should modify the code accordin" rel="nofollow">ingly
based on your own models. However, when you use car generators, use westCarGenerator and eastCarGenerator from AbstractBridgeSystem. The bridgeSegment3,
bridgeSegment2, bridgeSegment1 are the three bridge segmentsfrom west to east, respectively.The westCarGenerator generates cars drivin" rel="nofollow">ing from west toeast, so connect it
with your bridgeSegment3. 4.For each bridge, you need to set the ?in" rel="nofollow">initial state?and its ?traffic light duration time?accordin" rel="nofollow">ing to the globalsettin" rel="nofollow">ing class in" rel="nofollow">in
AbstractBridgeSystem:publicstaticclassBridgeSystemSettin" rel="nofollow">ing{//Bridge1, the east most onepublicstaticBridgeState
Bridge1InitialState;publicstaticdoubleBridge1TrafficLightDurationTime;// Bridge2, the middle onepublicstaticBridgeState
Bridge2InitialState;publicstaticdoubleBridge2TrafficLightDurationTime;// Bridge3, the west most onepublicstaticBridgeState
Bridge3InitialState;publicstaticdoubleBridge3TrafficLightDurationTime;}The sample code below illustrateshow you may use the global settin" rel="nofollow">ing in" rel="nofollow">in the in" rel="nofollow">initialize() of a
bridgeSegement:if(AbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge3InitialState==AbstractBridgeSystem.BridgeState.WEST_TO_EAST)holdIn(?westToEastGreen?,
AbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge3TrafficLightDurationTime);
5.Couple each bridge segment?s west output port and east output port to the transducer (provided by the AbstractBridgeSystem)?s in" rel="nofollow">input ports as illustrated below: add
(this.transduser);addCouplin" rel="nofollow">ing(bridgeSegment1, "eastbound_out", this.transduser, "Bridge1_EastOut");addCouplin" rel="nofollow">ing(bridgeSegment1, "westbound_out", this.transduser,
"Bridge1_WestOut");addCouplin" rel="nofollow">ing(bridgeSegment2, "eastbound_out", this.transduser, "Bridge2_EastOut");addCouplin" rel="nofollow">ing(bridgeSegment2, "westbound_out", this.transduser,
"Bridge2_WestOut");addCouplin" rel="nofollow">ing(bridgeSegment3, "eastbound_out", this.transduser, "Bridge3_EastOut");addCouplin" rel="nofollow">ing(bridgeSegment3, "westbound_out", this.transduser,
"Bridge3_WestOut");where bridgeSegment3,bridgeSegment2,bridgeSegment1are the three bridge segmentsfrom west to east, respectively. How the TA may test your modelUse
the?Test.java?:publicstaticvoidmain" rel="nofollow">in(Strin" rel="nofollow">ing[] args){// Set the in" rel="nofollow">initial states for the systemAbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge3InitialState=
AbstractBridgeSystem.BridgeState.WEST_TO_EAST; // the westmost bridgeAbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge3TrafficLightDurationTime=
200;AbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge2InitialState= AbstractBridgeSystem.BridgeState.WEST_TO_EAST; // the middle
bridgeAbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge2TrafficLightDurationTime= 200;AbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge1InitialState=
AbstractBridgeSystem.BridgeState.WEST_TO_EAST; // the eastmost bridgeAbstractBridgeSystem.BridgeSystemSettin" rel="nofollow">ing.Bridge1TrafficLightDurationTime= 200;// Create a bridge
system objectBridgeSystem sys = newBridgeSystem("a_bridge_system"); // change it to your bridge system class// Simulate the systemcoordin" rel="nofollow">inator r = new coordin" rel="nofollow">inator
(sys);r.in" rel="nofollow">initialize();System.out.prin" rel="nofollow">intln("Simulation started");r.simulate(100);System.out.prin" rel="nofollow">intln("Simulation fin" rel="nofollow">inished");// Show resultssys.prin" rel="nofollow">intResults();}After
executin" rel="nofollow">ing it, the simulation should prin" rel="nofollow">intoutputs similar as below:Simulation startedSimulation fin" rel="nofollow">inishedEvent number: 21WestGen_Car0 exits from BridgeSegment3 at
24.47212428641887WestGen_Car0 exits from BridgeSegment2 at 34.472124286418875WestGen_Car0 exits from BridgeSegment1 at 44.472124286418875WestGen_Car1 exits from
BridgeSegment3 at 61.79186369796051WestGen_Car1 exits from BridgeSegment2 at 71.79186369796051WestGen_Car1 exits from BridgeSegment1 at 81.79186369796051WestGen_Car2
exits from BridgeSegment3 at 95.11551765680146WestGen_Car2 exits from BridgeSegment2 at 105.11551765680146