Commit ea7230dc authored by rosemaryng's avatar rosemaryng
Browse files

[Clean up] Debugged Response time / residence time calculation + refactor multiple classes

parent 73458e3b
......@@ -162,10 +162,14 @@ public class Server extends ServiceSection {
}
job.setServiceArrivalTime(this.getTime());
jobInServiceMessage = sendMe(job, serviceTime);
System.out.println("serviceTime: " + serviceTime);
} else {
job.setIsPreemptedJob(false);
job.setServiceArrivalTime(this.getTime());
jobInServiceMessage = sendMe(job, job.getServiceTime());
System.out.println("serviceTime Else: " + job.getServiceTime());
}
if (preemption) {
jobInService = job;
......
......@@ -54,7 +54,7 @@ public class Storage extends InputSection {
public static final String FINITE_DROP = "drop";
public static final String FINITE_BLOCK = "BAS blocking";
public static final String FINITE_WAITING = "waiting queue";
public static final String FINITE_RETRIAL = "retry full";
public static final String FINITE_RETRIAL = "retrial";
private int totalCapacity;
private int[] capacities;
......
......@@ -236,7 +236,7 @@ public interface JobInfoList {
*/
public abstract void remove(JobInfo jobInfo);
// public abstract void remove(JobInfo jobInfo, int event);
public abstract void removeOnly(JobInfo jobInfo);
/**
* Removes a job info at the start of the list.
......
......@@ -553,27 +553,24 @@ public class LinkedJobInfoList implements JobInfoList {
doRemove(jobInfo, 0, 0);
}
// @Override
// public void remove(JobInfo jobInfo, int event) {
// if (event == NetEvent.EVENT_RETRIAL_JOB) {
// int c = jobInfo.getJob().getJobClass().getId();
// updateQueueLength(jobInfo);
// updateUtilization(jobInfo);
// updateUtilizationJoin(jobInfo);
// updateThroughput(jobInfo);
// finalRemove(jobInfo, list, 0);
// finalRemove(jobInfo, listPerClass[c], 0);
// jobsOut++;
// jobsOutPerClass[c]++;
// lastJobOutTime = getTime();
// lastJobOutTimePerClass[c] = getTime();
// totalSojournTime += getTime() - jobInfo.getEnteringTime();
// totalSojournTimePerClass[c] += getTime() - jobInfo.getEnteringTime();
// lastJobSojournTime = getTime() - jobInfo.getEnteringTime();
// lastJobSojournTimePerClass[c] = getTime() - jobInfo.getEnteringTime();
// }
//
// }
@Override
public void removeOnly(JobInfo jobInfo) {
int c = jobInfo.getJob().getJobClass().getId();
updateQueueLength(jobInfo);
updateUtilization(jobInfo);
updateUtilizationJoin(jobInfo);
updateThroughput(jobInfo);
finalRemove(jobInfo, list, 0);
finalRemove(jobInfo, listPerClass[c], 0);
jobsOut++;
jobsOutPerClass[c]++;
lastJobOutTime = getTime();
lastJobOutTimePerClass[c] = getTime();
totalSojournTime += getTime() - jobInfo.getEnteringTime();
totalSojournTimePerClass[c] += getTime() - jobInfo.getEnteringTime();
lastJobSojournTime = getTime() - jobInfo.getEnteringTime();
lastJobSojournTimePerClass[c] = getTime() - jobInfo.getEnteringTime();
}
/* (non-Javadoc)
* @see jmt.engine.QueueNet.JobInfoList#removeFirst()
......@@ -891,13 +888,13 @@ public class LinkedJobInfoList implements JobInfoList {
Measure m = responseTimePerClass[c];
if (m != null) {
m.update(getTime() - jobInfo.getEnteringTime(), 1.0);
System.out.println("Response Time: " + (getTime() - jobInfo.getEnteringTime()));
// System.out.println("Response Time: " + (getTime() - jobInfo.getEnteringTime()));
}
}
if (responseTime != null) {
responseTime.update(getTime() - jobInfo.getEnteringTime(), 1.0);
System.out.println("Response Time: " + (getTime() - jobInfo.getEnteringTime()));
// System.out.println("Response Time: " + (getTime() - jobInfo.getEnteringTime()));
}
}
......@@ -917,6 +914,10 @@ public class LinkedJobInfoList implements JobInfoList {
residenceTime.update(getTime() - jobInfo.getEnteringTime(), 1.0);
}
if(residenceTimePerClass != null || residenceTime != null) {
System.out.println("Residence time: " + (getTime() - jobInfo.getEnteringTime()));
}
}
protected void updateUtilization(JobInfo jobInfo) {
......@@ -1019,12 +1020,12 @@ public class LinkedJobInfoList implements JobInfoList {
Measure m = retrialRatePerClass[c];
if (m != null) {
m.update(getTime() - getLastJobRetrialTimePerClass(jobClass), 1.0);
System.out.println(getTime() - getLastJobRetrialTimePerClass(jobClass));
// System.out.println(getTime() - getLastJobRetrialTimePerClass(jobClass));
}
}
if (retrialRate != null) {
retrialRate.update(getTime() - getLastJobRetrialTime(), 1.0);
System.out.println(getTime() - getLastJobRetrialTime());
// System.out.println(getTime() - getLastJobRetrialTime());
}
}
......
......@@ -651,7 +651,7 @@ public class NetNode extends SimEntity {
}
}
if (event == NetEvent.EVENT_RETRIAL) {
removeJobFromNodeJobsList((Job) data);
removeJobFromNodeJobsListOnly((Job) data, event);
// System.out.println("Remove job from NodeJobsList after signaling retrial?: " + removeJobFromNodeJobsList((Job) data));
}
......@@ -691,15 +691,15 @@ public class NetNode extends SimEntity {
* Helper function to remove job from the NodeJobsList
* @param data the jobInfo data looking to be removed.
*/
// private boolean removeJobFromNodeJobsList(Job data, int event) {
// Job job = data;
// JobInfo jobInfo = jobsList.lookFor(job);
// if (jobInfo != null) {
// jobsList.remove(jobInfo, event);
// return true;
// }
// return false;
// }
public boolean removeJobFromNodeJobsListOnly(Job data, int event) {
Job job = data;
JobInfo jobInfo = jobsList.lookFor(job);
if (jobInfo != null && event == NetEvent.EVENT_RETRIAL) {
jobsList.removeOnly(jobInfo);
return true;
}
return false;
}
......
......@@ -420,7 +420,7 @@ public abstract class NodeSection {
}
}
if (event == NetEvent.EVENT_RETRIAL ) {
updateJobsListAfterSend((Job) data);
updateJobsListAfterSend((Job) data, event);
}
return ownerNode.send(event, data, delay, sectionID, destinationSection, destination);
}
......@@ -551,6 +551,13 @@ public abstract class NodeSection {
}
}
private void updateJobsListAfterSend(Job job, int event) {
JobInfo jobInfo = jobsList.lookFor(job);
if (jobInfo != null & event == NetEvent.EVENT_RETRIAL) {
jobsList.removeOnly(jobInfo);
}
}
/**
* Updates the JobInfoList after receiving this job.
* @param job job to be received.
......
......@@ -249,7 +249,7 @@ public interface CommonConstants {
public static final String FINITE_DROP = "Drop";
public static final String FINITE_BLOCK = "BAS Blocking";
public static final String FINITE_WAITING = "Waiting Queue";
public static final String FINITE_RETRIAL = "Retry Full";
public static final String FINITE_RETRIAL = "Retrial";
public static final String CLASSES_DESCRIPTION = HTML_START + HTML_FONT_TITLE + "Classes Characteristics" + HTML_FONT_TIT_END + HTML_FONT_NORM
+ "Define type (Open or Closed), name and parameters for each customer class."
......
......@@ -57,7 +57,7 @@ public class PAResultsModel implements MeasureDefinition {
private Vector<Integer> retrialRate = new Vector<Integer>();
private Vector<Integer> waitingTime = new Vector<Integer>();
private Vector<Integer> retrialOrbitSize = new Vector<Integer>();
private Vector<Integer> busyServersVar = new Vector<Integer>();
private Vector<Integer> busyServersNum = new Vector<Integer>();
private Vector<Integer> systemCustomerNumber = new Vector<Integer>();
private Vector<Integer> systemResponseTime = new Vector<Integer>();
......@@ -147,7 +147,7 @@ public class PAResultsModel implements MeasureDefinition {
} else if (measureType.equals(SimulationDefinition.MEASURE_RS)) {
retrialOrbitSize.add(new Integer(i));
} else if (measureType.equals(SimulationDefinition.MEASURE_BS)) {
busyServersVar.add(new Integer(i));
busyServersNum.add(new Integer(i));
} else if (measureType.equals(SimulationDefinition.MEASURE_S_CN)) {
systemCustomerNumber.add(new Integer(i));
} else if (measureType.equals(SimulationDefinition.MEASURE_S_RP)) {
......@@ -232,7 +232,7 @@ public class PAResultsModel implements MeasureDefinition {
} else if (type.equals(SimulationDefinition.MEASURE_RS)) {
retrialOrbitSize.add(new Integer(measures.size() - 1));
} else if (type.equals(SimulationDefinition.MEASURE_BS)) {
busyServersVar.add(new Integer(measures.size() - 1));
busyServersNum.add(new Integer(measures.size() - 1));
} else if (type.equals(SimulationDefinition.MEASURE_S_CN)) {
systemCustomerNumber.add(new Integer(measures.size() - 1));
} else if (type.equals(SimulationDefinition.MEASURE_S_RP)) {
......@@ -385,332 +385,135 @@ public class PAResultsModel implements MeasureDefinition {
return measures.get(measureIndex).values;
}
// --- List of getMeasure functions for each measure
/**
* Returns an array with the measureIndex of every queue length measure
* Helper method called by all getMeasure functions
* Returns an array with the measureIndex of every vector measure
* @return an array with measures' index
*/
public int[] getQueueLengthMeasures() {
int[] tmp = new int[queueLength.size()];
private int[] getTmpArray(Vector<Integer> vector) {
int[] tmp = new int[vector.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = queueLength.get(i).intValue();
tmp[i] = vector.get(i).intValue();
}
return tmp;
}
/**
* Returns an array with the measureIndex of every queue time measure
* @return an array with measures' index
*/
public int[] getQueueLengthMeasures() {
return getTmpArray(queueLength);
}
public int[] getQueueTimeMeasures() {
int[] tmp = new int[queueTime.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = queueTime.get(i).intValue();
}
return tmp;
return getTmpArray(queueTime);
}
/**
* Returns an array with the measureIndex of every response time measure
* @return an array with measures' index
*/
public int[] getResponseTimeMeasures() {
int[] tmp = new int[responseTime.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = responseTime.get(i).intValue();
}
return tmp;
return getTmpArray(responseTime);
}
/**
* Returns an array with the measureIndex of every residence time measure
* @return an array with measures' index
*/
public int[] getResidenceTimeMeasures() {
int[] tmp = new int[residenceTime.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = residenceTime.get(i).intValue();
}
return tmp;
return getTmpArray(residenceTime);
}
/**
* Returns an array with the measureIndex of every utilization measure
* @return an array with measures' index
*/
public int[] getUtilizationMeasures() {
int[] tmp = new int[utilization.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = utilization.get(i).intValue();
}
return tmp;
return getTmpArray(utilization);
}
/**
* Returns an array with the measureIndex of every throughput measure
* @return an array with measures' index
*/
public int[] getThroughputMeasures() {
int[] tmp = new int[throughput.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = throughput.get(i).intValue();
}
return tmp;
return getTmpArray(throughput);
}
/**
* Returns an array with the measureIndex of every drop rate measure
* @return an array with measures' index
*/
public int[] getDropRateMeasures() {
int[] tmp = new int[dropRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = dropRate.get(i).intValue();
}
return tmp;
return getTmpArray(dropRate);
}
/**
* Returns an array with the measureIndex of every reneging rate measure
* @return an array with measures' index
*/
public int[] getRenegingRateMeasures() {
int[] tmp = new int[renegingRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = renegingRate.get(i).intValue();
}
return tmp;
return getTmpArray(renegingRate);
}
/**
* Returns an array with the measureIndex of every balking rate measure
* @return an array with measures' index
*/
public int[] getBalkingRateMeasures() {
int[] tmp = new int[balkingRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = balkingRate.get(i).intValue();
}
return tmp;
return getTmpArray(balkingRate);
}
/**
* Returns an array with the measureIndex of every retrial rate measure
* @return an array with measures' index
*/
@Override
public int[] getRetrialRateMeasures() {
int[] tmp = new int[retrialRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = retrialRate.get(i).intValue();
}
return tmp;
return getTmpArray(retrialRate);
}
@Override
public int[] getRetrialOrbitSizeMeasures() {
int[] tmp = new int[retrialOrbitSize.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = retrialOrbitSize.get(i).intValue();
}
return tmp;
return getTmpArray(retrialOrbitSize);
}
@Override
public int[] getWaitingTimeMeasures() {
int[] tmp = new int[waitingTime.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = waitingTime.get(i).intValue();
}
return tmp;
return getTmpArray(waitingTime);
}
@Override
public int[] getNumberOfBusyServersMeasures() {
int[] tmp = new int[busyServersVar.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = busyServersVar.get(i).intValue();
}
return tmp;
return getTmpArray(busyServersNum);
}
/**
* Returns an array with the measureIndex of every system customer number measure
* @return an array with measures' index
*/
public int[] getSystemCustomerNumberMeasures() {
int[] tmp = new int[systemCustomerNumber.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemCustomerNumber.get(i).intValue();
}
return tmp;
return getTmpArray(systemCustomerNumber);
}
/**
* Returns an array with the measureIndex of every system response time measure
* @return an array with measures' index
*/
public int[] getSystemResponseTimeMeasures() {
int[] tmp = new int[systemResponseTime.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemResponseTime.get(i).intValue();
}
return tmp;
return getTmpArray(systemResponseTime);
}
/**
* Returns an array with the measureIndex of every system throughput measure
* @return an array with measures' index
*/
public int[] getSystemThroughputMeasures() {
int[] tmp = new int[systemThroughput.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemThroughput.get(i).intValue();
}
return tmp;
return getTmpArray(systemThroughput);
}
/**
* Returns an array with the measureIndex of every system drop rate measure
* @return an array with measures' index
*/
public int[] getSystemDropRateMeasures() {
int[] tmp = new int[systemDropRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemDropRate.get(i).intValue();
}
return tmp;
return getTmpArray(systemDropRate);
}
/**
* Returns an array with the measureIndex of every system reneging rate measure
* @return an array with measures' index
*/
public int[] getSystemRenegingRateMeasures() {
int[] tmp = new int[systemRenegingRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemRenegingRate.get(i).intValue();
}
return tmp;
return getTmpArray(systemRenegingRate);
}
/**
* Returns an array with the measureIndex of every system balking rate measure
* @return an array with measures' index
*/
public int[] getSystemBalkingRateMeasures() {
int[] tmp = new int[systemBalkingRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemBalkingRate.get(i).intValue();
}
return tmp;
return getTmpArray(systemBalkingRate);
}
/**
* Returns an array with the measureIndex of every system power measure
* @return an array with measures' index
*/
public int[] getSystemPowerMeasures() {
int[] tmp = new int[systemPower.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemPower.get(i).intValue();
}
return tmp;
return getTmpArray(systemPower);
}
/**
* Returns an array with the measureIndex of every system retrial rate measure
* @return an array with measures' index
*/
@Override
public int[] getSystemRetrialRateMeasures() {
int[] tmp = new int[systemRetrialRate.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = systemRetrialRate.get(i).intValue();
}
return tmp; }
return getTmpArray(systemRetrialRate);
}
/**
* Returns an array with the measureIndex of every response time per sink measure
* @return an array with measures' index
*/
public int[] getResponsetimePerSinkMeasures() {
int[] tmp = new int[responseTimePerSink.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = responseTimePerSink.get(i).intValue();
}
return tmp;
return getTmpArray(responseTimePerSink);
}
/**
* Returns an array with the measureIndex of every throughput per sink measure
* @return an array with measures' index
*/
public int[] getThroughputPerSinkMeasures() {
int[] tmp = new int[throughputPerSink.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = throughputPerSink.get(i).intValue();
}
return tmp;
return getTmpArray(throughputPerSink);
}
/**
* Returns an array with the measureIndex of every FCR total weight measure
* @return an array with measures' index
*/
public int[] getFCRTotalWeightMeasures() {
int[] tmp = new int[FCRTotalWeight.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = FCRTotalWeight.get(i).intValue();
}
return tmp;
return getTmpArray(FCRTotalWeight);
}
/**
* Returns an array with the measureIndex of every FCR memory occupation measure
* @return an array with measures' index
*/
public int[] getFCRMemoryOccupationMeasures() {
int[] tmp = new int[FCRMemoryOccupation.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = FCRMemoryOccupation.get(i).intValue();
}
return tmp;
return getTmpArray(FCRMemoryOccupation);
}
/**
* Returns an array with the measureIndex of every FJ customer number measure
* @return an array with measures' index
*/
public int[] getFJCustomerNumberMeasures() {
int[] tmp = new int[FJCustomerNumber.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = FJCustomerNumber.get(i).intValue();
}
return tmp;
return getTmpArray(FJCustomerNumber);
}
/**
* Returns an array with the measureIndex of every FJ response time measure
* @return an array with measures' index
*/
public int[] getFJResponseTimeMeasures() {
int[] tmp = new int[FJResponseTime.size()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = FJResponseTime.get(i).intValue();
}
return tmp;
return getTmpArray(FJResponseTime);
}
/**
* Returns an array with the measureIndex of every firing throughput measure
* @return an array with measures' index
*/
public int[] getFiringThroughputMeasures() {