Search in sources :

Example 1 with EntryCallNode

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

the class TBehaviorModelCreation method createEdge.

/**
 * Creates an edge from an edge representing attribute string and value.
 *
 * @param name
 *            attribute name
 * @param value
 *            attribute value
 *
 * @return EntryCallEdge
 */
private Optional<EntryCallEdge> createEdge(final String name, final Double value) {
    // only create relevant edges
    final double roundedValue = Math.floor(value);
    if (roundedValue > 0.5) {
        final String[] nodeNames = this.splitSignature(AbstractBehaviorModelTable.EDGE_INDICATOR_PATTERN, AbstractBehaviorModelTable.EDGE_DIVIDER_PATTERN, name);
        if (nodeNames.length == 2) {
            final EntryCallNode from = new EntryCallNode(nodeNames[0]);
            final EntryCallNode to = new EntryCallNode(nodeNames[1]);
            // rount
            final EntryCallEdge edge = new EntryCallEdge(from, to, roundedValue);
            return Optional.of(edge);
        }
    }
    return Optional.empty();
}
Also used : EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode)

Example 2 with EntryCallNode

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

the class TBehaviorModelCreation method createNode.

/**
 * Creates an node from a node representing attribute string and value.
 *
 * @param name
 *            attribute name
 * @param value
 *            attribute value
 *
 * @return EntryCallNode
 */
private Optional<EntryCallNode> createNode(final String name, final Double value) {
    final String[] signatures = this.splitSignature(AbstractBehaviorModelTable.INFORMATION_INDICATOR_PATTERN, AbstractBehaviorModelTable.INFORMATION_DIVIDER_PATTERN, name);
    if (signatures.length == 2) {
        final EntryCallNode node = new EntryCallNode(signatures[0]);
        final CallInformation callInformation = new CallInformation(signatures[1], value);
        node.getEntryCallInformation().add(callInformation);
        return Optional.of(node);
    } else {
        return Optional.empty();
    }
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode)

Example 3 with EntryCallNode

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

the class ComparisonOutputStage method execute.

@Override
protected void execute(final ComparisonResult result) throws IOException {
    final FileWriter fw = new FileWriter(this.outputFile);
    final BufferedWriter writer = new BufferedWriter(fw);
    final int baselineNodeCount = result.getBaselineNodes().size();
    final int testModelNodeCount = result.getTestModelNodes().size();
    final int missingNodeCount = result.getMissingNodes().size();
    final int additionalNodeCount = result.getAdditionalNodes().size();
    final int baselineEdgeCount = result.getBaselineEdges().size();
    final int testModelEdgeCount = result.getTestModelEdges().size();
    final int missingEdgeCount = result.getMissingEdgeCount();
    final int additionalEdgeCount = result.getAdditionalEdgeCount();
    writer.write("CP;" + this.outputFile.getName() + ";" + baselineNodeCount + ";" + baselineEdgeCount + ";" + testModelNodeCount + ";" + testModelEdgeCount + ";" + missingNodeCount + ";" + additionalNodeCount + ";" + missingEdgeCount + ";" + additionalEdgeCount + ";" + (double) missingNodeCount / (double) baselineNodeCount + ";" + (double) additionalNodeCount / (double) baselineNodeCount + ";" + (double) missingEdgeCount / (double) baselineEdgeCount + ";" + (double) additionalEdgeCount / (double) baselineEdgeCount + "\n");
    final List<EntryCallNode> allNodes = this.createAllNodesList(result.getBaselineNodes(), result.getTestModelNodes());
    final List<EntryCallEdge> allEdges = this.createAllEdgesList(result.getBaselineEdges(), result.getTestModelEdges());
    this.generateNodeCallInformation(writer, "baseline;" + this.outputFile.getName() + ";", allNodes, result.getBaselineNodes());
    this.generateNodeCallInformation(writer, "compared;" + this.outputFile.getName() + ";", allNodes, result.getTestModelNodes());
    writer.write("baseline;------------------------------------------ edges\n");
    writer.write("compared;------------------------------------------ edges\n");
    this.generateEdges(writer, "baseline;" + this.outputFile.getName() + ";", allEdges, result.getBaselineEdges());
    this.generateEdges(writer, "compared;" + this.outputFile.getName() + ";", allEdges, result.getTestModelEdges());
    writer.write("Nodes:\n\tmissing=" + result.getMissingNodes().size() + "\n\tadditional=" + result.getAdditionalNodes().size() + "\n");
    for (final EntryCallNode node : result.getMissingNodes()) {
        writer.write("\t - " + node.getSignature() + "\n");
    }
    for (final EntryCallNode node : result.getAdditionalNodes()) {
        writer.write("\t + " + node.getSignature() + "\n");
    }
    for (final EntryCallNode node : result.getSimilarNodes()) {
        writer.write("\t = " + node.getSignature() + "\n");
    }
    writer.write("Edges:\n\tmissing=" + result.getMissingEdgeCount() + "\n\tadditional=" + result.getAdditionalEdgeCount() + "\n");
    writer.write("Node differences:\n");
    for (final NodeDifference difference : result.getNodeDifferences()) {
        writer.write("\tNode" + difference.getReferenceNode().getSignature() + "\n");
        writer.write("\t\tMissing");
        String separator = "=";
        for (final CallInformation callInformation : difference.getMissingInformation()) {
            writer.write(separator + callInformation);
            separator = ", ";
        }
        writer.write("\n");
        writer.write("\t\tAdditional");
        separator = "=";
        for (final CallInformation callInformation : difference.getMissingInformation()) {
            writer.write(separator + callInformation);
            separator = ", ";
        }
        writer.write("\n");
    }
    writer.close();
    fw.close();
}
Also used : EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) FileWriter(java.io.FileWriter) NodeDifference(org.iobserve.evaluation.data.NodeDifference) BufferedWriter(java.io.BufferedWriter)

