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();
}
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();
}
}
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();
}
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());
}
}
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;
}
Aggregations