use of org.palladiosimulator.pcm.usagemodel.Workload in project iobserve-analysis by research-iobserve.
the class WorkloadEvaluation method calculateRME.
/**
* Calculates the relative measurement error between a reference workload and the approach's
* calculated workload. For an open workload the relative error of the mean inter arrival time
* is calculated. For a closed workload the relative error of the mean number of concurrent
* users is calculated. RME = (mw - rw) / rw, mw = measured workload, rw = reference workload
*
* @param usageModel
* contains the calculated workload
* @param referenceElements
* contains the reference workload
* @return return the relative measurement error
*/
public static double calculateRME(final UsageModel usageModel, final ReferenceElements referenceElements) {
double rme = 0;
final UsageScenario usageScenarioOfUsageModel = usageModel.getUsageScenario_UsageModel().get(0);
final Workload workload = usageScenarioOfUsageModel.getWorkload_UsageScenario();
// We distinguish between a closed and an open workload
if (workload.getClass().equals(ClosedWorkloadImpl.class)) {
final ClosedWorkload closedWorkloadOfUsageModel = (ClosedWorkload) workload;
// The RME is calculated by the mean number of concurrent users that states the
// population count of a closed workload
final int usageModelWorkload = closedWorkloadOfUsageModel.getPopulation();
final int referenceWorkload = referenceElements.getMeanConcurrentUserSessions();
rme = (1.0 * usageModelWorkload - 1.0 * referenceWorkload) / (1.0 * referenceWorkload);
} else if (workload.getClass().equals(OpenWorkloadImpl.class)) {
final OpenWorkload openWorkloadOfUsageModel = (OpenWorkload) workload;
final String interArrivalTime = openWorkloadOfUsageModel.getInterArrivalTime_OpenWorkload().getSpecification();
// The RME is calculated by the mean inter arrival time that states an open workload
final long usageModelWorkload = Long.parseLong(interArrivalTime);
final long referenceWorkload = referenceElements.getMeanInterArrivalTime();
rme = (1.0 * usageModelWorkload - 1.0 * referenceWorkload) / (1.0 * referenceWorkload);
}
rme = Math.abs(rme) * 100;
return rme;
}
Aggregations