use of org.iobserve.analysis.data.UserSessionCollectionModel in project iobserve-analysis by research-iobserve.
the class ClusteringPrePostProcessing method getForEachUserGroupAnEntryCallSequenceModel.
/**
* It creates for each cluster(user group) its own entryCallSequenceModel. For that, each
* entryCallSequenceModel receives exclusively the user group's assigned user sessions obtained
* via the clustering. Additionally each entryCallSequenceModel receives the user group's
* occurrence likelihood within the considered user sessions.
*
* @param clusteringResults
* hold the assignments of the clustering and the number of clusters
* @param callSequenceModel
* is the input entryCallSequenceModel that holds all user sessions
* @return for each cluster one entryCallSequenceModel. Each contains exclusively the cluster's
* assigned user sessions
*/
public List<UserSessionCollectionModel> getForEachUserGroupAnEntryCallSequenceModel(final ClusteringResults clusteringResults, final UserSessionCollectionModel callSequenceModel) {
final int numberOfClusters = clusteringResults.getNumberOfClusters();
final int[] assignments = clusteringResults.getAssignments();
final List<UserSessionCollectionModel> entryCallSequenceModels = new ArrayList<>(numberOfClusters);
final double countOfAbsoluteUserSessions = callSequenceModel.getUserSessions().size();
for (int k = 0; k < numberOfClusters; k++) {
final List<UserSession> sessions = new ArrayList<>();
int instanceNumber = 0;
double countOfAssigendUserSessions = 0;
for (final int clusterNum : assignments) {
if (clusterNum == k) {
sessions.add(callSequenceModel.getUserSessions().get(instanceNumber));
countOfAssigendUserSessions++;
}
instanceNumber++;
}
if (sessions.isEmpty()) {
continue;
}
final double relativeFrequencyOfUserGroup = countOfAssigendUserSessions / countOfAbsoluteUserSessions;
entryCallSequenceModels.add(new UserSessionCollectionModel(sessions, relativeFrequencyOfUserGroup));
}
return entryCallSequenceModels;
}
use of org.iobserve.analysis.data.UserSessionCollectionModel in project iobserve-analysis by research-iobserve.
the class ClusteringPrePostProcessing method setTheWorkloadIntensityForTheEntryCallSequenceModels.
/**
* It calculates and sets for each entryCallSequenceModel its specific workload intensity. For
* that it calculates an open or a closed workload and adds it to its entryCallSequenceModel.
*
* @param entryCallSequenceModels
* are the entryCallSequenceModels of the detected user groups
* @param isClosedWorkload
* states whether a closed or an open workload is requested by the user
*/
public void setTheWorkloadIntensityForTheEntryCallSequenceModels(final List<UserSessionCollectionModel> entryCallSequenceModels, final boolean isClosedWorkload) {
for (final UserSessionCollectionModel entryCallSequenceModel : entryCallSequenceModels) {
final WorkloadIntensity workloadIntensity = new WorkloadIntensity();
if (isClosedWorkload) {
this.calculateTheNumberOfConcurrentUsers(entryCallSequenceModel.getUserSessions(), workloadIntensity);
} else {
this.calculateInterarrivalTime(entryCallSequenceModel.getUserSessions(), workloadIntensity);
}
entryCallSequenceModel.setWorkloadIntensity(workloadIntensity);
}
}
use of org.iobserve.analysis.data.UserSessionCollectionModel in project iobserve-analysis by research-iobserve.
the class SimpleLoopReferenceHelper method getModel.
/**
* Creates a reference model that contains a loop element. Accordingly, user sessions whose call
* sequences contain iterated calls are created.(RQ-1.3)
*
* @param referenceUsageModelFileName
* reference usage model file name
* @param repositoryLookupModelProvider
* repository model provider
* @param correspondenceModel
* correspondence model
*
* @return the reference usage model and a corresponding EntryCallSequenceModel
* @throws IOException
* on error
*/
public static ReferenceElements getModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModelProvider, final CorrespondenceModel correspondenceModel) throws IOException {
// Create a random number of user sessions and random model element parameters. The user
// sessions' behavior will be created according to the reference usage model and
// subsequently the user sessions are used to create a usage model. The created usage model
// is matched against the reference usage model
final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 1);
final int loopCount = TestHelper.getRandomInteger(5, 2);
final int numberOfIteratedCalls = TestHelper.getRandomInteger(5, 1);
final UserSessionCollectionModel entryCallSequenceModel = new UserSessionCollectionModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
final ReferenceElements referenceElements = new ReferenceElements();
// In the following the reference usage model is created
AbstractUserAction lastAction;
final UsageModel usageModel = UsageModelFactory.createUsageModel();
final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
final Start start = UsageModelFactory.createAddStartAction("", scenarioBehaviour);
final Stop stop = UsageModelFactory.createAddStopAction("", scenarioBehaviour);
// A loop is created and the loop count is set
final Loop loop = UsageModelFactory.createLoop("", scenarioBehaviour);
UsageModelFactory.connect(start, loop);
final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmLoopIteration.setSpecification(String.valueOf(loopCount));
loop.setLoopIteration_Loop(pcmLoopIteration);
UsageModelFactory.connect(loop, stop);
// The EntryLevelSystemCalls that are iterated are added to the loop element
final Start loopStart = UsageModelFactory.createAddStartAction("", loop.getBodyBehaviour_Loop());
final Stop loopStop = UsageModelFactory.createAddStopAction("", loop.getBodyBehaviour_Loop());
lastAction = loopStart;
// iterated calls to the loop
for (int i = 0; i < numberOfIteratedCalls; i++) {
if (i >= 0 && i < 5) {
final OperationSignature operationSignature = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
if (operationSignature != null) {
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, operationSignature);
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), entryLevelSystemCall);
UsageModelFactory.connect(lastAction, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
} else {
throw new IllegalArgumentException("Illegal value of model element parameter");
}
}
UsageModelFactory.connect(lastAction, loopStop);
// According to the reference usage model user sessions are created that exactly represent
// the user behavior of the reference usage model. The entry and exit times enable that the
// calls within the user sessions are ordered according to the reference usage model
int entryTime = 1;
int exitTime = 2;
for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
entryTime = 1;
exitTime = 2;
// number of iterated calls
for (int k = 0; k < loopCount; k++) {
for (int j = 0; j < numberOfIteratedCalls; j++) {
EntryCallEvent entryCallEvent = null;
if (j >= 0 && j < 5) {
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[j], ReferenceUsageModelBuilder.CLASS_SIGNATURE[j], String.valueOf(i), "hostname");
} else {
throw new IllegalArgumentException("Illegal value of model element parameter");
}
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime = entryTime + 2;
exitTime = exitTime + 2;
}
}
}
// Saves the reference usage model and sets the usage model and the EntryCallSequenceModel
// as the reference elements. Our approach is now executed with the EntryCallSequenceModel
// and the resulting usage model can be matched against the reference usage model
TestHelper.saveModel(usageModel, referenceUsageModelFileName);
referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
referenceElements.setUsageModel(usageModel);
return referenceElements;
}
use of org.iobserve.analysis.data.UserSessionCollectionModel in project iobserve-analysis by research-iobserve.
the class BranchWithinBranchReference method getModel.
/**
* It creates a reference usage model that contains nested branches. Accordingly, user sessions
* whose call sequences differ from each other at the positions of the branches are
* created.(RQ-1.5)
*
* @param referenceUsageModelFileName
* file name of the reference model to store its result
* @param usageModelBuilder
* usage model builder
* @param repositoryLookupModel
* repository model provider
* @param correspondenceModel
* correspondence model
*
* @return a reference usage model and corresponding user sessions
* @throws IOException
* on error
*/
public static ReferenceElements getModel(final String referenceUsageModelFileName, final UsageModelFactory usageModelBuilder, final RepositoryLookupModelProvider repositoryLookupModel, final CorrespondenceModel correspondenceModel) throws IOException {
// Create a random number of user sessions and random model element parameters. The user
// sessions' behavior will be created according to the reference usage model and
// subsequently the user sessions are used to create a usage model. The created usage model
// is matched against the reference usage model. The minimum number of user sessions is set
// dependently from the random number of branch transitions, because it must be ensured that
// each branch transition is represented within the user sessions.
final int numberOfTransitionsOfExteriorBranch = TestHelper.getRandomInteger(3, 2);
final int numberOfTransitionsOfInteriorBranches = TestHelper.getRandomInteger(3, 2);
final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 10 * numberOfTransitionsOfExteriorBranch);
final UserSessionCollectionModel entryCallSequenceModel = new UserSessionCollectionModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
final ReferenceElements referenceElements = new ReferenceElements();
final List<Integer> branchTransitionCounter = new ArrayList<>();
final List<List<Integer>> listOfbranchTransitionCounterInterior = new ArrayList<>();
BranchWithinBranchReference.createUserSessions(branchTransitionCounter, listOfbranchTransitionCounterInterior, numberOfTransitionsOfExteriorBranch, numberOfTransitionsOfInteriorBranches, entryCallSequenceModel);
final UsageModel usageModel = BranchWithinBranchReference.createTheReferenceModel(usageModelBuilder, repositoryLookupModel, correspondenceModel, numberOfTransitionsOfExteriorBranch, numberOfTransitionsOfInteriorBranches, numberOfConcurrentUsers, branchTransitionCounter, listOfbranchTransitionCounterInterior);
// Saves the reference usage model and sets the usage model and the EntryCallSequenceModel
// as the reference elements. Our approach is now executed with the EntryCallSequenceModel
// and the resulting usage model can be matched against the reference usage model
TestHelper.saveModel(usageModel, referenceUsageModelFileName);
referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
referenceElements.setUsageModel(usageModel);
return referenceElements;
}
use of org.iobserve.analysis.data.UserSessionCollectionModel in project iobserve-analysis by research-iobserve.
the class SimpleBranchReference method getModel.
/**
* Creates a reference model that contains a branch element. Accordingly, user sessions whose
* call sequences differ from each other at the position of the branch are created.(RQ-1.2)
*
* @param referenceModelFileName
* file name of the reference model to store its result
* @param repositoryLookupModelProvider
* repository model provider
* @param correspondenceModel
* correspondence model
*
* @return a reference usage model and corresponding user sessions
* @throws IOException
* on error
*/
public static ReferenceElements getModel(final String referenceModelFileName, final RepositoryLookupModelProvider repositoryLookupModelProvider, final CorrespondenceModel correspondenceModel) throws IOException {
// Create a random number of user sessions and random model element parameters. The user
// sessions' behavior will be created according to the reference usage model and
// subsequently the user sessions are used to create a usage model. The created usage model
// is matched against the reference usage model. The minimum number of user sessions is set
// dependently from the random number of branch transitions, because it must be ensured that
// each branch transition is represented within the user sessions.
final int numberOfBranchTransitions = TestHelper.getRandomInteger(5, 2);
final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 10 * numberOfBranchTransitions);
final UserSessionCollectionModel entryCallSequenceModel = new UserSessionCollectionModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
// In the following the reference usage model is created
final UsageModel usageModel = UsageModelFactory.createUsageModel();
final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
final Start start = UsageModelFactory.createAddStartAction("", scenarioBehaviour);
final Stop stop = UsageModelFactory.createAddStopAction("", scenarioBehaviour);
AbstractUserAction lastAction = start;
// Creates the branch element and the branch transitions according to the random number of
// branch transitions
final Branch branch = UsageModelFactory.createBranch("", scenarioBehaviour);
UsageModelFactory.connect(start, branch);
// the alternative call sequences
for (int i = 0; i < numberOfBranchTransitions; i++) {
final BranchTransition branchTransition = UsageModelFactory.createBranchTransition(branch);
final ScenarioBehaviour branchTransitionBehaviour = branchTransition.getBranchedBehaviour_BranchTransition();
final Start startBranchTransition = UsageModelFactory.createAddStartAction("", branchTransitionBehaviour);
final Stop stopBranchTransition = UsageModelFactory.createAddStopAction("", branchTransitionBehaviour);
lastAction = startBranchTransition;
if (i >= 0 && i < 5) {
final OperationSignature operationSignature = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
if (operationSignature != null) {
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, operationSignature);
UsageModelFactory.addUserAction(branchTransitionBehaviour, entryLevelSystemCall);
UsageModelFactory.connect(lastAction, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
} else {
throw new IllegalArgumentException("Illegal value of model element parameter");
}
final OperationSignature operationSignature;
if (i == 0) {
operationSignature = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1]);
} else {
operationSignature = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0]);
}
if (operationSignature != null) {
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, operationSignature);
UsageModelFactory.addUserAction(branchTransitionBehaviour, entryLevelSystemCall);
UsageModelFactory.connect(lastAction, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
UsageModelFactory.connect(lastAction, stopBranchTransition);
}
final OperationSignature operationSignature = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2]);
if (operationSignature != null) {
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, operationSignature);
UsageModelFactory.addUserAction(scenarioBehaviour, entryLevelSystemCall);
UsageModelFactory.connect(branch, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
UsageModelFactory.connect(lastAction, stop);
final List<Integer> branchTransitionCounter = SimpleBranchReference.computeBranchTransitions(entryCallSequenceModel, branch, numberOfBranchTransitions);
// the randomly created user sessions
for (int i = 0; i < branch.getBranchTransitions_Branch().size(); i++) {
branch.getBranchTransitions_Branch().get(i).setBranchProbability((double) branchTransitionCounter.get(i) / numberOfConcurrentUsers);
}
return SimpleBranchReference.saveReferenceElements(usageModel, referenceModelFileName, entryCallSequenceModel);
}
Aggregations