* accesses to the reference station)
*/
private void scaleMeasureWithVisitRatio() {
//retrieves JobClass object using its name
JobClass jobClass = network.getJobClass(jobClassName);
double visitRatio = 1.0;
//current measure node
NetNode thisNode = network.getNode(nodeName);
// If measure is class specific
if (jobClass != null) {
//reference node for this job class
String referenceNodeName = jobClass.getReferenceNodeName();
NetNode referenceNode = network.getNode(referenceNodeName);
int visitsReferenceNode, visitsThisNode;
try {
//visits to the reference node
NodeSection refOutputSection = referenceNode.getSection(NodeSection.OUTPUT);
visitsReferenceNode = refOutputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobClass);
//visits to this node node
NodeSection thisNodeInputSection = thisNode.getSection(NodeSection.INPUT);
visitsThisNode = thisNodeInputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobClass);
// the reference source generates a certain number of jobs
// - some of them have reached this station
// - other have been dropped before enetering this station or
// elsewhere in the network
int droppedJobs = network.getDroppedJobs(jobClass);
if (thisNodeInputSection instanceof BlockingQueue) {
// if the input section is a BlockingQueue,
// remove (from the total number of visits)
// the jobs dropped by the BlockingQueue itself,
// because they have been counted
// in arrived jobs
visitsThisNode -= ((BlockingQueue) thisNode.getSection(NodeSection.INPUT)).getDroppedJobPerClass(jobClass.getId());
}
//visit ratio
//
// we must consider only not dropped jobs:
// --> visit ratio = visits to this node / (visits to ref node - dropped jobs)
visitRatio = (double) (visitsThisNode) / (visitsReferenceNode - droppedJobs);
//System.out.println("refNode: " + Integer.toString(visitsReferenceNode));
//System.out.println("thisNode: " + Integer.toString(visitsThisNode));
//System.out.println("dropped: " + droppedJobs);
//System.out.println("visit ratio: " + Double.toString(visitRatio));
} catch (NetException ne) {
visitRatio = 1;
logger.error("Error in computing visit ratio.");
ne.printStackTrace();
}
}
// Measure is class-independent --> Bertoli Marco
else {
try {
Iterator<JobClass> it = network.getJobClasses().listIterator();
double ratioSum = 0.0, weight = 0.0;
while (it.hasNext()) {
JobClass jobC = it.next();
//reference node for this job class
String referenceNodeName = jobC.getReferenceNodeName();
NetNode referenceNode = network.getNode(referenceNodeName);
int visitsReferenceNode, visitsThisNode;
//visits to the reference node
NodeSection refOutputSection = referenceNode.getSection(NodeSection.OUTPUT);
visitsReferenceNode = refOutputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobC);
//visits to this node node
NodeSection thisNodeInputSection = thisNode.getSection(NodeSection.INPUT);
visitsThisNode = thisNodeInputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobC);
int droppedJobs = network.getDroppedJobs(jobC);
if (thisNodeInputSection instanceof BlockingQueue) {
visitsThisNode -= ((BlockingQueue) thisNode.getSection(NodeSection.INPUT)).getDroppedJobPerClass(jobC.getId());
}
double currVisitRatio = (double) (visitsThisNode) / (visitsReferenceNode - droppedJobs);
// Uses new calculated visit ratio to compute a weighted visit ratio