Search in sources :

Example 1 with UserBehaviorTransformation

use of org.iobserve.analysis.behavior.karlsruhe.UserBehaviorTransformation in project iobserve-analysis by research-iobserve.

the class TEntryEventSequence method execute.

@Override
protected void execute(final UserSessionCollectionModel entryCallSequenceModel) throws DBException {
    // Resets the current usage model
    final UsageModel model = this.usageModelProvider.getAndLockModelRootNode(UsageModel.class, UsagemodelPackage.Literals.USAGE_MODEL);
    int numberOfUserGroups = model.getUsageScenario_UsageModel().size();
    TEntryEventSequence.LOGGER.debug("EntryEventSequence found: numberOfUserGroups before: {}", numberOfUserGroups);
    // Executes the user behavior modeling procedure
    final UserBehaviorTransformation behaviorModeling = new UserBehaviorTransformation(entryCallSequenceModel, numberOfUserGroups, this.varianceOfUserGroups, this.closedWorkload, this.thinkTime, this.repositoryLookupModel, this.correspondenceModel);
    try {
        behaviorModeling.modelUserBehavior();
        model.getUsageScenario_UsageModel().clear();
        model.getUserData_UsageModel().clear();
        final UsageModel newModel = behaviorModeling.getPcmUsageModel();
        model.getUsageScenario_UsageModel().addAll(newModel.getUsageScenario_UsageModel());
        model.getUserData_UsageModel().addAll(newModel.getUserData_UsageModel());
        numberOfUserGroups = model.getUsageScenario_UsageModel().size();
        TEntryEventSequence.LOGGER.debug("Model changed: numberOfUserGroups after: {}", numberOfUserGroups);
    } catch (final IOException e) {
        e.printStackTrace();
    }
    // Sets the new usage model within iObserve
    this.usageModelProvider.clearResource();
    try {
        this.usageModelProvider.storeModelPartition(model);
    } catch (final DBException e) {
        e.printStackTrace();
    }
    this.outputPort.send(behaviorModeling.getPcmUsageModel());
    this.outputPortSnapshot.send(false);
}
Also used : DBException(org.iobserve.model.persistence.DBException) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) IOException(java.io.IOException) UserBehaviorTransformation(org.iobserve.analysis.behavior.karlsruhe.UserBehaviorTransformation)

Example 2 with UserBehaviorTransformation

use of org.iobserve.analysis.behavior.karlsruhe.UserBehaviorTransformation in project iobserve-analysis by research-iobserve.

the class UserBehaviorTransformationTest method testBranchWithinLoop.

/**
 * TODO this test is dysfunctional as models are missing Test branch within a loop.
 *
 * @throws IOException
 *             when reading and writing files.
 * @throws DBException
 */
// @Test
public void testBranchWithinLoop() throws IOException, DBException {
    final Neo4JModelResource<Repository> repositoryModelProvider = new Neo4JModelResource<>(RepositoryPackage.eINSTANCE, new File("x"));
    final RepositoryLookupModelProvider repositoryLookupModel = new RepositoryLookupModelProvider(repositoryModelProvider.getAndLockModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY));
    final int numberOfIterations = 500;
    final int stepSize = 1;
    final List<AccuracyResults> results = new ArrayList<>();
    for (int i = 1; i <= numberOfIterations; i += stepSize) {
        final int numberOfUserGroups = UserBehaviorTransformationTest.NUMBER_OF_USER_GROUPS;
        final int varianceOfUserGroups = 0;
        final int thinkTime = UserBehaviorTransformationTest.THINK_TIME;
        final boolean isClosedWorkload = UserBehaviorTransformationTest.CLOSED_WORKLOAD;
        final ReferenceElements referenceElements = SimpleSequenceReferenceHelper.getModel(UserBehaviorTransformationTest.REFERENCE_USAGE_MODEL, repositoryLookupModel, null, thinkTime, isClosedWorkload);
        final UserBehaviorTransformation behaviorModeling = new UserBehaviorTransformation(referenceElements.getEntryCallSequenceModel(), numberOfUserGroups, varianceOfUserGroups, isClosedWorkload, thinkTime, repositoryLookupModel, null);
        behaviorModeling.modelUserBehavior();
        final AccuracyResults accuracyResults = UserBehaviorEvaluation.matchUsageModels(behaviorModeling.getPcmUsageModel(), referenceElements.getUsageModel());
        results.add(accuracyResults);
        final double relativeMeasurementError = WorkloadEvaluationHelper.calculateRME(behaviorModeling.getPcmUsageModel(), referenceElements);
        if (UserBehaviorTransformationTest.LOGGER.isDebugEnabled()) {
            UserBehaviorTransformationTest.LOGGER.debug("RME " + relativeMeasurementError);
        }
        TestHelper.saveModel(behaviorModeling.getPcmUsageModel(), UserBehaviorTransformationTest.OUTPUT_USAGE_MODEL);
        if (UserBehaviorTransformationTest.LOGGER.isDebugEnabled()) {
            UserBehaviorTransformationTest.LOGGER.debug("Iteration :" + i + "/" + numberOfIterations);
        }
    }
    TestHelper.writeAccuracyResults(results);
}
Also used : Neo4JModelResource(org.iobserve.model.persistence.neo4j.Neo4JModelResource) ArrayList(java.util.ArrayList) Repository(org.palladiosimulator.pcm.repository.Repository) UserBehaviorTransformation(org.iobserve.analysis.behavior.karlsruhe.UserBehaviorTransformation) File(java.io.File) RepositoryLookupModelProvider(org.iobserve.model.provider.deprecated.RepositoryLookupModelProvider)

Aggregations

UserBehaviorTransformation (org.iobserve.analysis.behavior.karlsruhe.UserBehaviorTransformation)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DBException (org.iobserve.model.persistence.DBException)1 Neo4JModelResource (org.iobserve.model.persistence.neo4j.Neo4JModelResource)1 RepositoryLookupModelProvider (org.iobserve.model.provider.deprecated.RepositoryLookupModelProvider)1 Repository (org.palladiosimulator.pcm.repository.Repository)1 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)1