Example 4 with EntryCallNode

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

the class TUsageModelToBehaviorModel method findLoopStart.

/**
 * Find first {@link EntryLevelSystemCall} element of a {@link Loop} body.
 *
 * @param loop
 *            loop
 * @return first found {@link EntryLevelSystemCall}, if found
 */
private Optional<EntryCallNode> findLoopStart(final AbstractUserAction action) {
    if (action instanceof Stop) {
        // LoopStart not found
        return Optional.empty();
    } else if (action instanceof EntryLevelSystemCall) {
        // found loop start
        final EntryLevelSystemCall entryLevelSystemCall = (EntryLevelSystemCall) action;
        final EntryCallNode entryCallNode = this.createEntryCallNode(entryLevelSystemCall);
        return Optional.of(entryCallNode);
    } else if (action instanceof Loop) {
        // search nested scenario
        final Loop loop = (Loop) action;
        final List<AbstractUserAction> userActions = loop.getBodyBehaviour_Loop().getActions_ScenarioBehaviour();
        if (userActions.size() > 0) {
            return this.findLoopStart(userActions.get(0));
        } else {
            return Optional.empty();
        }
    } else if (action instanceof Branch) {
        // will always found before
        return Optional.empty();
    } else {
        // next action
        return this.findLoopStart(action.getSuccessor());
    }
}
Also used : Loop(org.palladiosimulator.pcm.usagemodel.Loop) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) Stop(org.palladiosimulator.pcm.usagemodel.Stop) Branch(org.palladiosimulator.pcm.usagemodel.Branch)

Example 5 with EntryCallNode

use of org.iobserve.analysis.clustering.filter.models.EntryCallNode 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

EntryCallNode (org.iobserve.analysis.clustering.filter.models.EntryCallNode)11 CallInformation (org.iobserve.analysis.clustering.filter.models.CallInformation)5 EntryCallEdge (org.iobserve.analysis.clustering.filter.models.EntryCallEdge)5 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)3 Branch (org.palladiosimulator.pcm.usagemodel.Branch)3 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)3 Loop (org.palladiosimulator.pcm.usagemodel.Loop)3 Stop (org.palladiosimulator.pcm.usagemodel.Stop)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 SingleOrNoneCollector (org.iobserve.analysis.clustering.SingleOrNoneCollector)2 BehaviorModel (org.iobserve.analysis.clustering.filter.models.BehaviorModel)2 NodeDifference (org.iobserve.evaluation.data.NodeDifference)2 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)2 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)2 Start (org.palladiosimulator.pcm.usagemodel.Start)2 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)2 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)2