Search in sources :

Example 6 with BehaviorModel

use of org.iobserve.analysis.clustering.filter.models.BehaviorModel in project iobserve-analysis by research-iobserve.

the class TUsageModelToBehaviorModel method createBehaviorModel.

/**
 * send user behavior to ui.
 *
 * @param behavior
 *            user behavior
 *
 * @return behaviorModel
 */
private Optional<BehaviorModel> createBehaviorModel(final ScenarioBehaviour behavior) {
    if (!behavior.getActions_ScenarioBehaviour().isEmpty()) {
        final BehaviorModel behaviorModel = new BehaviorModel();
        this.traverseScenarioBehavior(behavior, behaviorModel, Optional.empty());
        behaviorModel.setName("mpe-behavior");
        return Optional.of(behaviorModel);
    } else {
        return Optional.empty();
    }
}
Also used : BehaviorModel(org.iobserve.analysis.clustering.filter.models.BehaviorModel)

Example 7 with BehaviorModel

use of org.iobserve.analysis.clustering.filter.models.BehaviorModel in project iobserve-analysis by research-iobserve.

the class TUsageModelToBehaviorModel method traverseAction.

private Map<EntryCallNode, Double> traverseAction(final BehaviorModel behaviorModel, final Optional<Map<EntryCallNode, Double>> optPreviousNodes, final AbstractUserAction action) {
    if (action instanceof Branch) {
        final Branch branch = (Branch) action;
        return this.traverseBranch(behaviorModel, optPreviousNodes, branch);
    } else if (action instanceof Loop) {
        final Loop loop = (Loop) action;
        return this.traverseLoop(behaviorModel, optPreviousNodes, loop);
    } else if (action instanceof EntryLevelSystemCall) {
        final Map<EntryCallNode, Double> endNodes = new HashMap<>();
        final EntryLevelSystemCall entryLevelSystemCall = (EntryLevelSystemCall) action;
        final EntryCallNode entryCallNode = this.createEntryCallNode(entryLevelSystemCall);
        behaviorModel.addNode(entryCallNode);
        if (optPreviousNodes.isPresent()) {
            optPreviousNodes.get().keySet().stream().map(previousNode -> new EntryCallEdge(previousNode, entryCallNode, optPreviousNodes.get().get(previousNode))).forEach(behaviorModel::addEdge);
        }
        endNodes.put(entryCallNode, 1.0);
        return this.traverseAction(behaviorModel, Optional.of(endNodes), action.getSuccessor());
    } else if (action instanceof Stop) {
        return optPreviousNodes.isPresent() ? optPreviousNodes.get() : new HashMap<>();
    } else {
        // skip action
        return this.traverseAction(behaviorModel, optPreviousNodes, action.getSuccessor());
    }
}
Also used : Loop(org.palladiosimulator.pcm.usagemodel.Loop) SingleOrNoneCollector(org.iobserve.analysis.clustering.SingleOrNoneCollector) BranchTransition(org.palladiosimulator.pcm.usagemodel.BranchTransition) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) HashMap(java.util.HashMap) OutputPort(teetime.framework.OutputPort) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) List(java.util.List) AbstractConsumerStage(teetime.framework.AbstractConsumerStage) Map(java.util.Map) BehaviorModel(org.iobserve.analysis.clustering.filter.models.BehaviorModel) EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) Optional(java.util.Optional) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Branch(org.palladiosimulator.pcm.usagemodel.Branch) Start(org.palladiosimulator.pcm.usagemodel.Start) Loop(org.palladiosimulator.pcm.usagemodel.Loop) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) Stop(org.palladiosimulator.pcm.usagemodel.Stop) EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) HashMap(java.util.HashMap) Stop(org.palladiosimulator.pcm.usagemodel.Stop) Branch(org.palladiosimulator.pcm.usagemodel.Branch)

Aggregations

BehaviorModel (org.iobserve.analysis.clustering.filter.models.BehaviorModel)7 EntryCallEdge (org.iobserve.analysis.clustering.filter.models.EntryCallEdge)5 Optional (java.util.Optional)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 SingleOrNoneCollector (org.iobserve.analysis.clustering.SingleOrNoneCollector)2 EntryCallNode (org.iobserve.analysis.clustering.filter.models.EntryCallNode)2 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)2 Branch (org.palladiosimulator.pcm.usagemodel.Branch)2 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)2 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)2 Loop (org.palladiosimulator.pcm.usagemodel.Loop)2 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)2 Start (org.palladiosimulator.pcm.usagemodel.Start)2 Stop (org.palladiosimulator.pcm.usagemodel.Stop)2 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)2 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)2 AbstractConsumerStage (teetime.framework.AbstractConsumerStage)2 OutputPort (teetime.framework.OutputPort)2