/** * Checks if at the current time, {@link #getK() K} events have happened, * considering the {@link #eventsArrivalProbability() probability of these K events} * to happen in a time interval. * * @return true if the K events have happened at current time, false otherwise */ public boolean eventsHappened(){ return rand.sample() <= eventsArrivalProbability(); }
/** * Gets a random number that represents the next time for an event to happen, * considering the {@link #getLambda() events arrival rate (lambda)}. * @return */ @Override public double sample() { return Math.exp(1.0 - rand.sample()) / getLambda(); }
/** * Randomly select a given number of VMs from the list of created VMs, * to be used by the NetworkCloudlets of the given application. * * @param broker the broker where to get the existing VM list * @param numberOfVmsToSelect number of VMs to selected from the existing list of VMs. * @return The list of randomly selected VMs */ protected List<NetworkVm> randomlySelectVmsForApp( DatacenterBroker broker, int numberOfVmsToSelect) { List<NetworkVm> list = new ArrayList<>(); int numOfExistingVms = this.vmList.size(); UniformDistr rand = new UniformDistr(0, numOfExistingVms, 5); for (int i = 0; i < numberOfVmsToSelect; i++) { final int vmIndex = (int)rand.sample() % vmList.size(); NetworkVm vm = vmList.get(vmIndex); list.add(vm); } return list; }
/** * Creates an array with the configuration of PEs for each VM to be created * in each experiment run. Every experiment will use the same VMs * configurations. * * @return the created VMs PEs array */ private int[] createVmPesArray() { final UniformDistr random = new UniformDistr(0, VM_PES_NUMBERS.length, getBaseSeed()); int[] pesArray = new int[VMS_TO_CREATE]; int totalNumberOfPes = 0; for (int i = 0; i < VMS_TO_CREATE; i++) { pesArray[i] = VM_PES_NUMBERS[(int) random.sample()]; totalNumberOfPes += pesArray[i]; } return pesArray; }
for (int i = 0; i < app.numbervm; i++) { int vmid = (int) ufrnd.sample(); vmids.add(vmid);