Skip to content
Snippets Groups Projects
Commit fe3c1937 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

rename for consistency, simple cleanups

parent 510890e4
No related branches found
No related tags found
No related merge requests found
package SimkitOpenDis7Examples;
import edu.nps.moves.dis7.enumerations.DisPduType;
import edu.nps.moves.dis7.pdus.EntityStatePdu;
import edu.nps.moves.dis7.utilities.DisChannel;
import edu.nps.moves.dis7.utilities.PduFactory;
import simkit.Priority;
import simkit.SimEntityBase;
import simkit.random.RandomVariate;
/**
* Simple Server component. Instances of this class cannot be used on their own,
* but require another SimEntity to schedule Arrival events. If it is desired to
* listen to an event of another name,use an Adapter instance.
*
* The StartService is schedule with a positive priority, which will ensure it
* will occur ahead of any simultaneously scheduled Arrival events, as long as
* they have the default priority of 0.0.
*
* @author abuss@nps.edu
*/
public class SimpleServerOpenDis7 extends SimEntityBase
{
// Utility constructor method: initial descriptor and verboseness of disNetworkInterface, pduRecorder
private final DisChannel disChannel = new DisChannel("TwoCraneBerthsOpenDis7", false, true);
PduFactory pduFactory = new PduFactory();
EntityStatePdu espduCrane = (EntityStatePdu) pduFactory.createPdu(DisPduType.ENTITY_STATE);
/**
* Total number of servers
*/
private int totalNumberServers;
/**
* Generates service times
*/
private RandomVariate serviceTimeGenerator;
/**
* number of available servers at any time
*/
protected int numberAvailableServers;
/**
* number in queue at any time
*/
protected int numberInQueue;
/**
* Number customers served
*/
protected int numberServed;
/**
* Zero-argument constructor
*/
public SimpleServerOpenDis7() {
}
/**
* Creates a new instance of SimpleServer with the given parameters
*
* @param totalNumberServers Total number of servers
* @param serviceTimeGenerator Service time generator. Must be RandomVariate
* instance that only generates non-negative values.
*/
public SimpleServerOpenDis7(int totalNumberServers, RandomVariate serviceTimeGenerator) {
setTotalNumberServers(totalNumberServers);
setServiceTimeGenerator(serviceTimeGenerator);
}
/**
* Set numberAvailable servers to total number servers, numberInQueue to 0,
* numberServed to 0.
*/
@Override
public void reset() {
super.reset();
numberInQueue = 0;
numberAvailableServers = totalNumberServers;
numberServed = 0;
}
/**
* Just fires PropertyChange events
*/
public void doRun() {
firePropertyChange("numberInQueue", getNumberInQueue());
firePropertyChange("numberAvailableServers", getNumberAvailableServers());
firePropertyChange("numberServed", getNumberServed());
}
/**
* Increment number in queue. If a server is available, schedule
* StartService immediately with priority of 1.0
*/
public void doArrival() {
int oldNumberInQueue = numberInQueue;
numberInQueue = numberInQueue + 1;
firePropertyChange("numberInQueue", oldNumberInQueue, getNumberInQueue());
if (getNumberAvailableServers() > 0) {
waitDelay("StartService", 0.0, Priority.HIGH);
}
}
/**
* Decrement numberInQueue and numberAvailableServers Schedule EndService
* after service time delay
*/
public void doStartService() {
int oldNumberInQueue = numberInQueue;
numberInQueue = numberInQueue - 1;
firePropertyChange("numberInQueue", oldNumberInQueue, numberInQueue);
int oldNumberAvailableServers = numberAvailableServers;
numberAvailableServers = numberAvailableServers - 1;
firePropertyChange("numberAvailableServers", oldNumberAvailableServers, numberAvailableServers);
// double serviceTime = getServiceTimeGenerator().generate();
// firePropertyChange("serviceTime", serviceTime);
waitDelay("EndService", serviceTimeGenerator);
}
/**
* Increment numberAvailableServers If customers in queue, schedule
* StartService immediately with HIGH priority
*/
public void doEndService() {
int oldNumberAvailableServers = numberAvailableServers;
numberAvailableServers = numberAvailableServers + 1;
firePropertyChange("numberAvailableServers", oldNumberAvailableServers, numberAvailableServers);
int oldNumberServed = numberServed;
numberServed = numberServed + 1;
firePropertyChange("numberServed", oldNumberServed, numberServed);
if (getNumberInQueue() > 0) {
waitDelay("StartService", 0.0, Priority.HIGH);
}
}
/**
* accessor method to get a state variable
* @return the numberAvailableServers
*/
public int getNumberAvailableServers() {
return numberAvailableServers;
}
/**
* accessor method to get a state variable
* @return the numberInQueue
*/
public int getNumberInQueue() {
return numberInQueue;
}
/**
* accessor method to set a state variable
* @param totalNumberServers total number of servers
* @throws IllegalArgumentException if totalNumberServers < 0
*/
public void setTotalNumberServers(int totalNumberServers) {
if (totalNumberServers <= 0) {
throw new IllegalArgumentException("Need positive number of servers: " + totalNumberServers);
}
this.totalNumberServers = totalNumberServers;
}
/**
* accessor method to get a state variable
* @return the serviceTimeGenerator
*/
public RandomVariate getServiceTimeGenerator() {
return this.serviceTimeGenerator;
}
/**
* accessor method to set a state variable
* @param serviceTimeGenerator the serviceTimeGenerator to set
*/
public void setServiceTimeGenerator(RandomVariate serviceTimeGenerator) {
this.serviceTimeGenerator = serviceTimeGenerator;
}
/**
* accessor method to get a state variable
* @return the totalNumberServers
*/
public int getTotalNumberServers() {
return this.totalNumberServers;
}
/**
* accessor method to get a state variable
* @return the numberServed
*/
public int getNumberServed() {
return this.numberServed;
}
}
...@@ -26,7 +26,10 @@ import simkit.SimEntityBase; ...@@ -26,7 +26,10 @@ import simkit.SimEntityBase;
public class TwoCraneBerthsOpenDis7 extends SimEntityBase public class TwoCraneBerthsOpenDis7 extends SimEntityBase
{ {
// Utility constructor method: initial descriptor and verboseness of disNetworkInterface, pduRecorder // Utility constructor method: initial descriptor and verboseness of disNetworkInterface, pduRecorder
private final DisChannel disChannel = new DisChannel("TwoCraneBerthsOpenDis7", false, true); private final DisChannel disChannel = new DisChannel("TwoCraneBerthsOpenDis7", false, true);
PduFactory pduFactory = new PduFactory();
EntityStatePdu espduCrane = (EntityStatePdu) pduFactory.createPdu(DisPduType.ENTITY_STATE);
/** /**
* Queue of Ships waiting to go into the berth * Queue of Ships waiting to go into the berth
...@@ -76,10 +79,10 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase ...@@ -76,10 +79,10 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase
/** /**
* Only PropertyChangeEvents * Only PropertyChangeEvents
*/ */
public void doRun() { public void doRun()
disChannel.setVerboseComments(true); {
disChannel.setVerboseComments(true); disChannel.setVerboseComments(true);
// TODO what is happening? not seen in logs... disChannel.setVerboseDisNetworkInterface(true);
firePropertyChange("queue", getQueue()); firePropertyChange("queue", getQueue());
firePropertyChange("berth", getBerth()); firePropertyChange("berth", getBerth());
...@@ -209,9 +212,6 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase ...@@ -209,9 +212,6 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase
waitDelay("EndUnloadingOneCrane", ship.getRemainingUnloadingTime(), ship); waitDelay("EndUnloadingOneCrane", ship.getRemainingUnloadingTime(), ship);
} }
// can be member variables (for efficiency, move above) or else embdedded within method (move below)
PduFactory pduFactory = new PduFactory();
EntityStatePdu espduCrane = (EntityStatePdu) pduFactory.createPdu(DisPduType.ENTITY_STATE);
/** /**
* Perform crane container unloading operations and send PDUs to report progress * Perform crane container unloading operations and send PDUs to report progress
...@@ -272,7 +272,7 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase ...@@ -272,7 +272,7 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase
espduCrane.setEntityLocation(pierDistanceForCraneOffload, 0.0, 0.0); espduCrane.setEntityLocation(pierDistanceForCraneOffload, 0.0, 0.0);
disChannel.sendSinglePdu(disTimeStamp, espduCrane); disChannel.sendSinglePdu(disTimeStamp, espduCrane);
disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO,
"Crane at position " + pierDistanceForCraneOffload + "m for offload after " + craneTravelDuration + " seconds"); "Crane moved to position " + pierDistanceForCraneOffload + "m for offload after " + craneTravelDuration + " seconds");
// 4. repeat until done: Crane rotates, lift container, rotates, lower container // 4. repeat until done: Crane rotates, lift container, rotates, lower container
for (int containerIndex = 1; containerIndex <= numberContainers; containerIndex++) for (int containerIndex = 1; containerIndex <= numberContainers; containerIndex++)
...@@ -281,14 +281,15 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase ...@@ -281,14 +281,15 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase
double craneRotationDelay = 90.0 / craneRotationRate; // units analysis: degrees / (degrees/second) = seconds double craneRotationDelay = 90.0 / craneRotationRate; // units analysis: degrees / (degrees/second) = seconds
espduCrane.setEntityOrientation(orientationToShip); espduCrane.setEntityOrientation(orientationToShip);
disChannel.sendSinglePdu(disTimeStamp, espduCrane); disChannel.sendSinglePdu(disTimeStamp, espduCrane);
disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Crane oriented to ship after " + craneRotationDelay + " seconds"); disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Crane oriented to ship after " + craneRotationDelay + " seconds" +
" with craneRotationRate=" + craneRotationRate + " degrees/second");
// // 4.b announce next step without further delay, then perform container hookup // // 4.b announce next step without further delay, then perform container hookup
disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Hooking up Container " + containerIndex + " to crane "); // TODO + whichCrane disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Hooking up Container " + containerIndex + " to crane has started..."); // TODO + whichCrane
disTimeStamp += containerHookupDuration; disTimeStamp += containerHookupDuration;
// disChannel.sendSinglePdu(disTimeStamp, espduCrane); // superfluous, crane hasn't moved // disChannel.sendSinglePdu(disTimeStamp, espduCrane); // superfluous, crane hasn't moved
disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Hooked up: Container " + containerIndex + " to crane " // TODO + whichCrane disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Hooked up: Container " + containerIndex + " to crane" // TODO + whichCrane
+ " after " + craneRotationDelay + " seconds"); + " after " + craneRotationDelay + " seconds");
// 4.c crane rotates to pier // 4.c crane rotates to pier
...@@ -296,12 +297,12 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase ...@@ -296,12 +297,12 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase
espduCrane.setEntityOrientation(orientationToPier); espduCrane.setEntityOrientation(orientationToPier);
disChannel.sendSinglePdu(disTimeStamp, espduCrane); disChannel.sendSinglePdu(disTimeStamp, espduCrane);
disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Crane oriented to pier after " + craneRotationDelay + " seconds" + disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Crane oriented to pier after " + craneRotationDelay + " seconds" +
" (" + craneRotationRate + " degrees/second)"); " with craneRotationRate=" + craneRotationRate + " degrees/second");
// 4.d crane unhooks container // 4.d crane unhooks container
disTimeStamp += containerDetachDuration; disTimeStamp += containerDetachDuration;
// disChannel.sendSinglePdu(disTimeStamp, espduCrane); // superfluous, crane hasn't moved // disChannel.sendSinglePdu(disTimeStamp, espduCrane); // superfluous, crane hasn't moved
disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Detached: Container " + containerIndex + " on pier" // TODO + whichCrane disChannel.sendCommentPdu(disTimeStamp, VariableRecordType.CARGO, "Crane detached: Container " + containerIndex + " on pier" // TODO + whichCrane
+ " after " + containerDetachDuration + " seconds"); + " after " + containerDetachDuration + " seconds");
// send PDUs accordingly // send PDUs accordingly
......
...@@ -36,14 +36,15 @@ public class RunSimpleServer ...@@ -36,14 +36,15 @@ public class RunSimpleServer
* Run a simple program and compute statistical measurement of results. * Run a simple program and compute statistical measurement of results.
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String args[]) { public static void main(String args[])
String rvName = "Uniform"; {
String rvName = "Uniform"; // TODO is enumeration available?
double lower = 0.9; double lower = 0.9;
double upper = 2.2; double upper = 2.2;
RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(rvName, lower, upper); RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(rvName, lower, upper);
ArrivalProcess arrival = new ArrivalProcess(interarrivalTimeGenerator); ArrivalProcess arrival = new ArrivalProcess(interarrivalTimeGenerator);
rvName = "Gamma"; rvName = "Gamma"; // TODO is enumeration available?
double alpha = 1.7; double alpha = 1.7;
double beta = 1.8; double beta = 1.8;
......
...@@ -53,13 +53,13 @@ public class RunSimpleServerOpenDis7 ...@@ -53,13 +53,13 @@ public class RunSimpleServerOpenDis7
RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(rvName, lower, upper); RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(rvName, lower, upper);
ArrivalProcessOpenDis7 arrival = new ArrivalProcessOpenDis7(interarrivalTimeGenerator); ArrivalProcessOpenDis7 arrival = new ArrivalProcessOpenDis7(interarrivalTimeGenerator);
rvName = "Gamma"; rvName = "Gamma"; // TODO is enumeration available?
double alpha = 1.7; double alpha = 1.7;
double beta = 1.8; double beta = 1.8;
RandomVariate serviceTimeGenerator = RandomVariateFactory.getInstance(rvName, alpha, beta); RandomVariate serviceTimeGenerator = RandomVariateFactory.getInstance(rvName, alpha, beta);
int numServ = 2; int numServ = 1;
SimpleServerOpenDis7 server = new SimpleServer(numServ, serviceTimeGenerator); SimpleServerOpenDis7 server = new SimpleServerOpenDis7(numServ, serviceTimeGenerator);
arrival.addSimEventListener(server); arrival.addSimEventListener(server);
SimplePropertyDumper simplePropertyDumper = new SimplePropertyDumper(); SimplePropertyDumper simplePropertyDumper = new SimplePropertyDumper();
......
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=SimkitOpenDis7Examples/run/RunSimpleServerOpenDis7.java -Drun.class=SimkitOpenDis7Examples.run.RunSimpleServerOpenDis7 run-single ant -f C:\\x3d-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=SimkitOpenDis7Examples/run/RunSimpleServerOpenDis7.java -Drun.class=SimkitOpenDis7Examples.run.RunSimpleServerOpenDis7 run-single
init: init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties Deleting: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar: deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties Updating property file: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes Compiling 1 source file to C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
warning: [options] system modules path not set in conjunction with -source 17
1 warning
compile-single: compile-single:
run-single: run-single:
[DisChannel] thisHostName=IT160907-UWALPP [DisChannel] thisHostName=IT160907-INFLPP
[DisThreadedNetworkInterface] using network interface PANGP Virtual Ethernet Adapter [DisThreadedNetworkInterface] using network interface Intel(R) Wi-Fi 6E AX210 160MHz
[DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete. [DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete.
[DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true [DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true
[DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true [DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true
[DisChannel] Network confirmation: address=239.1.2.3 port=3000 [DisChannel] Network confirmation: address=239.1.2.3 port=3000
[DisChannel] Beginning pdu save to directory ./pduLog [DisChannel] Beginning pdu save to directory ./pduLog
[PduRecorder] Recorder log file open: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog [PduRecorder] Recorder log file open: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog22.dislog
[DisThreadedNetworkInterface] using network interface PANGP Virtual Ethernet Adapter [DisThreadedNetworkInterface] using network interface Intel(R) Wi-Fi 6E AX210 160MHz
[DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete. [DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete.
[DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true [DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true
[DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true [DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true
...@@ -23,18 +25,19 @@ run-single: ...@@ -23,18 +25,19 @@ run-single:
[DisThreadedNetworkInterface DisChannel] [sending 1] DisPduType 22 COMMENT, size 80 bytes) [DisThreadedNetworkInterface DisChannel] [sending 1] DisPduType 22 COMMENT, size 80 bytes)
[DisThreadedNetworkInterface DisChannel] [receipt 1] DisPduType 22 COMMENT, size 80 bytes) [DisThreadedNetworkInterface DisChannel] [receipt 1] DisPduType 22 COMMENT, size 80 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 1] DisPduType 22 COMMENT, size 80 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 1] DisPduType 22 COMMENT, size 80 bytes)
[DisChannel] *** [CommentPdu narrative sent: OTHER] [ArrivalProcessOpenDis7 initialized] [DisChannel] *** [CommentPdu OTHER] [ArrivalProcessOpenDis7 initialized]
[DisChannel] thisHostName=IT160907-INFLPP
ArrivalProcessOpenDis7.1 ArrivalProcessOpenDis7.1
interarrivalTimeGenerator = Uniform (0.900, 2.200) interarrivalTimeGenerator = Uniform (0.900, 2.200)
SimpleServer.2 SimpleServerOpenDis7.2
totalNumberServers = 2 totalNumberServers = 1
serviceTimeGenerator = Gamma (1.700, 1.800) serviceTimeGenerator = Gamma (1.700, 1.800)
Simulation ended at time 100,000.000 Simulation ended at time 100,000.000
There have been 64,475 arrivals There have been 64,526 arrivals
There have been 64,472 customers served There have been 32,790 customers served
Average number in queue 15.9655 Average number in queue 15912.7375
Average utilization 0.9819 Average utilization 1.0000
Execution complete. Execution complete.
*** setKillSentinelAndInterrupts() killed=true sendingThread.isInterrupted()=true receiveThread.isInterrupted()=true *** setKillSentinelAndInterrupts() killed=true sendingThread.isInterrupted()=true receiveThread.isInterrupted()=true
[DisThreadedNetworkInterface PduRecorder] close(): pdus2send.size()=0 baos.size()=0 dos.size()=0 [DisThreadedNetworkInterface PduRecorder] close(): pdus2send.size()=0 baos.size()=0 dos.size()=0
...@@ -43,5 +46,11 @@ Execution complete. ...@@ -43,5 +46,11 @@ Execution complete.
*** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true *** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true
*** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false *** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false
PduRecorder.stop() closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog PduRecorder.stop() closing recorder log file: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog22.dislog
BUILD SUCCESSFUL (total time: 5 seconds) *** setKillSentinelAndInterrupts() killed=true sendingThread.isInterrupted()=true receiveThread.isInterrupted()=true
[DisThreadedNetworkInterface DisChannel] close(): pdus2send.size()=0 baos.size()=0 dos.size()=80
[DisThreadedNetworkInterface DisChannel] datagramSocket.leaveGroup address=239.1.2.3 port=3000 isClosed()=true close() complete.
*** killThread() status: sendingThread.isAlive()=false sendingThread.isInterrupted()=true
*** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true
*** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false
BUILD SUCCESSFUL (total time: 10 seconds)
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=SimkitOpenDis7Examples/run/RunTwoCranesBerth.java -Drun.class=SimkitOpenDis7Examples.run.RunTwoCranesBerth run-single ant -f C:\\x3d-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=SimkitOpenDis7Examples/run/RunTwoCraneBerths.java -Drun.class=SimkitOpenDis7Examples.run.RunTwoCraneBerths run-single
init: init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties Deleting: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar: deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties Updating property file: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes Compiling 1 source file to C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
warning: [options] system modules path not set in conjunction with -source 17
1 warning
compile-single: compile-single:
run-single: run-single:
ShipArrivalProcess.1 ShipArrivalProcess.1
...@@ -20,4 +22,4 @@ Average # in queue: 0.6834 ...@@ -20,4 +22,4 @@ Average # in queue: 0.6834
Average # busy berths: 1.1737 Average # busy berths: 1.1737
Average time in system: 1.3207 Average time in system: 1.3207
Average delay in queue: 0.4857 Average delay in queue: 0.4857
BUILD SUCCESSFUL (total time: 3 seconds) BUILD SUCCESSFUL (total time: 6 seconds)
No preview for this file type
package SimkitOpenDis7Examples.run;
import SimkitOpenDis7Examples.ShipArrivalProcess;
import SimkitOpenDis7Examples.TwoCraneBerths;
import simkit.Schedule;
import simkit.random.RandomVariate;
import simkit.random.RandomVariateFactory;
import simkit.stat.CollectionSizeTimeVaryingStats;
import simkit.stat.SimpleStatsTally;
/**
* Run simple two-berth model for 10 years (3650 days).
* <h2>Output:</h2><pre>
ShipArrivalProcess.1
unloadTimeGenerator = Uniform (0.500, 1.500)
interarrivalTimeGenerator = Exponential (0.700)
TwoCraneBerths.2
Simulation ended at time 3,650.0
Number of ships arriving: 5,135
Number of ships unloaded: 5,129
Maximum # in queue: 11
Average # in queue: 0.6834
Average # busy berths: 1.1737
Average time in system: 1.3207
Average delay in queue: 0.4857
</pre>
*
* @author abuss@nps.edu
*/
public class RunTwoCranesBerth
{
/** Default constructor */
public RunTwoCranesBerth()
{
// default constructor
}
/**
* Run a simple program and compute statistical measurement of results.
* @param args the command line arguments
*/
public static void main(String[] args) {
RandomVariate interarrivalTimeGenerator =
RandomVariateFactory.getInstance("Exponential", 0.7);
RandomVariate unloadingTimeGenerator =
RandomVariateFactory.getInstance("Uniform", 0.5, 1.5);
ShipArrivalProcess shipArrivalProcess =
new ShipArrivalProcess(interarrivalTimeGenerator,
unloadingTimeGenerator);
TwoCraneBerths twoCraneBerths = new TwoCraneBerths();
shipArrivalProcess.addSimEventListener(twoCraneBerths);
SimpleStatsTally delayInQueueStat = new SimpleStatsTally("delayInQueue");
SimpleStatsTally timeInSystemStat = new SimpleStatsTally("timeInSystem");
CollectionSizeTimeVaryingStats numberInQueueStat =
new CollectionSizeTimeVaryingStats("queue");
CollectionSizeTimeVaryingStats numberInBerthStat =
new CollectionSizeTimeVaryingStats("berth");
// SimplePropertyDumper simplePropertyDumper = new SimplePropertyDumper();
// twoCraneBerths.addPropertyChangeListener(simplePropertyDumper);
twoCraneBerths.addPropertyChangeListener(delayInQueueStat);
twoCraneBerths.addPropertyChangeListener(timeInSystemStat);
twoCraneBerths.addPropertyChangeListener(numberInQueueStat);
twoCraneBerths.addPropertyChangeListener(numberInBerthStat);
System.out.println(shipArrivalProcess);
System.out.println(twoCraneBerths);
double stopTime = 10 * 365;
Schedule.stopAtTime(stopTime);
Schedule.setVerbose(false);
Schedule.reset();
Schedule.startSimulation();
System.out.printf("%nSimulation ended at time %,.1f%n%n",
Schedule.getSimTime());
System.out.printf("Number of ships arriving:\t%,d%n", shipArrivalProcess.getNumberArrivals());
System.out.printf("Number of ships unloaded:\t%,d%n", timeInSystemStat.getCount());
System.out.printf("Maximum # in queue:\t\t%.0f%n", numberInQueueStat.getMaxObs());
System.out.printf("Average # in queue:\t\t%.4f%n", numberInQueueStat.getMean());
System.out.printf("Average # busy berths:\t\t%.4f%n", numberInBerthStat.getMean());
System.out.printf("Average time in system:\t\t%.4f%n",
timeInSystemStat.getMean());
System.out.printf("Average delay in queue:\t\t%.4f%n",
delayInQueueStat.getMean()); }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment