if (regions != null) {
//at least one region has been defined
for (BlockingRegion region : regions) {
BlockingRegion reg = region;
if (!reg.hasGlobalConstraint()) {
continue;
}
//max capacity
double maxCapacity = reg.getMaxCapacity();
String[] stations = reg.getRegionNodeNames();
double classTotalQueue, regUtilization;
double classWeight;
String className;
for (int c = 0; c < classNumber; c++) {
className = classes[c].getName();
//logger.debug("Computing region U for class " + className);
classWeight = reg.getClassWeights()[c];
classTotalQueue = 0.0;
boolean success = true;
if (classWeight == 0.0) {
regUtilization = 0.0;
} else {
for (String station : stations) {
double queue = findQueueMeasure(className, station);
if (queue == -1) {
success = false;
break;
}
//logger.debug("Queue at station " + stations[s] + ": " + Double.toString(queue));
classTotalQueue += queue;
}
if (success) {
//logger.debug("Total queue: " + Double.toString(classTotalQueue));
//logger.debug("Weight: " + Double.toString(classWeight));
regUtilization = (classTotalQueue * classWeight) / maxCapacity;
logger.debug("Region Utilization for " + reg.getName() + "-" + className + ": " + Double.toString(regUtilization));
} else {
//regUtilization = -1;
regUtilization = Double.NEGATIVE_INFINITY;
logger.debug("Region Utilization for " + reg.getName() + "-" + className + " not computed");
}
}
Element el = doc.createElement("measure");
root.appendChild(el);
String inputStation = reg.getInputStation().getName();
el.setAttribute("station", inputStation);
el.setAttribute("class", className);
el.setAttribute("meanValue", Double.toString(regUtilization));
el.setAttribute("successful", Boolean.toString(success));
el.setAttribute("measureType", "Region Utilization");