use of org.iobserve.analysis.behavior.karlsruhe.data.BranchModel in project iobserve-analysis by research-iobserve.
the class BranchModelCreator method createCallBranchModel.
/**
* It creates a BranchModel from an EntryCallSequenceModel. At that the single sequences are
* aggregated to a tree-like structure: Equal sequences are summarized to one sequence,
* alternative sequences are represented via branches.
*
* @param entryCallSequenceModel
* whose call sequences are aggregated to a coherent CallBranchModel
* @return a BranchModel corresponding to the passed EntryCallSequenceModel
*/
public BranchModel createCallBranchModel(final UserSessionCollectionModel entryCallSequenceModel) {
// Sets the user group's specific workload intensity and likelihood
final BranchModel branchModel = new BranchModel(entryCallSequenceModel.getWorkloadIntensity(), entryCallSequenceModel.getLikelihoodOfUserGroup());
final List<UserSession> userSessions = entryCallSequenceModel.getUserSessions();
// The initial branch that contains the root node
// Every sequence passes this branch -> likelihood of reaching this branch is 1
final Branch rootBranch = new Branch();
rootBranch.setBranchLikelihood(1);
rootBranch.setBranchId(1);
rootBranch.setTreeLevel(0);
// Descending sort by call sequence length
Collections.sort(userSessions, BranchModelCreator.SORT_USER_SESSION_BY_CALL_SEQUENCE_SIZE);
// Initializes the root sequence with the longest call sequence
this.setBranchSequence(rootBranch, userSessions.get(0).getEvents(), 0);
int numberOfBranches = 1;
// loops over all userSession without the first user session that initialized the rootBranch
for (int j = 1; j < userSessions.size(); j++) {
final UserSession userSession = userSessions.get(j);
// The branchGuide guides through the tree structure. It determines the recent regarded
// branch
final List<Integer> branchGuide = new ArrayList<>();
// The position states the recent position within the branch sequence
int positionInBranch = 0;
for (int i = 0; i <= userSession.getEvents().size(); i++) {
// Determines which branch is currently examined
final Branch examinedBranch = this.getExaminedBranch(branchGuide, rootBranch);
if (i < userSession.getEvents().size()) {
final EntryCallEvent callEvent = userSession.getEvents().get(i);
// currently examined branch
if (this.checkPositionMatchInBranch(callEvent, examinedBranch, positionInBranch)) {
this.incrementCountOfBranchElement(examinedBranch, positionInBranch);
positionInBranch++;
continue;
}
// a child branch
if (this.isPositionLastElementInBranchSequence(examinedBranch, positionInBranch)) {
final int indexOfMatchingChildBranch = this.getIndexOfMatchingChildBranch(callEvent, examinedBranch);
if (indexOfMatchingChildBranch > -1) {
// Continue with the same call event but switching to the new branch
branchGuide.add(indexOfMatchingChildBranch);
// NOCS
i--;
positionInBranch = 0;
continue;
}
}
// No match could be found --> Split branch into child branches
numberOfBranches = this.splitBranch(examinedBranch, positionInBranch, numberOfBranches, false, userSession, i);
break;
} else {
// End of sequence -> looking for an exit element
if (this.checkIfBranchSequenceTerminates(examinedBranch, positionInBranch)) {
this.incrementCountOfBranchElement(examinedBranch, positionInBranch);
break;
}
// Checks if there is an exit branch
if (this.isPositionLastElementInBranchSequence(examinedBranch, positionInBranch)) {
final int indexOfMatchingChildBranch = this.getIndexOfMatchingExitBranch(examinedBranch);
if (indexOfMatchingChildBranch > -1) {
// Iterate the exit state adding but switching to the new branch
branchGuide.add(indexOfMatchingChildBranch);
// NOCS
i--;
positionInBranch = 0;
continue;
}
}
// No matching exit element found --> Split branch into child branches
numberOfBranches = this.splitBranch(examinedBranch, positionInBranch, numberOfBranches, true, null, 0);
break;
}
}
}
branchModel.setRootBranch(rootBranch);
branchModel.setNumberOfBranches(numberOfBranches);
return branchModel;
}
use of org.iobserve.analysis.behavior.karlsruhe.data.BranchModel in project iobserve-analysis by research-iobserve.
the class LoopExtraction method createCallLoopBranchModels.
/**
* Executes the extraction of iterated behavior process.
*/
public void createCallLoopBranchModels() {
final LoopBranchModelCreator modelCreator = new LoopBranchModelCreator();
this.loopBranchModels = new ArrayList<>();
for (final BranchModel branchModel : this.branchModels) {
// Each BranchModel is checked for iterated behavior
modelCreator.detectLoopsInCallBranchModel(branchModel);
this.loopBranchModels.add(branchModel);
}
}
use of org.iobserve.analysis.behavior.karlsruhe.data.BranchModel in project iobserve-analysis by research-iobserve.
the class PcmUsageModelBuilder method createUsageModel.
/**
* Creates a PCM usage model from the passed LoopBranchModels.
*
* @return the created PCM usage model
*/
public UsageModel createUsageModel() {
final UsageModel usageModel = UsageModelFactory.createUsageModel();
// Creates for each detected user group its own usage scenario
for (int i = 0; i < this.loopBranchModels.size(); i++) {
final BranchModel callBranchModel = this.loopBranchModels.get(i);
final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("Usage Scneario of user group " + i, usageModel);
final Map<Integer, ScenarioBehaviour> branchScenarioBehaviours = new HashMap<>();
this.branchScenarioBehavioursOfUserGroups.add(branchScenarioBehaviours);
if (this.isClosedWorkloadRequested) {
UsageModelFactory.createClosedWorkload(callBranchModel.getWorkloadIntensity().getAvgNumberOfConcurrentUsers(), this.thinkTime, usageScenario);
} else {
UsageModelFactory.createOpenWorkload(callBranchModel.getWorkloadIntensity().getInterarrivalTimeOfUserSessions(), usageScenario);
}
// creates for each Branch its own scenario behavior
this.createForEachBranchAScenarioBehavior(callBranchModel.getRootBranch(), i);
// The rootBranch contains every succeeding branches and is set as the scenario behavior
// of the user groupĀ“s usage scenario
usageScenario.setScenarioBehaviour_UsageScenario(this.branchScenarioBehavioursOfUserGroups.get(i).get(callBranchModel.getRootBranch().getBranchId()));
usageModel.getUsageScenario_UsageModel().add(usageScenario);
}
return usageModel;
}
use of org.iobserve.analysis.behavior.karlsruhe.data.BranchModel in project iobserve-analysis by research-iobserve.
the class BranchExtraction method createCallBranchModels.
/**
* Create a call branch model.
*/
public void createCallBranchModels() {
final BranchModelCreator modelCreator = new BranchModelCreator();
this.branchModels = new ArrayList<>();
for (final UserSessionCollectionModel entryCallSequenceModel : this.entryCallSequenceModels) {
/**
* 1. Aggregates the single EntryCall sequences to a BranchModel
*/
final BranchModel branchModel = modelCreator.createCallBranchModel(entryCallSequenceModel);
/**
* 2. Calculates the likelihoods of the branches of the obtained BranchModel
*/
modelCreator.calculateLikelihoodsOfBranches(branchModel);
/**
* 3. Tries to fuse branches to obtain a more compact model
*/
modelCreator.compactBranchModel(branchModel);
this.branchModels.add(branchModel);
}
}
Aggregations