/** * Creates a fault injection mechanism for the Hosts of a given {@link Datacenter}. * The Hosts failures are randomly injected according to a {@link UniformDistr} * pseudo random number generator, which indicates the mean of failures to be generated per <b>hour</b>, * (which is also called <b>event rate</b> or <b>rate parameter</b>). * * @param datacenter the Datacenter to which failures will be randomly injected for its Hosts * @see #HostFaultInjection(Datacenter, ContinuousDistribution) */ public HostFaultInjection(final Datacenter datacenter) { this(datacenter, new UniformDistr()); }
/** * 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; }
@Override public long getSeed() { return rand.getSeed(); }
/** * Creates a pseudo random number generator (PRNG) for a experiment run that * generates uniform values between [min and max[. If it is to apply the * {@link #isApplyAntitheticVariatesTechnique() "Antithetic Variates Technique"} * to reduce results' variance, the second half of experiments will use the * seeds from the first half. * * @param experimentIndex index of the experiment run to create a PRNG * @param minValue the minimum value the generator will return (inclusive) * @param maxValue the maximum value the generator will return (exclusive) * @return the created PRNG * * @see UniformDistr#isApplyAntitheticVariates() */ protected ContinuousDistribution createRandomGen(final int experimentIndex, final double minValue, final double maxValue) { if (isToReuseSeedFromFirstHalfOfExperiments(experimentIndex)) { final int expIndexFromFirstHalf = experimentIndex - halfSimulationRuns(); return new UniformDistr(minValue, maxValue, seeds.get(expIndexFromFirstHalf)).setApplyAntitheticVariates(true); } return new UniformDistr(minValue, maxValue, seeds.get(experimentIndex)); }
/** * 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(); }
CloudletSchedulerExperiment(int index, ExperimentRunner runner) { super(index, runner); this.cloudletPesPrng = new UniformDistr(0, 1); }
/** * 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; }
public PowerVmSelectionPolicyRandomSelection(){ super(); rand = new UniformDistr(); }
UniformDistr ufrnd = new UniformDistr(0, numVms, 5); for (int i = 0; i < app.numbervm; i++) { int vmid = (int) ufrnd.sample(); vmids.add(vmid);
/** * Instantiates the simulation experiment. * * @param index a number the identifies the current experiment being run * @param runner the runner that will be in charge to setup and run the * experiment */ DatacenterBrokerHeuristicExperiment(int index, DatacenterBrokerHeuristicRunner runner) { super(index, runner); this.randomGen = new UniformDistr(0, 1); createSimulatedAnnealingHeuristic(); }
/** * Creates a new Poisson random number generator to check * the probability of 1 event ({@link #getK() k}) to happen at each time * interval. * * @param lambda the average number of events that happen at each 1 time unit. * If one considers the unit as minute, this value means the average number of arrivals * at each minute. * @param seed the seed to initialize the uniform random number generator * @see #setK(int) * @see #setLambda(double) */ public PoissonDistr(final double lambda, final long seed){ this.rand = new UniformDistr(seed); this.k = 1; this.setLambda(lambda); }
private CloudletTaskCompletionTimeMinimizationExperiment(final int index, final ExperimentRunner runner, final long seed) { super(index, runner, seed); setHostsNumber(HOSTS); setVmsNumber(VMS); this.randCloudlet = new UniformDistr(getSeed()); this.randVm = new UniformDistr(getSeed()+2); this.randCloudletPes = new UniformDistr(getSeed()+3); this.randMipsVm = new UniformDistr(getSeed()+4); contractsMap = new HashMap<>(); }
/** * Instantiates a new utilization model stochastic. * * @param seed the seed to generate the pseudo random utilization values */ public UtilizationModelStochastic(long seed) { super(); setHistory(new HashMap<>()); setRandomGenerator(new UniformDistr(seed)); }
/** * Instantiates a new utilization model stochastic * that defines the resource utilization in percentage. */ public UtilizationModelStochastic() { super(); setHistory(new HashMap<>()); setRandomGenerator(new UniformDistr()); }
private CloudletTaskCompletionTimeWorkLoadMinimizationExperiment(final int index, final ExperimentRunner runner, final long seed) { super(index, runner, seed); setHostsNumber(HOSTS); setVmsNumber(VMS); randVm = new UniformDistr(getSeed()+1); randMip = new UniformDistr(getSeed()+2); contractsMap = new HashMap<>(); }
@Override protected void setup() { cloudletsCompletionTimeMeans = new ArrayList<>(getSimulationRuns()); cloudletsNumber = new ArrayList<>(getSimulationRuns()); cloudletsNumberPrng = new UniformDistr(VM_PES / 2, VM_PES + 1, getBaseSeed()); }
private void createSimulatedAnnealingHeuristic() { heuristic = new CloudletToVmMappingSimulatedAnnealing(SA_INITIAL_TEMPERATURE, new UniformDistr(0, 1)); heuristic.setColdTemperature(SA_COLD_TEMPERATURE); heuristic.setCoolingRate(SA_COOLING_RATE); heuristic.setNeighborhoodSearchesByIteration(SA_NUMBER_OF_NEIGHBORHOOD_SEARCHES); }
@Setup public void doSetup() { CloudletToVmMappingSimulatedAnnealing heuristic = new CloudletToVmMappingSimulatedAnnealing(0, new UniformDistr(0, 1)); instance1 = createInstance(); instance2 = createInstance(); /*Call the getCost the first time without measure it in order to measure the time for the second call, when the cost is already computed*/ instance2.getCost(); }
private MinTimeBetweenEventsExample() { Log.setLevel(Level.WARN); System.out.println("Starting " + getClass().getSimpleName()); simulation = new CloudSim(MIN_TIME_BETWEEN_EVENTS); this.hostList = new ArrayList<>(); this.vmList = new ArrayList<>(); this.cloudletList = new ArrayList<>(); this.datacenter = createDatacenter(); this.broker = new DatacenterBrokerSimple(simulation); Vm vm = createAndSubmitVm(); final long seed = 1547040598054L; random = new UniformDistr(seed); createAndSubmitCloudlets(vm); runSimulationAndPrintResults(); }