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

initial integration of opendis7 class with simkiet

parent f5ec5384
No related branches found
No related tags found
No related merge requests found
package SimkitOpenDis7Examples;
import OpenDis7Examples.OpenDis7NetworkCapabilities;
import simkit.SimEntityBase;
import simkit.random.RandomVariate;
/**
* One of the simplest non-trivial Event Graph models. A series of Arrival
* events is scheduled based on an inter arrival time random variate. The state
* variable, simply counts the number of these arrivals.
*
* @author ahbuss
*/
public class ArrivalProcessOpenDis7 extends SimEntityBase {
private final OpenDis7NetworkCapabilities opendis7 = new OpenDis7NetworkCapabilities();
/**
* Generates interarrival times
*/
private RandomVariate interarrivalTimeGenerator;
/**
* State variable that counts the number of Arrival events
*/
protected int numberArrivals;
/**
* Instantiate an ArrivalProcess with the given interarrivalTimeGenerator
*
* @param interarrivalTimeGenerator Given RandomVariate for interarrival
* times
*/
public ArrivalProcessOpenDis7(RandomVariate interarrivalTimeGenerator) {
this.setInterarrivalTimeGenerator(interarrivalTimeGenerator);
}
/**
* If the ArrivalProcess is instantiated using the zero-argument
* constructor, be sure the set the interarrivalTimeGenerator with an
* explicit call to its setter method.
*/
public ArrivalProcessOpenDis7() {
System.out.println("opendis7.getNetworkAddress()=" + opendis7.getNetworkAddress());
}
/**
* Initialize numberArrivals to 0
*/
public void reset() {
super.reset();
numberArrivals = 0;
}
/**
* Schedule the first Arrival event with delay generated by
* interarrivalTimeGenerator
*/
public void doRun() {
firePropertyChange("numberArrivals", getNumberArrivals());
waitDelay("Arrival", interarrivalTimeGenerator);
}
/**
* Increment numberArrivals<br>
* Schedule next Arrival event with delay generated by
* interarrivalTimeGenerator
*/
public void doArrival() {
int oldNumberArrivals = getNumberArrivals();
numberArrivals += 1;
firePropertyChange("numberArrivals", oldNumberArrivals, getNumberArrivals());
waitDelay("Arrival", interarrivalTimeGenerator);
}
/**
* @return the interarrivalTimeGenerator
*/
public RandomVariate getInterarrivalTimeGenerator() {
return interarrivalTimeGenerator;
}
/**
* @param interarrivalTimeGenerator the interarrivalTimeGenerator to set
*/
public void setInterarrivalTimeGenerator(RandomVariate interarrivalTimeGenerator) {
this.interarrivalTimeGenerator = interarrivalTimeGenerator;
}
/**
* @return the numberArrivals
*/
public int getNumberArrivals() {
return numberArrivals;
}
}
package SimkitOpenDis7Examples.run;
import SimkitOpenDis7Examples.ArrivalProcessOpenDis7;
import SimkitOpenDis7Examples.SimpleServer;
import simkit.Schedule;
import simkit.random.RandomVariate;
import simkit.random.RandomVariateFactory;
import simkit.stat.SimpleStatsTimeVarying;
import simkit.util.SimplePropertyDumper;
/**
* <h2>Output:</h2><pre>
* ArrivalProcess.1
* &nbsp;&nbsp;&nbsp;&nbsp;interarrivalTimeGenerator = Uniform (0.900, 2.200)
* SimpleServer.2
* &nbsp;&nbsp;&nbsp;&nbsp;serviceTimeGenerator = Gamma (1.700, 1.800)
* &nbsp;&nbsp;&nbsp;&nbsp;totalNumberServers = 2
* Simulation ended at time 100,000.000
*
* There have been 64,475 arrivals
* There have been 64,472 customers served
* Average number in queue 15.9655
* Average utilization 0.9819</pre>
*
* @author ahbuss
*/
public class RunSimpleServerOpenDis7 {
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
String rvName = "Uniform";
double lower = 0.9;
double upper = 2.2;
RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(rvName, lower, upper);
ArrivalProcessOpenDis7 arrival = new ArrivalProcessOpenDis7(interarrivalTimeGenerator);
rvName = "Gamma";
double alpha = 1.7;
double beta = 1.8;
RandomVariate serviceTimeGenerator = RandomVariateFactory.getInstance(rvName, alpha, beta);
int numServ = 2;
SimpleServer server = new SimpleServer(numServ, serviceTimeGenerator);
arrival.addSimEventListener(server);
SimplePropertyDumper simplePropertyDumper = new SimplePropertyDumper();
// server.addPropertyChangeListener(simplePropertyDumper);
// arrival.addPropertyChangeListener(simplePropertyDumper);
SimpleStatsTimeVarying numberInQueueStat = new SimpleStatsTimeVarying("numberInQueue");
SimpleStatsTimeVarying numberAvailableServersStat = new SimpleStatsTimeVarying("numberAvailableServers");
server.addPropertyChangeListener(numberInQueueStat);
server.addPropertyChangeListener(numberAvailableServersStat);
System.out.println(arrival);
System.out.println(server);
// Schedule.setVerbose(true);
// Schedule.setSingleStep(false);
// double stopTime = 6.0;
double stopTime = 100000.0;
Schedule.stopAtTime(stopTime);
Schedule.reset();
numberInQueueStat.reset();
numberAvailableServersStat.reset();
Schedule.startSimulation();
System.out.printf("Simulation ended at time %,.3f%n", Schedule.getSimTime());
System.out.printf("%nThere have been %,d arrivals%n", arrival.getNumberArrivals());
System.out.printf("There have been %,d customers served%n", server.getNumberServed());
System.out.printf("Average number in queue\t%.4f%n", numberInQueueStat.getMean());
System.out.printf("Average utilization\t%.4f%n", 1.0 - numberAvailableServersStat.getMean() / server.getTotalNumberServers());
}
}
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=debug.single -Djavac.includes=SimkitOpenDis7Examples/run/RunSimpleServerOpenDis7.java -Ddebug.class=SimkitOpenDis7Examples.run.RunSimpleServerOpenDis7 debug-single
init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
compile-single:
[OpenDis7]thisHostName=IT160907-UWALPP
ArrivalProcessOpenDis7.1
interarrivalTimeGenerator = Uniform (0.900, 2.200)
SimpleServer.2
totalNumberServers = 2
serviceTimeGenerator = Gamma (1.700, 1.800)
Simulation ended at time 100,000.000
There have been 64,475 arrivals
There have been 64,472 customers served
Average number in queue 15.9655
Average utilization 0.9819
debug-single:
BUILD SUCCESSFUL (total time: 1 minute 9 seconds)
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