Search in sources :

Example 1 with NodeDifference

use of org.iobserve.evaluation.data.NodeDifference 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 2 with NodeDifference

use of org.iobserve.evaluation.data.NodeDifference in project iobserve-analysis by research-iobserve.

the class ModelComparisonStage method execute.

/*
     * (non-Javadoc)
     *
     * @see teetime.framework.AbstractStage#execute()
     */
@Override
protected void execute() throws Exception {
    /**
     * We cannot user else if here, as (a) there could be an input at each input port, (b) there
     * could be a model at testModel but not at the referenceModel input, in an if-then-else
     * style, the test model would not be received until we have a reference model, which
     * unnecessarily would imply a sequence between both ports.
     */
    if (this.referenceModel == null) {
        this.referenceModel = this.referenceModelInputPort.receive();
    }
    if (this.testModel == null) {
        this.testModel = this.testModelInputPort.receive();
    }
    /**
     * We still have to check both, as there could be nothing a both ports.
     */
    if (this.referenceModel != null && this.testModel != null) {
        final ComparisonResult result = new ComparisonResult();
        result.getBaselineNodes().addAll(this.referenceModel.getNodes());
        result.getBaselineEdges().addAll(this.referenceModel.getEdges());
        result.getTestModelNodes().addAll(this.testModel.getNodes());
        result.getTestModelEdges().addAll(this.testModel.getEdges());
        /**
         * Missing nodes.
         */
        for (final EntryCallNode baselineNode : this.referenceModel.getNodes()) {
            final EntryCallNode testModelNode = this.findMatchingModelNode(this.testModel.getNodes(), baselineNode);
            if (testModelNode == null) {
                result.getMissingNodes().add(baselineNode);
            } else {
                result.getSimilarNodes().add(baselineNode);
                /**
                 * Compute mismatch in call information.
                 */
                final List<CallInformation> missingInformation = this.computeAdditionalInformation(baselineNode.getEntryCallInformation(), testModelNode.getEntryCallInformation());
                final List<CallInformation> additionalInformation = this.computeAdditionalInformation(testModelNode.getEntryCallInformation(), baselineNode.getEntryCallInformation());
                result.getNodeDifferences().add(new NodeDifference(baselineNode, testModelNode, missingInformation, additionalInformation));
            }
        }
        /**
         * Additional nodes.
         */
        for (final EntryCallNode testModelNode : this.testModel.getNodes()) {
            final EntryCallNode baselineNode = this.findMatchingModelNode(this.referenceModel.getNodes(), testModelNode);
            if (baselineNode == null) {
                result.getAdditionalNodes().add(testModelNode);
            }
        }
        /**
         * Missing edges.
         */
        int missingEdgeCount = 0;
        for (final EntryCallEdge baselineEdge : this.referenceModel.getEdges()) {
            final EntryCallEdge testModelEdge = this.findMatchingModelEdge(this.testModel.getEdges(), baselineEdge);
            if (testModelEdge == null) {
                missingEdgeCount += (int) baselineEdge.getCalls();
            } else {
                missingEdgeCount += Math.abs((int) (baselineEdge.getCalls() - testModelEdge.getCalls()));
            }
        }
        result.setMissingEdgeCount(missingEdgeCount);
        /**
         * Additional edges.
         */
        int additionalEdgeCount = 0;
        for (final EntryCallEdge testModelEdge : this.testModel.getEdges()) {
            final EntryCallEdge baselineEdge = this.findMatchingModelEdge(this.referenceModel.getEdges(), testModelEdge);
            if (baselineEdge == null) {
                additionalEdgeCount += (int) testModelEdge.getCalls();
            } else {
                additionalEdgeCount += Math.abs((int) (baselineEdge.getCalls() - testModelEdge.getCalls()));
            }
        }
        result.setAdditionalEdgeCount(additionalEdgeCount);
        /**
         * Forget models after processing to be able to process the next elements.
         */
        this.referenceModel = null;
        this.testModel = null;
        /**
         * Add baseline and testModelNodes
         */
        this.resultPort.send(result);
    }
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) NodeDifference(org.iobserve.evaluation.data.NodeDifference) ComparisonResult(org.iobserve.evaluation.data.ComparisonResult)

Example 3 with NodeDifference

use of org.iobserve.evaluation.data.NodeDifference in project iobserve-analysis by research-iobserve.

the class ModelComparisonStageTest method setUp.

/**
 * Setup test by creating input and output models.
 */
@Before
public void setUp() {
    this.expectedResult.setAdditionalEdgeCount(1);
    this.expectedResult.getAdditionalNodes().add(this.nodeDtest);
    this.expectedResult.getBaselineEdges().addAll(this.referenceModel.getEdges());
    this.expectedResult.getBaselineNodes().addAll(this.referenceModel.getNodes());
    this.expectedResult.setMissingEdgeCount(1);
    this.expectedResult.getMissingNodes().add(this.nodeC);
    this.expectedResult.getSimilarNodes().add(this.nodeA);
    final List<CallInformation> missingInformation = new ArrayList<>();
    final List<CallInformation> additionalInformation = new ArrayList<>();
    final NodeDifference nodeDiff = new NodeDifference(this.nodeA, this.nodeAtest, missingInformation, additionalInformation);
    final NodeDifference nodeDiff2 = new NodeDifference(this.nodeB, this.nodeBtest, missingInformation, additionalInformation);
    this.expectedResult.getNodeDifferences().add(nodeDiff2);
    this.expectedResult.getNodeDifferences().add(nodeDiff);
    this.expectedResult.getSimilarNodes().add(this.nodeB);
    this.expectedResult.getTestModelEdges().addAll(this.testModel.getEdges());
    this.expectedResult.getTestModelNodes().addAll(this.testModel.getNodes());
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) NodeDifference(org.iobserve.evaluation.data.NodeDifference) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Aggregations

CallInformation (org.iobserve.analysis.clustering.filter.models.CallInformation)3 NodeDifference (org.iobserve.evaluation.data.NodeDifference)3 EntryCallEdge (org.iobserve.analysis.clustering.filter.models.EntryCallEdge)2 EntryCallNode (org.iobserve.analysis.clustering.filter.models.EntryCallNode)2 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 ComparisonResult (org.iobserve.evaluation.data.ComparisonResult)1 Before (org.junit.Before)1