use of org.iobserve.stages.general.data.PayloadAwareEntryCallEvent in project iobserve-analysis by research-iobserve.
the class GraphEditDistance method eventGroupInsertionCost.
/**
* calculates the insertion cost of an eventgroup including the insertion cost of the events
*/
private double eventGroupInsertionCost(final EventGroup eventGroup) {
double distance = GraphEditDistance.eventGroupInsertCost;
final Queue<PayloadAwareEntryCallEvent> queue = new LinkedList<>(eventGroup.getEvents());
final List<PayloadAwareEntryCallEvent> equalEvents = new ArrayList<>();
while (!queue.isEmpty()) {
final PayloadAwareEntryCallEvent event1 = queue.poll();
// look for equal events, as they can be duplicated, instead of created
for (final PayloadAwareEntryCallEvent event2 : queue) {
if (GraphEditDistance.haveSameValues(event1, event2)) {
equalEvents.add(event2);
}
}
queue.removeAll(equalEvents);
distance += equalEvents.size() * GraphEditDistance.WEIGTHING.getDuplicateCost(event1.getParameters());
distance += GraphEditDistance.WEIGTHING.getInsertCost(event1.getParameters());
}
return distance;
}
use of org.iobserve.stages.general.data.PayloadAwareEntryCallEvent in project iobserve-analysis by research-iobserve.
the class UserSessionToModelGeneratorTest method setup.
@Before
public void setup() {
final String[] parameters1 = { "view A" };
final String[] values1 = { "" };
final PayloadAwareEntryCallEvent event1 = TestHelper.createEvent(1, "A", parameters1, values1);
final String[] parameters2 = { "view B" };
final String[] values2 = { "" };
final PayloadAwareEntryCallEvent event2 = TestHelper.createEvent(2, "B", parameters2, values2);
final String[] parameters3 = { "stay at B" };
final String[] values3 = { "with value 1" };
final PayloadAwareEntryCallEvent event3 = TestHelper.createEvent(3, "B", parameters3, values3);
final String[] parameters4 = { "stay at B" };
final String[] values4 = { "with value 2" };
final PayloadAwareEntryCallEvent event4 = TestHelper.createEvent(4, "B", parameters4, values4);
final String[] parameters5 = { "stay at B with other parameter name" };
final String[] values5 = { "" };
final PayloadAwareEntryCallEvent event5 = TestHelper.createEvent(5, "B", parameters5, values5);
this.session = new UserSession("", "");
this.session.add(event1);
this.session.add(event2);
this.session.add(event3);
this.session.add(event4);
this.session.add(event5);
}
use of org.iobserve.stages.general.data.PayloadAwareEntryCallEvent in project iobserve-analysis by research-iobserve.
the class UserSessionToModelConverter method eventsToModel.
/**
* Converts a list of events into a behavior model
*
* @param events
* The list of events
* @return The behavior model
*/
public static BehaviorModelGED eventsToModel(final List<EntryCallEvent> events) {
final BehaviorModelGED model = new BehaviorModelGED();
final Iterator<EntryCallEvent> iterator = events.iterator();
// start with the node "init"
BehaviorModelNode currentNode = new BehaviorModelNode("Init");
model.getNodes().put("Init", currentNode);
BehaviorModelNode lastNode = currentNode;
// for all events
while (iterator.hasNext()) {
final PayloadAwareEntryCallEvent event = (PayloadAwareEntryCallEvent) iterator.next();
// current node is an existing node with the same name or if non-existing a new node
currentNode = model.getNodes().get(event.getOperationSignature());
if (currentNode == null) {
currentNode = new BehaviorModelNode(event.getOperationSignature());
}
// add node to model
model.getNodes().put(event.getOperationSignature(), currentNode);
// add edge to model
UserSessionToModelConverter.addEdge(event, model, lastNode, currentNode);
lastNode = currentNode;
}
return model;
}
use of org.iobserve.stages.general.data.PayloadAwareEntryCallEvent in project iobserve-analysis by research-iobserve.
the class GraphEditDistance method eventGroupDistance.
/**
* Calculates the distance between two event groups. This includes the distance between the
* contained events
*/
private double eventGroupDistance(final EventGroup eventGroup1, final EventGroup eventGroup2) {
double distance = 0;
// at first all events are unvisited
final Queue<PayloadAwareEntryCallEvent> unvisitedEvents1 = new LinkedList<>(eventGroup1.getEvents());
final Queue<PayloadAwareEntryCallEvent> unvisitedEvents2 = new LinkedList<>(eventGroup2.getEvents());
while (!unvisitedEvents1.isEmpty()) {
final List<PayloadAwareEntryCallEvent> matches1 = new ArrayList<>();
final List<PayloadAwareEntryCallEvent> matches2 = new ArrayList<>();
final PayloadAwareEntryCallEvent event = unvisitedEvents1.poll();
matches1.add(event);
// find equal events in same event group
for (final PayloadAwareEntryCallEvent potentialMatch : unvisitedEvents1) {
if (GraphEditDistance.haveSameValues(event, potentialMatch)) {
matches1.add(potentialMatch);
}
}
unvisitedEvents1.removeAll(matches1);
// find equal events in other event group
for (final PayloadAwareEntryCallEvent potentialMatch : unvisitedEvents2) {
if (GraphEditDistance.haveSameValues(event, potentialMatch)) {
matches2.add(potentialMatch);
}
}
unvisitedEvents2.removeAll(matches2);
// events have to be created in other eventgroup
if (matches2.isEmpty()) {
distance += GraphEditDistance.WEIGTHING.getInsertCost(event.getParameters());
distance += GraphEditDistance.WEIGTHING.getDuplicateCost(event.getParameters()) * (matches1.size() - 1);
} else {
// event occurs in both groups, so it has to be duplicated, till amount is the
// same
final int amountDifference = Math.abs(matches1.size() - matches2.size());
distance += GraphEditDistance.WEIGTHING.getDuplicateCost(event.getParameters()) * amountDifference;
}
}
// maybe some events are left in the second group, which weren't in the first group
while (!unvisitedEvents2.isEmpty()) {
final PayloadAwareEntryCallEvent event1 = unvisitedEvents2.poll();
final List<PayloadAwareEntryCallEvent> equalEvents = new ArrayList<>();
for (final PayloadAwareEntryCallEvent event2 : unvisitedEvents2) {
if (GraphEditDistance.haveSameValues(event1, event2)) {
equalEvents.add(event2);
}
}
unvisitedEvents2.removeAll(equalEvents);
distance += equalEvents.size() * GraphEditDistance.WEIGTHING.getDuplicateCost(event1.getParameters());
distance += GraphEditDistance.WEIGTHING.getInsertCost(event1.getParameters());
}
return distance;
}
use of org.iobserve.stages.general.data.PayloadAwareEntryCallEvent in project iobserve-analysis by research-iobserve.
the class BehaviorModelTable method addInformation.
@Override
public void addInformation(final PayloadAwareEntryCallEvent event) {
final String eventSignature = this.getSignatureFromEvent(event);
final List<CallInformation> newCallInformations = new ArrayList<>();
try {
for (int i = 0; i < event.getParameters().length; i++) {
newCallInformations.add(new CallInformation(event.getParameters()[i], String.valueOf(this.parameterValueDoubleMapper.mapValue(event.getParameters()[i], event.getValues()[i]))));
}
final List<AggregatedCallInformation> aggCallInformations = Arrays.asList(this.signatures.get(eventSignature).getSecond());
for (final CallInformation newCallInformation : newCallInformations) {
// add new CallInfromation to the aggregation correctly
final Optional<AggregatedCallInformation> match = aggCallInformations.stream().filter(aggCallInformation -> aggCallInformation.belongsTo(newCallInformation)).collect(new SingleOrNoneCollector<>());
match.ifPresent(aggCallInformation -> aggCallInformation.addCallInformation(newCallInformation));
}
} catch (final IllegalArgumentException e) {
BehaviorModelTable.LOGGER.error("Illegal argument exception", e);
}
}
Aggregations