Skip to content
Snippets Groups Projects
Commit adf2c3b2 authored by dansl's avatar dansl
Browse files

Commit additions for Steady State and Transient Stats

parent cf796e91
No related branches found
No related tags found
No related merge requests found
......@@ -6,14 +6,15 @@ package mv3302;
import simkit.random.RandomVariate;
/**
*
* @author dansl
*/
public final class StoppedPartArrivalProcess extends PartArrivalProcess {
private RandomVariate interarrivalTimeGenerator;
//private RandomVariate interarrivalTimeGenerator;
public int stopTime;
//int stopTime = 480;
/**
* Zero-argument constructor
......@@ -27,13 +28,13 @@ public final class StoppedPartArrivalProcess extends PartArrivalProcess {
*
* @param interarrivalTimes Given inter arrival times
*/
public StoppedPartArrivalProcess(RandomVariate interarrivalTimeGenerator) {
setInterarrivalTimeGenerator(interarrivalTimeGenerator);
public StoppedPartArrivalProcess(int stopTime) {
this.stopTime = stopTime;
}
@Override
public void doRun() {
waitDelay("StopArrivals", interarrivalTimeGenerator);
waitDelay("StopArrivals", getStopTime());
}
/**
......@@ -45,18 +46,16 @@ public final class StoppedPartArrivalProcess extends PartArrivalProcess {
}
/**
* @return the interarrivalTimeGenerator
* @return the stopTime
*/
@Override
public RandomVariate getInterarrivalTimeGenerator() {
return interarrivalTimeGenerator;
public int getStopTime() {
return stopTime;
}
/**
* @param interarrivalTimeGenerator the interarrivalTimeGenerator to set
* @param stopTime the stopTime to set
*/
@Override
public void setInterarrivalTimeGenerator(RandomVariate interarrivalTimeGenerator) {
this.interarrivalTimeGenerator = interarrivalTimeGenerator;
public void setStopTime(int stopTime) {
this.stopTime = stopTime;
}
}
package mv3302.run;
import static java.lang.Math.sqrt;
import mv3302.PartArrivalProcess;
import mv3302.StoppedPartArrivalProcess;
import mv3302.TransferLineComponent;
import mv3302.TransientStats;
......@@ -22,7 +23,9 @@ public class RunTransientAnalysis {
public static void main(String args[]) {
RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(
"Exponential", 2.5);
StoppedPartArrivalProcess arrivalProcess = new StoppedPartArrivalProcess(interarrivalTimeGenerator);
int stopTime = 480;
PartArrivalProcess partArrivalProcess = new PartArrivalProcess(interarrivalTimeGenerator);
StoppedPartArrivalProcess stoppedArrivalProcess = new StoppedPartArrivalProcess(stopTime);
RandomVariate[] processingTimeGenerator
= {RandomVariateFactory.getInstance("Exponential", 2.4), RandomVariateFactory.getInstance("Gamma", 3.2, 3.3), RandomVariateFactory.getInstance("Uniform", 4.5, 6.7), RandomVariateFactory.getInstance("Exponential", 3.0)};
......@@ -35,36 +38,38 @@ public class RunTransientAnalysis {
TransferLineComponent transferLineComponent = new TransferLineComponent(processingTimeGenerator, totalNumberWorkstations);
arrivalProcess.addSimEventListener(transferLineComponent);
partArrivalProcess.addSimEventListener(transferLineComponent);
stoppedArrivalProcess.addSimEventListener(transferLineComponent);
TransientStats delayInQueueTransient = new TransientStats("delayInQueue");
// SimpleStatsTally delayInQueueTransient = new SimpleStatsTally("delayInQueue");
//
SimpleStatsTally totalTimeInSystemStat = new SimpleStatsTally("totalTimeInSystem");
SimpleStatsTally delayInQueueStat = new SimpleStatsTally("delayInQueue");
transferLineComponent.addPropertyChangeListener(delayInQueueTransient);
transferLineComponent.addPropertyChangeListener(totalTimeInSystemStat);
System.out.println(arrivalProcess);
System.out.println(partArrivalProcess);
System.out.println(stoppedArrivalProcess);
System.out.println(transferLineComponent);
SimpleStatsTally outerDelayInQueueStat = new SimpleStatsTally("outerDelayInQueue");
SimpleStatsTally outerTimeInSystemStat = new SimpleStatsTally("outerTimeInSystem");
int stopTime = 50;
int numberReplications = 200;
double alpha = 0.05;
Schedule.stopOnEvent(stopTime, "Arrival");
Schedule.stopOnEvent(10000, "Arrival");
System.out.println("Avg Delay In Queue");
for (int replication = 1; replication <= stopTime; ++replication) {
Schedule.reset();
delayInQueueTransient.reset();
totalTimeInSystemStat.reset();
Schedule.startSimulation();
outerDelayInQueueStat.newObservation(delayInQueueStat.getMean());
outerTimeInSystemStat.newObservation(totalTimeInSystemStat.getMean());
System.out.printf("%d %.3f ± %.3f%n",
replication,
outerDelayInQueueStat.getMean(),
outerDelayInQueueStat.getStandardDeviation()
* StudentT.getQuantile(1.0 - 0.5 * alpha, outerDelayInQueueStat.getCount() - 1) / sqrt(outerDelayInQueueStat.getCount())
outerTimeInSystemStat.getMean(),
outerTimeInSystemStat.getStandardDeviation()
* StudentT.getQuantile(1.0 - 0.5 * alpha, outerTimeInSystemStat.getCount() - 1) / sqrt(outerTimeInSystemStat.getCount())
);
}
......
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