Search in sources :

Example 1 with OpenWorkload

use of org.palladiosimulator.pcm.usagemodel.OpenWorkload 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;
}
Also used : ClosedWorkload(org.palladiosimulator.pcm.usagemodel.ClosedWorkload) OpenWorkloadImpl(org.palladiosimulator.pcm.usagemodel.impl.OpenWorkloadImpl) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) OpenWorkload(org.palladiosimulator.pcm.usagemodel.OpenWorkload) Workload(org.palladiosimulator.pcm.usagemodel.Workload) OpenWorkload(org.palladiosimulator.pcm.usagemodel.OpenWorkload) ClosedWorkload(org.palladiosimulator.pcm.usagemodel.ClosedWorkload)

Example 2 with OpenWorkload

use of org.palladiosimulator.pcm.usagemodel.OpenWorkload in project iobserve-analysis by research-iobserve.

the class UsageModelFactory method createOpenWorkload.

/**
 * Create an {@link OpenWorkload} and add it to the given {@link UsageScenario}.
 *
 * @param avgInterarrivalTime
 *            the interarrival time
 * @param parent
 *            usage scenario the workload should be added to
 * @return brand new instance of {@link OpenWorkload}
 */
public static OpenWorkload createOpenWorkload(final long avgInterarrivalTime, final UsageScenario parent) {
    final OpenWorkload openWorkload = UsagemodelFactory.eINSTANCE.createOpenWorkload();
    parent.setWorkload_UsageScenario(openWorkload);
    // create variables
    final PCMRandomVariable pcmInterarrivalTime = CoreFactory.eINSTANCE.createPCMRandomVariable();
    pcmInterarrivalTime.setSpecification(String.valueOf(avgInterarrivalTime));
    pcmInterarrivalTime.setOpenWorkload_PCMRandomVariable(openWorkload);
    openWorkload.setInterArrivalTime_OpenWorkload(pcmInterarrivalTime);
    return openWorkload;
}
Also used : OpenWorkload(org.palladiosimulator.pcm.usagemodel.OpenWorkload) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Aggregations

OpenWorkload (org.palladiosimulator.pcm.usagemodel.OpenWorkload)2 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)1 ClosedWorkload (org.palladiosimulator.pcm.usagemodel.ClosedWorkload)1 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)1 Workload (org.palladiosimulator.pcm.usagemodel.Workload)1 OpenWorkloadImpl (org.palladiosimulator.pcm.usagemodel.impl.OpenWorkloadImpl)1