use of org.iobserve.analysis.clustering.filter.models.EntryCallEdge 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.EntryCallEdge 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);
}
use of org.iobserve.analysis.clustering.filter.models.EntryCallEdge 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;
}
use of org.iobserve.analysis.clustering.filter.models.EntryCallEdge 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;
}
use of org.iobserve.analysis.clustering.filter.models.EntryCallEdge in project iobserve-analysis by research-iobserve.
the class TBehaviorModelVisualization method createEdges.
/**
* create new edges at visualization backend.
*
* @param entryCallEdges
* entryCallEdges
* @param modelId
* modelId
*/
private void createEdges(final Set<EntryCallEdge> entryCallEdges, final long modelId) {
final ArrayNode edges = this.objectMapper.createArrayNode();
for (final EntryCallEdge entryCallEdge : entryCallEdges) {
final ObjectNode json = this.objectMapper.createObjectNode();
final String sourceSignature = entryCallEdge.getSource().getSignature();
final String targetSignature = entryCallEdge.getTarget().getSignature();
json.put("id", 0);
json.put("start", this.nodeMap.get(sourceSignature));
json.put("end", this.nodeMap.get(targetSignature));
json.put("action", String.format("%s->%s", sourceSignature, targetSignature));
json.put("count", entryCallEdge.getCalls());
this.postElement(json, this.getEdgeUrl(modelId));
edges.add(json);
}
}
Aggregations