use of org.palladiosimulator.pcm.usagemodel.ClosedWorkload in project Palladio-Editors-Sirius by PalladioSimulator.
the class ClosedWorkloadThinkTimeAction method getRandomVariable.
@Override
public RandomVariable getRandomVariable(EObject element) {
ClosedWorkload workload = (ClosedWorkload) element;
PCMRandomVariable rv = workload.getThinkTime_ClosedWorkload();
return rv;
}
use of org.palladiosimulator.pcm.usagemodel.ClosedWorkload 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;
}
use of org.palladiosimulator.pcm.usagemodel.ClosedWorkload in project iobserve-analysis by research-iobserve.
the class UsageModelDataFactory method createUsageModel.
/**
* Create a usage model.
*
* @return returns a usage model
*/
public static UsageModel createUsageModel() {
final UsageModel usageModel = UsagemodelFactory.eINSTANCE.createUsageModel();
// Think time
final PCMRandomVariable thinkTime = CoreFactory.eINSTANCE.createPCMRandomVariable();
thinkTime.setSpecification("5.0");
// Closed workload
final ClosedWorkload closedWorkload = UsagemodelFactory.eINSTANCE.createClosedWorkload();
closedWorkload.setPopulation(2);
closedWorkload.setThinkTime_ClosedWorkload(thinkTime);
// Scenario behavior
final ScenarioBehaviour buyBookScenarioBehaviour = UsageModelDataFactory.createScenarionBehaviorBuyaBook();
// Usage scenario
final UsageScenario usageScenarioGroup0 = UsagemodelFactory.eINSTANCE.createUsageScenario();
usageScenarioGroup0.setEntityName(UsageModelDataFactory.USAGE_SCENARIO_GROUP_0);
usageScenarioGroup0.setScenarioBehaviour_UsageScenario(buyBookScenarioBehaviour);
usageScenarioGroup0.setWorkload_UsageScenario(closedWorkload);
usageModel.getUsageScenario_UsageModel().add(usageScenarioGroup0);
return usageModel;
}
use of org.palladiosimulator.pcm.usagemodel.ClosedWorkload in project iobserve-analysis by research-iobserve.
the class UsageModelFactory method createClosedWorkload.
/**
* Create an {@link OpenWorkload} and add it to the given {@link UsageScenario}.
*
* @param population
* population
* @param thinkTime
* thinkTime
* @param parent
* usage scenario the workload should be added to
* @return created closed workload instance
*/
public static ClosedWorkload createClosedWorkload(final int population, final double thinkTime, final UsageScenario parent) {
final ClosedWorkload closedWorkload = UsagemodelFactory.eINSTANCE.createClosedWorkload();
parent.setWorkload_UsageScenario(closedWorkload);
// create variables
final PCMRandomVariable pcmThinkTime = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmThinkTime.setSpecification(String.valueOf(thinkTime));
pcmThinkTime.setClosedWorkload_PCMRandomVariable(closedWorkload);
closedWorkload.setPopulation(population);
closedWorkload.setThinkTime_ClosedWorkload(pcmThinkTime);
return closedWorkload;
}
use of org.palladiosimulator.pcm.usagemodel.ClosedWorkload in project iobserve-analysis by research-iobserve.
the class WorkloadEvaluationHelper 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