Commit a7cd311b authored by rosemaryng's avatar rosemaryng
Browse files

[Engine] Added analyse impatience rate in GlobalJobInfoList for use in Simulation

parent 4f6cf555
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
package jmt.engine.NetStrategies.ImpatienceStrategies;
import com.google.common.base.Preconditions;
// import com.google.common.base.Preconditions;
import java.util.Random;
import jmt.engine.NetStrategies.ImpatienceStrategies.ImpatienceMeasurement.BooleanValueImpatienceMeasurement;
import jmt.engine.NetStrategies.ImpatienceStrategies.ImpatienceMeasurement.ImpatienceMeasurement;
......
......@@ -5,12 +5,13 @@ import java.util.List;
import jmt.engine.QueueNet.JobClass;
import jmt.engine.QueueNet.JobInfo;
import jmt.engine.QueueNet.JobInfoList;
import jmt.engine.QueueNet.WaitingRequest;
public class BooleanValueImpatienceMeasurement implements ImpatienceMeasurement {
private int queueLength;
private boolean booleanValue = false;
public BooleanValueImpatienceMeasurement(JobInfoList jobsList, JobInfoList waitingRequests,
public BooleanValueImpatienceMeasurement(JobInfoList jobsList, List<WaitingRequest> waitingRequests,
int jobClassPriority, boolean priorityActivated) {
setQueueLength(jobsList, waitingRequests, jobClassPriority, priorityActivated);
}
......@@ -20,11 +21,16 @@ public class BooleanValueImpatienceMeasurement implements ImpatienceMeasurement
/**
* Calculates the queue length the job will face depending on whether priority is activated or not.
*/
private void setQueueLength(JobInfoList jobsList, JobInfoList waitingRequests,
private void setQueueLength(JobInfoList jobsList, List<WaitingRequest> waitingRequests,
int jobClassPriority, boolean priorityActivated) {
if (priorityActivated) {
List<JobInfo> jobsListBuffer = jobsList.getInternalJobInfoList();
List<JobInfo> waitingRequestsBuffer = waitingRequests.getInternalJobInfoList();
//TODO rose: re-evaluate the usage of waitingRequestBuffer
// List<JobInfo> waitingRequestsBuffer = waitingRequests.getInternalJobInfoList();
List<JobInfo> waitingRequestsBuffer = new ArrayList<>();
for (WaitingRequest r: waitingRequests) {
waitingRequestsBuffer.add(r);
}
List<JobInfo> combinedBuffer = new ArrayList<>();
combinedBuffer.addAll(jobsListBuffer);
combinedBuffer.addAll(waitingRequestsBuffer);
......
......@@ -19,10 +19,10 @@
package jmt.engine.NodeSections;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jmt.common.exception.NetException;
......@@ -117,7 +117,7 @@ public class Queue extends InputSection {
//the JobInfoList used for Fork nodes
private JobInfoList FJList;
// Backup buffer when the main jobsList is full
private JobInfoList waitingRequests;
private List<WaitingRequest> waitingRequests;
//number of dropped jobs
private int droppedJobs;
......@@ -152,6 +152,12 @@ public class Queue extends InputSection {
private NetNode regionInputStation;
//------------------------------------------------------------------//
private enum BufferType {
FJ_LIST,
JOBS_LIST,
WAITING_REQUESTS
}
/**
* Creates a new instance of finite Queue.
* @param size Queue size (-1 = infinite queue).
......@@ -343,7 +349,8 @@ public class Queue extends InputSection {
protected void nodeLinked(NetNode node) throws NetException {
// Sets netnode dependent properties
jobClasses = getJobClasses();
waitingRequests = new LinkedList<WaitingRequest>();
//TODO rose: waiting Requests is not used
//waitingRequests = new LinkedList<WaitingRequest>();
//waitingRequests.setNetSystem(node.getNetSystem());
if (putStrategies == null) {
putStrategies = new QueuePutStrategy[jobClasses.size()];
......
......@@ -237,8 +237,8 @@ public class GlobalJobInfoList {
// Updates jobs number and reneging rate data structures
jobs--;
jobsPerClass[job.getJobClass().getId()]--;
lastModifyNumberPerClass[job.getJobClass().getId()] = lastModifyNumber = NetSystem.getTime();
lastJobRenegeTimePerClass[job.getJobClass().getId()] = lastJobRenegeTime = NetSystem.getTime();
lastModifyNumberPerClass[job.getJobClass().getId()] = lastModifyNumber = getTime();
lastJobRenegeTimePerClass[job.getJobClass().getId()] = lastJobRenegeTime = getTime();
}
/**
......@@ -251,9 +251,9 @@ public class GlobalJobInfoList {
// Updates jobs number and balking rate data structures
jobs--;
jobsPerClass[job.getJobClass().getId()]--;
lastModifyNumberPerClass[job.getJobClass().getId()] = lastModifyNumber = NetSystem.getTime();
lastModifyNumberPerClass[job.getJobClass().getId()] = lastModifyNumber = getTime();
lastJobBalkTimePerClass[job.getJobClass().getId()] = lastJobBalkTime = NetSystem.getTime();
lastJobBalkTimePerClass[job.getJobClass().getId()] = lastJobBalkTime = getTime();
}
/**
......@@ -364,6 +364,38 @@ public class GlobalJobInfoList {
}
}
/**
* Analyzes Reneging Rate for a specific job class or for every class
* @param jobClass specified job class. If null measure will be job independent
* @param Measure reference to a Measure object
*/
public void analyzeRenegingRate(JobClass jobClass, Measure Measure) {
if (jobClass != null) {
if (renegingRatePerClass == null) {
renegingRatePerClass = new InverseMeasure[classNum];
}
renegingRatePerClass[jobClass.getId()] = (InverseMeasure) Measure;
} else {
renegingRate = (InverseMeasure) Measure;
}
}
/**
* Analyzes Balking Rate for a specific job class or for every class
* @param jobClass specified job class. If null measure will be job independent
* @param Measure reference to a Measure object
*/
public void analyzeBalkingRate(JobClass jobClass, Measure Measure) {
if (jobClass != null) {
if (balkingRatePerClass == null) {
balkingRatePerClass = new InverseMeasure[classNum];
}
balkingRatePerClass[jobClass.getId()] = (InverseMeasure) Measure;
} else {
balkingRate = (InverseMeasure) Measure;
}
}
// ------------------------------------------------------------------------------------
// --- Methods to update measures -----------------------------------------------------
......
/**
* Copyright (C) 2016, Laboratorio di Valutazione delle Prestazioni - Politecnico di Milano
* <p>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
......@@ -23,7 +23,7 @@ import org.apache.commons.math3.util.Pair;
/**
* This class implements a generic job of a queue network.
* @author Francesco Radaelli, Marco Bertoli
* @author Francesco Radaelli, Marco Bertoli
*/
public class Job implements Cloneable {
......@@ -55,8 +55,8 @@ public class Job implements Cloneable {
private NetNode originalDestinationNode = null;
private double serviceTime = -1.0;
private NetSystem netSystem;
private NetSystem netSystem;
protected GlobalJobInfoList globalJobInfoList = null;
protected Pair<NetNode, JobClass> lastVisitedPair = null;
......@@ -71,7 +71,7 @@ public class Job implements Cloneable {
this.jobClass = jobClass;
this.globalJobInfoList = globalJobInfoList;
//reset();
serviceArrivalTime = 0;
serviceArrivalTime = 0;
isPreemptedJob = false;
jobIsInService = false;
}
......@@ -178,10 +178,10 @@ public class Job implements Cloneable {
this.lastVisitedPair = pair;
}
public NetSystem getNetSystem(){
public NetSystem getNetSystem() {
return netSystem;
}
}
/**
* Adds a pair to the visit path of this job.
* @param pair the pair to be added to the visit path.
......@@ -214,6 +214,7 @@ public class Job implements Cloneable {
public void setIsJobInService(boolean jobIsInService) {
this.jobIsInService = jobIsInService;
}
public RemoveToken getServingMessage() {
return servingMessage;
}
......@@ -221,14 +222,14 @@ public class Job implements Cloneable {
public void setServingMessage(RemoveToken servingMessage) {
this.servingMessage = servingMessage;
}
public void initialize(NetSystem netSystem){
public void initialize(NetSystem netSystem) {
this.netSystem = netSystem;
// Job Id is used only for logging
this.Id = netSystem.nextjobNumber();
resetSystemEnteringTime();
}
public void resetSystemEnteringTime() {
this.systemEnteringTime = netSystem.getTime();
//resetClass();
......
......@@ -316,7 +316,7 @@ public class Simulation {
try {
//creates all nodes
NetNode[] netNodes = new NetNode[nodes.size()];
NetNode[] netNodes = new NetNode[nodes.size()];
for (int i = 0; i < nodes.size(); i++) {
netNodes[i] = (nodes.get(i)).getNode();
}
......
......@@ -23,21 +23,12 @@ import java.awt.Component;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
......@@ -249,7 +240,6 @@ public class InputSectionPanel extends WizardPanel implements CommonConstants {
editor.stopCellEditing();
}
Vector<Object> classKeys = classData.getClassKeys();
String queuePolicy = (String) queuePolicyCombo.getSelectedItem();
data.setStationQueueStrategy(stationKey, queuePolicy);
......@@ -280,8 +270,8 @@ public class InputSectionPanel extends WizardPanel implements CommonConstants {
}
}
}
// Update the balking parameter for all classes in this station
Vector<Object> classKeys = classData.getClassKeys();
for (Object classKey : classKeys) {
data.updateBalkingParameter(stationKey, classKey, queuePolicy);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment