Search in sources :

Example 1 with BehaviorModel

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

the class TBehaviorModelCreation method execute.

@Override
protected void execute(final Instances instances) {
    final int size = instances.numInstances();
    for (int i = 0; i < size; i++) {
        final Instance instance = instances.instance(i);
        final Optional<BehaviorModel> behaviorModel = this.createBehaviorModel(instances, instance);
        final String modelName = this.namePrefix + i;
        behaviorModel.ifPresent(model -> model.setName(modelName));
        behaviorModel.ifPresent(this.outputPort::send);
    }
}
Also used : Instance(weka.core.Instance) BehaviorModel(org.iobserve.analysis.clustering.filter.models.BehaviorModel)

Example 2 with BehaviorModel

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

the class TBehaviorModelCreation method createBehaviorModel.

/**
 * create a BehaviorModel from Instance.
 *
 * @param instances
 *            instances containing the attribute names
 * @param instance
 *            instance containing the attributes
 * @return behavior model if relevant
 */
private Optional<BehaviorModel> createBehaviorModel(final Instances instances, final Instance instance) {
    final int size = instance.numAttributes();
    final BehaviorModel behaviorModel = new BehaviorModel();
    for (int i = 0; i < size; i++) {
        final Attribute attribute = instances.attribute(i);
        final String attributeName = attribute.name();
        final Double attributeValue = instance.value(attribute);
        if (this.matchEdge(attributeName)) {
            final Optional<EntryCallEdge> edge = this.createEdge(attributeName, attributeValue);
            if (edge.isPresent()) {
                behaviorModel.addEdge(edge.get());
            }
        } else if (this.matchNode(attributeName)) {
            final Optional<EntryCallNode> node = this.createNode(attributeName, attributeValue);
            if (node.isPresent()) {
                behaviorModel.addNode(node.get());
            }
        }
    }
    if (behaviorModel.getEdges().isEmpty() && behaviorModel.getNodes().isEmpty()) {
        return Optional.empty();
    }
    return Optional.of(behaviorModel);
}
Also used : EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) Optional(java.util.Optional) Attribute(weka.core.Attribute) BehaviorModel(org.iobserve.analysis.clustering.filter.models.BehaviorModel)

Example 3 with BehaviorModel

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

the class ModelComparisonStageTest method createReferenceModel.

private BehaviorModel createReferenceModel() {
    final BehaviorModel model = new BehaviorModel();
    model.addNode(this.nodeA);
    model.addNode(this.nodeB);
    model.addNode(this.nodeC);
    final EntryCallEdge edgeAB = new EntryCallEdge(this.nodeA, this.nodeB);
    edgeAB.addCalls(4);
    model.addEdge(edgeAB);
    final EntryCallEdge edgeBA = new EntryCallEdge(this.nodeB, this.nodeA);
    edgeBA.addCalls(3);
    model.addEdge(edgeBA);
    final EntryCallEdge edgeBC = new EntryCallEdge(this.nodeB, this.nodeC);
    edgeBA.addCalls(1);
    model.addEdge(edgeBC);
    return model;
}
Also used : EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) BehaviorModel(org.iobserve.analysis.clustering.filter.models.BehaviorModel)

Example 4 with BehaviorModel

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

the class ModelComparisonStageTest method createTestModel.

private BehaviorModel createTestModel() {
    final BehaviorModel model = new BehaviorModel();
    model.addNode(this.nodeAtest);
    model.addNode(this.nodeBtest);
    model.addNode(this.nodeDtest);
    final EntryCallEdge edgeAB = new EntryCallEdge(this.nodeAtest, this.nodeBtest);
    edgeAB.addCalls(4);
    model.addEdge(edgeAB);
    final EntryCallEdge edgeBA = new EntryCallEdge(this.nodeBtest, this.nodeAtest);
    edgeBA.addCalls(3);
    model.addEdge(edgeBA);
    final EntryCallEdge edgeBD = new EntryCallEdge(this.nodeBtest, this.nodeDtest);
    edgeBA.addCalls(1);
    model.addEdge(edgeBD);
    return model;
}
Also used : EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) BehaviorModel(org.iobserve.analysis.clustering.filter.models.BehaviorModel)

Example 5 with BehaviorModel

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

the class TUsageModelToBehaviorModel method traverseBranch.

private Map<EntryCallNode, Double> traverseBranch(final BehaviorModel behaviorModel, final Optional<Map<EntryCallNode, Double>> optPreviousNodes, final Branch branch) {
    // assign new probabilities to the nodes
    final Map<BranchTransition, Map<EntryCallNode, Double>> transitionMap = new HashMap<>();
    for (final BranchTransition transition : branch.getBranchTransitions_Branch()) {
        final Map<EntryCallNode, Double> branchMap = new HashMap<>();
        optPreviousNodes.ifPresent(previousNodes -> previousNodes.keySet().stream().forEach(node -> branchMap.put(node, transition.getBranchProbability())));
        transitionMap.put(transition, branchMap);
    }
    // traverse all branches and collect the end nodes
    final Map<EntryCallNode, Double> endNodes = branch.getBranchTransitions_Branch().stream().map(transition -> this.traverseScenarioBehavior(transition.getBranchedBehaviour_BranchTransition(), behaviorModel, // all
    Optional.of(transitionMap.get(transition)))).collect(HashMap::new, Map::putAll, // collect endNodes
    Map::putAll);
    return endNodes;
}
Also used : 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) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) HashMap(java.util.HashMap) BranchTransition(org.palladiosimulator.pcm.usagemodel.BranchTransition) HashMap(java.util.HashMap) Map(java.util.Map)

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