how to add algorithm in cloudsim

4,241 views
Skip to first unread message

Riddhi Patel

unread,
Jan 12, 2015, 9:27:54 PM1/12/15
to clou...@googlegroups.com
Algorithm 1: Modified Best Fit Decreasing (MBFD)
1Input:hostList,vmList Output:allocation of VMs
2 vmList.sortDecreasingUtilization()
3 foreach vm in vmList do
4 minPower←MAX
5 allocatedHost←NULL
6 foreach host in hostList do
7     if host has enough resource for vm then
8  power←estimatePower(host, vm)
9  if power < minPower then
10   allocatedHost←host
11   minPower←power
12 if allocatedHost≠ NULL then
13     allocate vm to allocatedHost
14return allocation


hello... this is my existing algorithm . and i want to implement it in to the cloudsim using netbeans. how i work on it pllzzz plzzz plzzz reply me if anyone know ...its realy important for me ..
thank you..

Zahra Bagheri

unread,
Jan 15, 2015, 10:31:57 AM1/15/15
to clou...@googlegroups.com
Hi,

This algorithm already has been implemented in the power package of CloudSim.
Refer to PowerVmAllocationPolicyMigrationAbstract class in the following path:
org.cloudbus.cloudsim.power
Then you can find the aforesaid algorithm in findHostForVm method:
public PowerHost findHostForVm(Vm vm, Set<? extends Host> excludedHosts)

Regards

Riddhi Patel

unread,
Jan 21, 2015, 7:42:04 AM1/21/15
to clou...@googlegroups.com
thank you soo much for reply ..


RIDDHI PATEL

--

---
You received this message because you are subscribed to a topic in the Google Groups "cloudsim" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cloudsim/PoSb3y8Mq4c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cloudsim+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Riddhi Patel

unread,
Jan 21, 2015, 7:48:56 AM1/21/15
to clou...@googlegroups.com
but this program is nor running .. " RunnerAbstract class dose not have main method "  this error is generate .now what i do..??? 
plzzz reply  me  Zahra  medam ...

RIDDHI PATEL

Zahra Bagheri

unread,
Jan 21, 2015, 10:40:55 AM1/21/15
to clou...@googlegroups.com
Which class did you run? In order to get the output of Power examples run one of classes in the following paths:
org.cloudbus.cloudsim.examples.power.planetlab
org.cloudbus.cloudsim.examples.power.random

Riddhi Patel

unread,
Jan 22, 2015, 12:34:57 AM1/22/15
to clou...@googlegroups.com
thank you for reply.. 

i used this file which i attach hear, for implement the modified best fit decreasing algorithm .but still it will not running ..
and is it correct program to implement this algorithm ..???   Am i going to right way ..or not ..??? if any suggestion then plzz tell me 
pllzzzz reply ...

RIDDHI PATEL
RandomRunner.java

Zahra Bagheri

unread,
Jan 22, 2015, 9:07:37 AM1/22/15
to clou...@googlegroups.com
Hi
This attached file is not a runnable java file. As I said previously you can get the output of mentioned algorithm by executing one of the classes in:
org.cloudbus.cloudsim.examples.power.planetlab
or
org.cloudbus.cloudsim.examples.power.random
In these examples Modified Best Fit Decreasing (MBFD) has been adapted as VM placement policy.
Regards

Riddhi Patel

unread,
Jan 22, 2015, 11:12:11 PM1/22/15
to clou...@googlegroups.com
again thank you ...for reply 

ya i try to run this class but it will not work .if possible can u mail me the file plz ...if possible ..... 

RIDDHI PATEL
errorDoc1.docx

Zahra Bagheri

unread,
Jan 23, 2015, 9:30:06 AM1/23/15
to clou...@googlegroups.com
It seems the CloudSim package has not been imported completely in NetBeens.
Try again to import it from CloudSim zip file, Then your power examples appear like this screen shot:

Inline image 1

Riddhi Patel

unread,
Jan 24, 2015, 12:31:14 AM1/24/15
to clou...@googlegroups.com
Thank you sooo much for reply ... 

i done what ever u sayed. i attech the file named error2 plz see i write my difficulty  in file .plz madam help me what is the  next i do ..??

RIDDHI PATEL
error2.docx

Zahra Bagheri

unread,
Jan 24, 2015, 8:18:59 AM1/24/15
to clou...@googlegroups.com
You can run file which has main method, So now simply right click on one of classes in org.cloudbus.cloudsim.examples.power.random (for example IqrMc.java) and click Run file...

Riddhi Patel

unread,
Jan 24, 2015, 11:52:49 PM1/24/15
to clou...@googlegroups.com
Thank you  mam' 

 error is generating  :(

now ..?????????
 

RIDDHI PATEL
error3.docx
Message has been deleted

Zahra Bagheri

unread,
Jan 26, 2015, 2:57:53 AM1/26/15
to clou...@googlegroups.com
Add flanagan.jar to the project libraries. It has been attached:


flanagan.jar

Riddhi Patel

unread,
Jan 26, 2015, 10:35:18 AM1/26/15
to clou...@googlegroups.com
thank you so much again .for reply ..mam' 

but stil  it is not run ..
see atched file error4  plz

RIDDHI PATEL
error4.docx

Zahra Bagheri

unread,
Jan 28, 2015, 11:57:29 AM1/28/15
to clou...@googlegroups.com
See attached document to setup CloudSim in NetBeans

CloudSim Setup in NetBeans.pdf

Riddhi Patel

unread,
Feb 1, 2015, 6:27:37 AM2/1/15
to clou...@googlegroups.com

Thank you so much. .mam...:)

Riddhi Patel

unread,
Feb 2, 2015, 12:33:31 AM2/2/15
to clou...@googlegroups.com
hello Zahra Bagheri ,,
                                  Energy consumption , resources utilization , workload capacity , scalabilty , efficiency is main parameter to   implementing Modified best fit decreasing algorithm ,

now i atteched the file . 

 all of them which will used for my algorithm to plzzz   guide me  mam'.

 which  will be  right to fullfil my peameter ??

pllzzz mem' its humble request to reply me n  give me some  proper guidence..

RIDDHI PATEL
Data.docx

M. Fasih Akbar

unread,
Feb 2, 2015, 6:58:26 AM2/2/15
to clou...@googlegroups.com
Zahra replied that ....this algorithm already implemented as per her first reply

"
This algorithm already has been implemented in the power package of CloudSim.
Refer to PowerVmAllocationPolicyMigrationAbstract class in the following path:
org.cloudbus.cloudsim.power
"
Thanx.

Riddhi Patel

unread,
Feb 2, 2015, 7:07:14 AM2/2/15
to clou...@googlegroups.com
thank you for reply 
  
ya ...but   except this class is  it will not add the other functionality  like  Dvfs.java , Lrmc.java etc....   
is  it not add  in this ???
plz reply ...




RIDDHI PATEL

Riddhi Patel

unread,
Feb 2, 2015, 8:19:27 AM2/2/15
to clou...@googlegroups.com
this is PowerVmAllocationPolicyMigrationAbstract class    now what i do ..?? where whoud i change in here ?? plzzz plzzz 

/*
 * Title:        CloudSim Toolkit
 * Description:  CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 *
 * Copyright (c) 2009-2012, The University of Melbourne, Australia
 */

package org.cloudbus.cloudsim.power;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.HostDynamicWorkload;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.power.lists.PowerVmList;
import org.cloudbus.cloudsim.util.ExecutionTimeMeasurer;

/**
 * The class of an abstract power-aware VM allocation policy that dynamically optimizes the VM
 * allocation using migration.
 * 
 * If you are using any algorithms, policies or workload included in the power package, please cite
 * the following paper:
 * 
 * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive
 * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in
 * Cloud Data Centers", Concurrency and Computation: Practice and Experience, ISSN: 1532-0626, Wiley
 * Press, New York, USA, 2011, DOI: 10.1002/cpe.1867
 * 
 * @author Anton Beloglazov
 * @since CloudSim Toolkit 3.0
 */
public abstract class PowerVmAllocationPolicyMigrationAbstract extends PowerVmAllocationPolicyAbstract {

/** The vm selection policy. */
private PowerVmSelectionPolicy vmSelectionPolicy;

/** The saved allocation. */
private final List<Map<String, Object>> savedAllocation = new ArrayList<Map<String, Object>>();

/** The utilization history. */
private final Map<Integer, List<Double>> utilizationHistory = new HashMap<Integer, List<Double>>();

/** The metric history. */
private final Map<Integer, List<Double>> metricHistory = new HashMap<Integer, List<Double>>();

/** The time history. */
private final Map<Integer, List<Double>> timeHistory = new HashMap<Integer, List<Double>>();

/** The execution time history vm selection. */
private final List<Double> executionTimeHistoryVmSelection = new LinkedList<Double>();

/** The execution time history host selection. */
private final List<Double> executionTimeHistoryHostSelection = new LinkedList<Double>();

/** The execution time history vm reallocation. */
private final List<Double> executionTimeHistoryVmReallocation = new LinkedList<Double>();

/** The execution time history total. */
private final List<Double> executionTimeHistoryTotal = new LinkedList<Double>();

/**
* Instantiates a new power vm allocation policy migration abstract.
* @param hostList the host list
* @param vmSelectionPolicy the vm selection policy
*/
public PowerVmAllocationPolicyMigrationAbstract(
List<? extends Host> hostList,
PowerVmSelectionPolicy vmSelectionPolicy) {
super(hostList);
setVmSelectionPolicy(vmSelectionPolicy);
}

/**
* Optimize allocation of the VMs according to current utilization.
* @param vmList the vm list
* @return the array list< hash map< string, object>>
*/
@Override
public List<Map<String, Object>> optimizeAllocation(List<? extends Vm> vmList) {
ExecutionTimeMeasurer.start("optimizeAllocationTotal");

ExecutionTimeMeasurer.start("optimizeAllocationHostSelection");
List<PowerHostUtilizationHistory> overUtilizedHosts = getOverUtilizedHosts();
getExecutionTimeHistoryHostSelection().add(
ExecutionTimeMeasurer.end("optimizeAllocationHostSelection"));

printOverUtilizedHosts(overUtilizedHosts);

saveAllocation();

ExecutionTimeMeasurer.start("optimizeAllocationVmSelection");
List<? extends Vm> vmsToMigrate = getVmsToMigrateFromHosts(overUtilizedHosts);
getExecutionTimeHistoryVmSelection().add(ExecutionTimeMeasurer.end("optimizeAllocationVmSelection"));

Log.printLine("Reallocation of VMs from the over-utilized hosts:");
ExecutionTimeMeasurer.start("optimizeAllocationVmReallocation");
List<Map<String, Object>> migrationMap = getNewVmPlacement(vmsToMigrate, new HashSet<Host>(
overUtilizedHosts));
getExecutionTimeHistoryVmReallocation().add(
ExecutionTimeMeasurer.end("optimizeAllocationVmReallocation"));
Log.printLine();

migrationMap.addAll(getMigrationMapFromUnderUtilizedHosts(overUtilizedHosts));

restoreAllocation();

getExecutionTimeHistoryTotal().add(ExecutionTimeMeasurer.end("optimizeAllocationTotal"));

return migrationMap;
}

/**
* Gets the migration map from under utilized hosts.
* @param overUtilizedHosts the over utilized hosts
* @return the migration map from under utilized hosts
*/
protected List<Map<String, Object>> getMigrationMapFromUnderUtilizedHosts(
List<PowerHostUtilizationHistory> overUtilizedHosts) {
List<Map<String, Object>> migrationMap = new LinkedList<Map<String, Object>>();
List<PowerHost> switchedOffHosts = getSwitchedOffHosts();

// over-utilized hosts + hosts that are selected to migrate VMs to from over-utilized hosts
Set<PowerHost> excludedHostsForFindingUnderUtilizedHost = new HashSet<PowerHost>();
excludedHostsForFindingUnderUtilizedHost.addAll(overUtilizedHosts);
excludedHostsForFindingUnderUtilizedHost.addAll(switchedOffHosts);
excludedHostsForFindingUnderUtilizedHost.addAll(extractHostListFromMigrationMap(migrationMap));

// over-utilized + under-utilized hosts
Set<PowerHost> excludedHostsForFindingNewVmPlacement = new HashSet<PowerHost>();
excludedHostsForFindingNewVmPlacement.addAll(overUtilizedHosts);
excludedHostsForFindingNewVmPlacement.addAll(switchedOffHosts);

int numberOfHosts = getHostList().size();

while (true) {
if (numberOfHosts == excludedHostsForFindingUnderUtilizedHost.size()) {
break;
}

PowerHost underUtilizedHost = getUnderUtilizedHost(excludedHostsForFindingUnderUtilizedHost);
if (underUtilizedHost == null) {
break;
}

Log.printLine("Under-utilized host: host #" + underUtilizedHost.getId() + "\n");

excludedHostsForFindingUnderUtilizedHost.add(underUtilizedHost);
excludedHostsForFindingNewVmPlacement.add(underUtilizedHost);

List<? extends Vm> vmsToMigrateFromUnderUtilizedHost = getVmsToMigrateFromUnderUtilizedHost(underUtilizedHost);
if (vmsToMigrateFromUnderUtilizedHost.isEmpty()) {
continue;
}

Log.print("Reallocation of VMs from the under-utilized host: ");
if (!Log.isDisabled()) {
for (Vm vm : vmsToMigrateFromUnderUtilizedHost) {
Log.print(vm.getId() + " ");
}
}
Log.printLine();

List<Map<String, Object>> newVmPlacement = getNewVmPlacementFromUnderUtilizedHost(
vmsToMigrateFromUnderUtilizedHost,
excludedHostsForFindingNewVmPlacement);

excludedHostsForFindingUnderUtilizedHost.addAll(extractHostListFromMigrationMap(newVmPlacement));

migrationMap.addAll(newVmPlacement);
Log.printLine();
}

return migrationMap;
}

/**
* Prints the over utilized hosts.
* @param overUtilizedHosts the over utilized hosts
*/
protected void printOverUtilizedHosts(List<PowerHostUtilizationHistory> overUtilizedHosts) {
if (!Log.isDisabled()) {
Log.printLine("Over-utilized hosts:");
for (PowerHostUtilizationHistory host : overUtilizedHosts) {
Log.printLine("Host #" + host.getId());
}
Log.printLine();
}
}

/**
* Find host for vm.
* @param vm the vm
* @param excludedHosts the excluded hosts
* @return the power host
*/
public PowerHost findHostForVm(Vm vm, Set<? extends Host> excludedHosts) {
double minPower = Double.MAX_VALUE;
PowerHost allocatedHost = null;

for (PowerHost host : this.<PowerHost> getHostList()) {
if (excludedHosts.contains(host)) {
continue;
}
if (host.isSuitableForVm(vm)) {
if (host.getUtilizationOfCpuMips() != 0 && isHostOverUtilizedAfterAllocation(host, vm)) {
continue;
}

try {
double powerAfterAllocation = getPowerAfterAllocation(host, vm);
if (powerAfterAllocation != -1) {
double powerDiff = powerAfterAllocation - host.getPower();
if (powerDiff < minPower) {
minPower = powerDiff;
allocatedHost = host;
}
}
} catch (Exception e) {
}
}
}
return allocatedHost;
}

/**
* Checks if is host over utilized after allocation.
* @param host the host
* @param vm the vm
* @return true, if is host over utilized after allocation
*/
protected boolean isHostOverUtilizedAfterAllocation(PowerHost host, Vm vm) {
boolean isHostOverUtilizedAfterAllocation = true;
if (host.vmCreate(vm)) {
isHostOverUtilizedAfterAllocation = isHostOverUtilized(host);
host.vmDestroy(vm);
}
return isHostOverUtilizedAfterAllocation;
}

/**
* Find host for vm.
* @param vm the vm
* @return the power host
*/
@Override
public PowerHost findHostForVm(Vm vm) {
Set<Host> excludedHosts = new HashSet<Host>();
if (vm.getHost() != null) {
excludedHosts.add(vm.getHost());
}
return findHostForVm(vm, excludedHosts);
}

/**
* Extract host list from migration map.
* @param migrationMap the migration map
* @return the list
*/
protected List<PowerHost> extractHostListFromMigrationMap(List<Map<String, Object>> migrationMap) {
List<PowerHost> hosts = new LinkedList<PowerHost>();
for (Map<String, Object> map : migrationMap) {
hosts.add((PowerHost) map.get("host"));
}
return hosts;
}

/**
* Gets the new vm placement.
* @param vmsToMigrate the vms to migrate
* @param excludedHosts the excluded hosts
* @return the new vm placement
*/
protected List<Map<String, Object>> getNewVmPlacement(
List<? extends Vm> vmsToMigrate,
Set<? extends Host> excludedHosts) {
List<Map<String, Object>> migrationMap = new LinkedList<Map<String, Object>>();
PowerVmList.sortByCpuUtilization(vmsToMigrate);
for (Vm vm : vmsToMigrate) {
PowerHost allocatedHost = findHostForVm(vm, excludedHosts);
if (allocatedHost != null) {
allocatedHost.vmCreate(vm);
Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId());

Map<String, Object> migrate = new HashMap<String, Object>();
migrate.put("vm", vm);
migrate.put("host", allocatedHost);
migrationMap.add(migrate);
}
}
return migrationMap;
}

/**
* Gets the new vm placement from under utilized host.
* @param vmsToMigrate the vms to migrate
* @param excludedHosts the excluded hosts
* @return the new vm placement from under utilized host
*/
protected List<Map<String, Object>> getNewVmPlacementFromUnderUtilizedHost(
List<? extends Vm> vmsToMigrate,
Set<? extends Host> excludedHosts) {
List<Map<String, Object>> migrationMap = new LinkedList<Map<String, Object>>();
PowerVmList.sortByCpuUtilization(vmsToMigrate);
for (Vm vm : vmsToMigrate) {
PowerHost allocatedHost = findHostForVm(vm, excludedHosts);
if (allocatedHost != null) {
allocatedHost.vmCreate(vm);
Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId());

Map<String, Object> migrate = new HashMap<String, Object>();
migrate.put("vm", vm);
migrate.put("host", allocatedHost);
migrationMap.add(migrate);
} else {
Log.printLine("Not all VMs can be reallocated from the host, reallocation cancelled");
for (Map<String, Object> map : migrationMap) {
((Host) map.get("host")).vmDestroy((Vm) map.get("vm"));
}
migrationMap.clear();
break;
}
}
return migrationMap;
}

/**
* Gets the vms to migrate from hosts.
* @param overUtilizedHosts the over utilized hosts
* @return the vms to migrate from hosts
*/
protected
List<? extends Vm>
getVmsToMigrateFromHosts(List<PowerHostUtilizationHistory> overUtilizedHosts) {
List<Vm> vmsToMigrate = new LinkedList<Vm>();
for (PowerHostUtilizationHistory host : overUtilizedHosts) {
while (true) {
Vm vm = getVmSelectionPolicy().getVmToMigrate(host);
if (vm == null) {
break;
}
vmsToMigrate.add(vm);
host.vmDestroy(vm);
if (!isHostOverUtilized(host)) {
break;
}
}
}
return vmsToMigrate;
}

/**
* Gets the vms to migrate from under utilized host.
* @param host the host
* @return the vms to migrate from under utilized host
*/
protected List<? extends Vm> getVmsToMigrateFromUnderUtilizedHost(PowerHost host) {
List<Vm> vmsToMigrate = new LinkedList<Vm>();
for (Vm vm : host.getVmList()) {
if (!vm.isInMigration()) {
vmsToMigrate.add(vm);
}
}
return vmsToMigrate;
}

/**
* Gets the over utilized hosts.
* @return the over utilized hosts
*/
protected List<PowerHostUtilizationHistory> getOverUtilizedHosts() {
List<PowerHostUtilizationHistory> overUtilizedHosts = new LinkedList<PowerHostUtilizationHistory>();
for (PowerHostUtilizationHistory host : this.<PowerHostUtilizationHistory> getHostList()) {
if (isHostOverUtilized(host)) {
overUtilizedHosts.add(host);
}
}
return overUtilizedHosts;
}

/**
* Gets the switched off host.
* @return the switched off host
*/
protected List<PowerHost> getSwitchedOffHosts() {
List<PowerHost> switchedOffHosts = new LinkedList<PowerHost>();
for (PowerHost host : this.<PowerHost> getHostList()) {
if (host.getUtilizationOfCpu() == 0) {
switchedOffHosts.add(host);
}
}
return switchedOffHosts;
}

/**
* Gets the under utilized host.
* @param excludedHosts the excluded hosts
* @return the under utilized host
*/
protected PowerHost getUnderUtilizedHost(Set<? extends Host> excludedHosts) {
double minUtilization = 1;
PowerHost underUtilizedHost = null;
for (PowerHost host : this.<PowerHost> getHostList()) {
if (excludedHosts.contains(host)) {
continue;
}
double utilization = host.getUtilizationOfCpu();
if (utilization > 0 && utilization < minUtilization
&& !areAllVmsMigratingOutOrAnyVmMigratingIn(host)) {
minUtilization = utilization;
underUtilizedHost = host;
}
}
return underUtilizedHost;
}

/**
* Checks whether all vms are in migration.
* @param host the host
* @return true, if successful
*/
protected boolean areAllVmsMigratingOutOrAnyVmMigratingIn(PowerHost host) {
for (PowerVm vm : host.<PowerVm> getVmList()) {
if (!vm.isInMigration()) {
return false;
}
if (host.getVmsMigratingIn().contains(vm)) {
return true;
}
}
return true;
}

/**
* Checks if is host over utilized.
* @param host the host
* @return true, if is host over utilized
*/
protected abstract boolean isHostOverUtilized(PowerHost host);

/**
* Adds the history value.
* @param host the host
* @param metric the metric
*/
protected void addHistoryEntry(HostDynamicWorkload host, double metric) {
int hostId = host.getId();
if (!getTimeHistory().containsKey(hostId)) {
getTimeHistory().put(hostId, new LinkedList<Double>());
}
if (!getUtilizationHistory().containsKey(hostId)) {
getUtilizationHistory().put(hostId, new LinkedList<Double>());
}
if (!getMetricHistory().containsKey(hostId)) {
getMetricHistory().put(hostId, new LinkedList<Double>());
}
if (!getTimeHistory().get(hostId).contains(CloudSim.clock())) {
getTimeHistory().get(hostId).add(CloudSim.clock());
getUtilizationHistory().get(hostId).add(host.getUtilizationOfCpu());
getMetricHistory().get(hostId).add(metric);
}
}

/**
* Save allocation.
*/
protected void saveAllocation() {
getSavedAllocation().clear();
for (Host host : getHostList()) {
for (Vm vm : host.getVmList()) {
if (host.getVmsMigratingIn().contains(vm)) {
continue;
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("host", host);
map.put("vm", vm);
getSavedAllocation().add(map);
}
}
}

/**
* Restore allocation.
*/
protected void restoreAllocation() {
for (Host host : getHostList()) {
host.vmDestroyAll();
host.reallocateMigratingInVms();
}
for (Map<String, Object> map : getSavedAllocation()) {
Vm vm = (Vm) map.get("vm");
PowerHost host = (PowerHost) map.get("host");
if (!host.vmCreate(vm)) {
Log.printLine("Couldn't restore VM #" + vm.getId() + " on host #" + host.getId());
System.exit(0);
}
getVmTable().put(vm.getUid(), host);
}
}

/**
* Gets the power after allocation.
* @param host the host
* @param vm the vm
* @return the power after allocation
*/
protected double getPowerAfterAllocation(PowerHost host, Vm vm) {
double power = 0;
try {
power = host.getPowerModel().getPower(getMaxUtilizationAfterAllocation(host, vm));
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
return power;
}

/**
* Gets the power after allocation. We assume that load is balanced between PEs. The only
* restriction is: VM's max MIPS < PE's MIPS
* @param host the host
* @param vm the vm
* @return the power after allocation
*/
protected double getMaxUtilizationAfterAllocation(PowerHost host, Vm vm) {
double requestedTotalMips = vm.getCurrentRequestedTotalMips();
double hostUtilizationMips = host.getUtilizationOfCpuMips();
for (Vm vm2 : host.getVmList()) {
if (host.getVmsMigratingIn().contains(vm2)) {
// calculate additional potential CPU usage of a migrating in VM
hostUtilizationMips += host.getTotalAllocatedMipsForVm(vm2) * 0.9 / 0.1;
}
}

double hostPotentialUtilizationMips = hostUtilizationMips + requestedTotalMips;
double pePotentialUtilization = hostPotentialUtilizationMips / host.getTotalMips();
return pePotentialUtilization;
}

/**
* Gets the saved allocation.
* @return the saved allocation
*/
protected List<Map<String, Object>> getSavedAllocation() {
return savedAllocation;
}

/**
* Sets the vm selection policy.
* @param vmSelectionPolicy the new vm selection policy
*/
protected void setVmSelectionPolicy(PowerVmSelectionPolicy vmSelectionPolicy) {
this.vmSelectionPolicy = vmSelectionPolicy;
}

/**
* Gets the vm selection policy.
* @return the vm selection policy
*/
protected PowerVmSelectionPolicy getVmSelectionPolicy() {
return vmSelectionPolicy;
}

/**
* Gets the utilization history.
* @return the utilization history
*/
public Map<Integer, List<Double>> getUtilizationHistory() {
return utilizationHistory;
}

/**
* Gets the metric history.
* @return the metric history
*/
public Map<Integer, List<Double>> getMetricHistory() {
return metricHistory;
}

/**
* Gets the time history.
* @return the time history
*/
public Map<Integer, List<Double>> getTimeHistory() {
return timeHistory;
}

/**
* Gets the execution time history vm selection.
* @return the execution time history vm selection
*/
public List<Double> getExecutionTimeHistoryVmSelection() {
return executionTimeHistoryVmSelection;
}

/**
* Gets the execution time history host selection.
* @return the execution time history host selection
*/
public List<Double> getExecutionTimeHistoryHostSelection() {
return executionTimeHistoryHostSelection;
}

/**
* Gets the execution time history vm reallocation.
* @return the execution time history vm reallocation
*/
public List<Double> getExecutionTimeHistoryVmReallocation() {
return executionTimeHistoryVmReallocation;
}

/**
* Gets the execution time history total.
* @return the execution time history total
*/
public List<Double> getExecutionTimeHistoryTotal() {
return executionTimeHistoryTotal;

RIDDHI PATEL

To unsubscribe from this group and all its topics, send an email to cloudsim+unsubscribe@googlegroups.com.

Riddhi Patel

unread,
Feb 4, 2015, 10:31:02 AM2/4/15
to clou...@googlegroups.com
hello, Zahra  mam'

in PowerVmAllocationPolicyMigrationAbstract class  what i change for modifed best fit decrising aldorithm ??
plzzzz plzz reply ..plz guide me 

RIDDHI PATEL

Zahra Bagheri

unread,
Feb 5, 2015, 5:08:37 AM2/5/15
to clou...@googlegroups.com
Hi

The MBFD algorithm has been implemented in findHostForVm method. So, you can make desired changes there.

elhossiny ibrahim

unread,
Feb 6, 2015, 6:56:50 AM2/6/15
to clou...@googlegroups.com
to  Zahra Bagheri 

i need to implement PSO,ACO  as a resource allocation policies i know that the editing will be in datacenterbroker can you help me to know which functions will be edited or added 
or where my algorithm code will be added to the broker 
thanks in advance
i hope that you answer me please  

Riddhi Patel

unread,
Feb 6, 2015, 7:23:40 AM2/6/15
to clou...@googlegroups.com
Thank you again for reply me ...


yes i know MBFD was implemented . but for changes in this algorithm i want to implement MBFD algorithm in cloudsim . then will i changes according to my parameter .

as you say   findHostForVm method. and      as per my work this java class PowerVmAllocationPolicyMigrationAbstract.java   will be used . that i understand.

but .   acording to this  algorithm steps ,,,Where i codeing  for this ??   i can't understand .  plzz plz mam reply  ...

your all reply is very helpful for my thesis ...plz mam'  plz mam' tell me the ex ate location where i do it ..?

Algorithm 1: Modified Best Fit Decreasing (MBFD)
1Input:hostList,vmList Output:allocation of VMs
2 vmList.sortDecreasingUtilization()
3 foreach vm in vmList do
4 minPower←MAX
5 allocatedHost←NULL
6 foreach host in hostList do
7     if host has enough resource for vm then
8  power←estimatePower(host, vm)
9  if power < minPower then
10   allocatedHost←host
11   minPower←power
12 if allocatedHost≠ NULL then
13     allocate vm to allocatedHost
14return allocation


RIDDHI PATEL

--

Zahra Bagheri

unread,
Feb 6, 2015, 12:00:47 PM2/6/15
to clou...@googlegroups.com
All steps of the algorithm exist in PowerVmAllocationPolicyMigrationAbstract class
and the main steps to specify a host with minimum power consumption
has been implemented in findHostForVm method as follows:

public PowerHost findHostForVm(Vm vm, Set<? extends Host> excludedHosts) {
double minPower = Double.MAX_VALUE; // step 4
PowerHost allocatedHost = null; // step 5

for (PowerHost host : this.<PowerHost> getHostList()) { // step 6
if (excludedHosts.contains(host)) {
continue;
}
if (host.isSuitableForVm(vm)) { // step 7
if (getUtilizationOfCpuMips(host) != 0 && isHostOverUtilizedAfterAllocation(host, vm)) {
continue;
}

try {
double powerAfterAllocation = getPowerAfterAllocation(host, vm); // step 8
if (powerAfterAllocation != -1) {
double powerDiff = powerAfterAllocation - host.getPower();
if (powerDiff < minPower) { // step 9
minPower = powerDiff;
allocatedHost = host; // step 10
}
}
} catch (Exception e) {
}
}
}
return allocatedHost;
}


Algorithm 1: Modified Best Fit Decreasing (MBFD)
1Input:hostList,vmList Output:allocation of VMs
2 vmList.sortDecreasingUtilization()
3 foreach vm in vmList do
4 minPower←MAX
5 allocatedHost←NULL
6 foreach host in hostList do
7     if host has enough resource for vm then
8  power←estimatePower(host, vm)
9  if power < minPower then
10   allocatedHost←host
11   minPower←power
12 if allocatedHost≠ NULL then
13     allocate vm to allocatedHost
14return allocation

So, you can modify the criteria of host selection according to your parameters.

Zahra Bagheri

unread,
Feb 6, 2015, 12:23:29 PM2/6/15
to clou...@googlegroups.com
Hi,
The resource allocation has 2 levels in CloudSim: Host and VM levels.
If you want to apply your algorithm at the host level, you can extend VmAllocationPolicy class
and implement your algorithm in allocateHostForVm method of this class.
At the VM level, DatacenterBroker class can be extended and submitCloudlets method
in this class has to modify in order to allocate a specific VM to a cloudlet.
Regards

--

elhossiny ibrahim

unread,
Feb 6, 2015, 12:38:53 PM2/6/15
to clou...@googlegroups.com
hi 
i am very thankful for you
what is the parameters that i will use it to compare and evaluate between different algorithms  ??

Riddhi Patel

unread,
Feb 7, 2015, 3:56:33 AM2/7/15
to clou...@googlegroups.com
thank you ..so much mam' ... your reply is really really helpfull  for my thesis.... thank you so much ...

RIDDHI PATEL

elhossiny ibrahim

unread,
Feb 7, 2015, 5:08:12 AM2/7/15
to clou...@googlegroups.com
to  Zahra Bagheri
hi 

Riddhi Patel

unread,
Feb 24, 2015, 12:43:45 AM2/24/15
to clou...@googlegroups.com
hello Zahra mam' 
                                till  now i m changeing the cloudexample which is cloudsim provide . and i do my work . but in some days the examples output was not changing . i change the vmid  , Mips , all perameter but output  was not change ... 

i know there was some  problem . but i can't fine the problem what it is . 

plzz plz  mam help me ..why my any examples is not change ..??  

RIDDHI PATEL

--

Yodit Gebrealif

unread,
Feb 24, 2015, 7:25:35 AM2/24/15
to clou...@googlegroups.com
hi dear Zahra
how can i calculate the expected response time of cloud let before assign to VM. please help me it is very urgent

desai megha

unread,
Feb 28, 2015, 11:42:41 PM2/28/15
to clou...@googlegroups.com
i want to migrate vm from one machine to another using one perticular algorithm in cloudsim ..where should i place it ??and how??please help me



On Tuesday, January 13, 2015 at 7:57:54 AM UTC+5:30, Riddhi Patel wrote:
Algorithm 1: Modified Best Fit Decreasing (MBFD)
1Input:hostList,vmList Output:allocation of VMs
2 vmList.sortDecreasingUtilization()
3 foreach vm in vmList do
4 minPower←MAX
5 allocatedHost←NULL
6 foreach host in hostList do
7     if host has enough resource for vm then
8  power←estimatePower(host, vm)
9  if power < minPower then
10   allocatedHost←host
11   minPower←power
12 if allocatedHost≠ NULL then
13     allocate vm to allocatedHost
14return allocation


Riddhi Patel

unread,
Mar 12, 2015, 8:38:53 AM3/12/15
to clou...@googlegroups.com
hello  Zahara mam'   
                    in previous u really help me ..  plzz help me again 

 how i add the power policy in program ..? 

Mansoor Ganji

unread,
Dec 22, 2015, 1:51:54 AM12/22/15
to cloudsim

خانم دکتر یا مهندس باقری (ببخشید نمی دانم که مدرکتان چیست)

باسلام و احترام ، طبق بررسی های سوال و جوابهای انجام شده در گروه ظاهرا جنابعالی از همه مسلط تر به بحث کلادسیم و کاهش مصرف توان می باشید می خواستم خواهش کنم با توجه به زمان کم باقیمانده من به دفاعیه ام بنده را راهنمایی فرمایید ضمن اینکه اگر امکان داشته باشد مستقیما با ایمیل جنابعالی در تماس باشم .

من می خواهم با شبیه ساز کلادسیم دو تا کلاستر داشته باشم که خود شامل چهار دیتا سنتر و ۵ هاست و ۶ وی ام می باشد و در نهایت می خواهم نسبت به کاهش مصرف توان بایک اللگوریتم اقدام نمایم . خواهشمند است راهنمایی فرمایید که اولا امکان ایجاد کلاستر در فسمت پاور کلاد سیم وجود دارد یا خیر و به چه صورت ؟ در ثانی به چه صورت می توانم شرایط را به گونه ای ایجاد کنم که خود سیستم از کلاستری که مصرف توان کمتری دارد استفاده نماید؟


باسپاس بیکران-

Mansoor Ganji

unread,
Dec 22, 2015, 1:52:14 AM12/22/15
to cloudsim

خانم دکتر یا مهندس باقری (ببخشید نمی دانم که مدرکتان چیست)

باسلام و احترام ، طبق بررسی های سوال و جوابهای انجام شده در گروه ظاهرا جنابعالی از همه مسلط تر به بحث کلادسیم و کاهش مصرف توان می باشید می خواستم خواهش کنم با توجه به زمان کم باقیمانده من به دفاعیه ام بنده را راهنمایی فرمایید ضمن اینکه اگر امکان داشته باشد مستقیما با ایمیل جنابعالی در تماس باشم .

من می خواهم با شبیه ساز کلادسیم دو تا کلاستر داشته باشم که خود شامل چهار دیتا سنتر و ۵ هاست و ۶ وی ام می باشد و در نهایت می خواهم نسبت به کاهش مصرف توان بایک اللگوریتم اقدام نمایم . خواهشمند است راهنمایی فرمایید که اولا امکان ایجاد کلاستر در فسمت پاور کلاد سیم وجود دارد یا خیر و به چه صورت ؟ در ثانی به چه صورت می توانم شرایط را به گونه ای ایجاد کنم که خود سیستم از کلاستری که مصرف توان کمتری دارد استفاده نماید؟


باسپاس بیکران-


On Wednesday, January 28, 2015 at 8:27:29 PM UTC+3:30, Zahra Bagheri wrote:

Kartik Maheshwari

unread,
Feb 2, 2016, 1:25:08 AM2/2/16
to cloudsim

its very imp for me ... plz help me to implement this algo in cloudsim, please guide me ,




Riddhi Patel

unread,
Feb 3, 2016, 12:11:32 AM2/3/16
to clou...@googlegroups.com
 hello ..

  Refer  PowerVmAllocationPolicyMigrationAbstract class in the following path:
org.cloudbus.cloudsim.power
Then you can find the aforesaid algorithm in findHostForVm method:
public PowerHost findHostForVm(Vm vm, Set<? extends Host> excludedHosts)

 Mrs. RIDDHI PATEL
Assistant Professer  SCET

On Tue, Feb 2, 2016 at 11:55 AM, Kartik Maheshwari <er.kar...@gmail.com> wrote:

its very imp for me ... plz help me to implement this algo in cloudsim, please guide me ,




mokhtar alwrafi

unread,
Feb 27, 2016, 1:56:33 AM2/27/16
to cloudsim
Hi Zahra ...
how can i add the scheduling algorithm to cloudsim
Is there any scheduling algorithm in 8 exmples that alrady in cloudsim ?

mokhtar alwrafi

unread,
Feb 27, 2016, 1:57:20 AM2/27/16
to cloudsim
Hi Zahra

Zahra Bagheri

unread,
Feb 27, 2016, 2:17:31 AM2/27/16
to clou...@googlegroups.com
Hi
The scheduling algorithms have been implemented in 2 levels: Host and VM
In both levels, there are time-shared and space-shared scheduler which defined in VmScheduler and CloudletScheduler.
Refer to the following classes used in CloudSim examples:
VmSchedulerSpaceShared
VmSchedulerTimeShared
CloudletSchedulerSpaceShared
CloudletSchedulerTimeShared

Regards

--

mokhtar alwrafi

unread,
Feb 29, 2016, 2:22:18 PM2/29/16
to cloudsim
Thank u for replay ....
but still i got confused .....i install cloudsim without error and i implement that examples include in cloudsim tools, then now i have RR example as example 9 when i added to 8 examples and i implemented it but not work ...

Zahra Bagheri

unread,
Mar 1, 2016, 11:37:39 PM3/1/16
to clou...@googlegroups.com
What is the problem? Where did you add your scheduling algorithm?

mokhtar alwrafi

unread,
Mar 2, 2016, 5:17:06 AM3/2/16
to cloudsim
Pls can u give me ur email or any way to contact with u fast...
my problem reduce makespan and cost for task scheduling in cloud.

mokhtar alwrafi

unread,
Mar 4, 2016, 4:13:51 AM3/4/16
to cloudsim
My problem how can reduce total execution time (makespan) and cost for task scheduling in cloud.


soud

unread,
Mar 15, 2016, 12:51:27 AM3/15/16
to cloudsim
please share with us the procedure as we have similar scheduling algorithm.
let discuss here.

souad

unread,
Apr 28, 2016, 5:12:03 AM4/28/16
to cloudsim
Hello Zahra,
 Could you please help on where to add the scheduling algorithm for GA and PSO algorithm , which package, which task and method,
Please I would appreciate if you help. It is really urgent for me. 
Thank you. 

Vivek Rajani

unread,
Apr 29, 2016, 10:44:21 AM4/29/16
to cloudsim

Hello, All researchers

I want to know below algorithm is implemented somewhere in cloudsim or not?

If anyone have sample code of this algorithm plz share it, I want to learn about it


I.  Input: hostList, VMList Output: allocation of VMs
2. Cluster=MK(VMList)
3. arrangeByHighDensityCluster(cluster, VMList)
4. foreach VM in VMList do
5. maxPower = Double. MIN_ VALUE
6. allocatedHost = null
7. foreach host in hostList do
8. if host has enough resources for VM
9. power After Allocation = getPower After Allocation(host, VM)
10. powerDiff= powerAfterAlIocation - host.getPowerO
II.   If powerDiff > maxPower
12. maxPower = powerDiff
13. allocatedHost = host
14. If allocatedHost f. null then
15. allocation.add(VM,allocatedHost)
16. Return allocation

mokhtar alwrafi

unread,
May 14, 2016, 3:01:04 AM5/14/16
to cloudsim
In CloudSim, how can I calculate utilization and cost of bandwidth for each vm when the cloudlets are running?


I am now trying to calculate the utilization of bandwidth for vm, so can any one tell me, how can I calculate utilization and cost of bandwidth for each vm when the cloudlets are running?

fazel saberi

unread,
Feb 4, 2017, 3:54:07 PM2/4/17
to cloudsim

Hi - I need a project that has ifogsim in the Internet of Things is simulated. In terms of reducing latency nodes. I need programming code into this project. Thankful

fazel saberi

unread,
Feb 4, 2017, 3:57:04 PM2/4/17
to cloudsim
سلام و عرض ادب خدمت همشهری گرامی سرکار خانم باقری - در خصوص شبیه سازی با ifog میتونم ازتون راهنمایی بگیرم؟


On Wednesday, January 21, 2015 at 7:40:55 AM UTC-8, Zahra Bagheri wrote:
Which class did you run? In order to get the output of Power examples run one of classes in the following paths:
org.cloudbus.cloudsim.examples.power.planetlab
org.cloudbus.cloudsim.examples.power.random

On Wed, Jan 21, 2015 at 4:18 PM, Riddhi Patel <riddhi....@gmail.com> wrote:
but this program is nor running .. " RunnerAbstract class dose not have main method "  this error is generate .now what i do..??? 
plzzz reply  me  Zahra  medam ...

RIDDHI PATEL

On Wed, Jan 21, 2015 at 6:12 PM, Riddhi Patel <riddhi....@gmail.com> wrote:
thank you soo much for reply ..


RIDDHI PATEL

On Thu, Jan 15, 2015 at 9:01 PM, Zahra Bagheri <zha.b...@gmail.com> wrote:
Hi,

This algorithm already has been implemented in the power package of CloudSim.
Refer to PowerVmAllocationPolicyMigrationAbstract class in the following path:
org.cloudbus.cloudsim.power
Then you can find the aforesaid algorithm in findHostForVm method:
public PowerHost findHostForVm(Vm vm, Set<? extends Host> excludedHosts)

Regards

On Tuesday, January 13, 2015 at 5:57:54 AM UTC+3:30, Riddhi Patel wrote:
Algorithm 1: Modified Best Fit Decreasing (MBFD)
1Input:hostList,vmList Output:allocation of VMs
2 vmList.sortDecreasingUtilization()
3 foreach vm in vmList do
4 minPower←MAX
5 allocatedHost←NULL
6 foreach host in hostList do
7     if host has enough resource for vm then
8  power←estimatePower(host, vm)
9  if power < minPower then
10   allocatedHost←host
11   minPower←power
12 if allocatedHost≠ NULL then
13     allocate vm to allocatedHost
14return allocation


hello... this is my existing algorithm . and i want to implement it in to the cloudsim using netbeans. how i work on it pllzzz plzzz plzzz reply me if anyone know ...its realy important for me ..
thank you..

--

---
You received this message because you are subscribed to a topic in the Google Groups "cloudsim" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cloudsim/PoSb3y8Mq4c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cloudsim+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

fazel saberi

unread,
Feb 4, 2017, 4:14:33 PM2/4/17
to cloudsim
Hi - I need a project that has ifogsim in the Internet of Things is simulated. In terms of reducing latency nodes. I need programming code into this project. Thankful


Simar Preet Singh

unread,
Feb 17, 2017, 11:47:23 PM2/17/17
to cloudsim
Respected fazel saberi,

Are you working on iFogSim?
What is your email id?

Regards,
Simar Preet Singh
er.simarp...@gmail.com                

va...@mst.edu

unread,
May 24, 2017, 1:32:09 AM5/24/17
to cloudsim

Hi. I want to add a cryptographic module in my iFogSim simulation. Is it possible ??

sa sa

unread,
Oct 14, 2017, 6:48:26 PM10/14/17
to cloudsim
سلام خانم باقری . موضوع پایان نامه من : بهبود مصرف انرژی درمهاجرت ماشین مجازی با استفاده از الگوریتم چکه های آب هوشمند هستش . میشه راهنمایی کنید که کد الگوریتم رو دقیقا باید در کدام پکیج و یا کدام کلاس بیارم ؟


On Thursday, January 15, 2015 at 7:01:57 PM UTC+3:30, Zahra Bagheri wrote:
Hi,

This algorithm already has been implemented in the power package of CloudSim.
Refer to PowerVmAllocationPolicyMigrationAbstract class in the following path:
org.cloudbus.cloudsim.power
Then you can find the aforesaid algorithm in findHostForVm method:
public PowerHost findHostForVm(Vm vm, Set<? extends Host> excludedHosts)

Regards

Zahra Bagheri

unread,
Oct 19, 2017, 7:23:51 AM10/19/17
to clou...@googlegroups.com

سلام
کلاس
PowerVmAllocationPolicyMigrationAbstract
متدهای
OptimizeAllocation
و
FindHostForVm

--

Dalia Sobhy

unread,
Jan 13, 2018, 4:57:47 AM1/13/18
to cloudsim
Hello all,

I am new to ifogsim and have read the pdf tutorial. But actually I have mainly a particular question how to measure the QoS of fog devices in terms of power consumption, the response time and cost and so on ?

Thanks

hadismoha...@gmail.com

unread,
Apr 24, 2019, 11:27:23 AM4/24/19
to cloudsim
با سلام.. امکانش هست در خصوص اولویت دهی به کلودلت ها و تخصیص اونها به ماشین های مجازی راهنمایی کنید .
و این که امکانش هست که هاست ها رو در لبه شبکه بر اساس سوییچ هایی که به آن متصل شده اند دسته بندی کرد؟


On Thursday, October 19, 2017 at 2:53:51 PM UTC+3:30, Zahra Bagheri wrote:

سلام
کلاس
PowerVmAllocationPolicyMigrationAbstract
متدهای
OptimizeAllocation
و
FindHostForVm

To unsubscribe from this group and all its topics, send an email to clou...@googlegroups.com.

Priyanka

unread,
Apr 28, 2019, 10:33:39 AM4/28/19
to cloudsim
hello mam, 
I have proposed an algorithm for vm scheduling (to schedule vm on host). I have implemented my proposed approach in cloudsim by updating VMAllocationPolicy class but till now the resource requirement  of VM is static. I have query that during simulation how I can change resources requirement (cpu, memory and bandwidth) of a VM. after change in requirement I need to calculate overloaded host on the basis of utilization of host. During simulation how I can calculate utilization of host (to detect overloaded or not). Do I need to pause the simulation, what I have to do. please help..  

On Thursday, October 19, 2017 at 4:53:51 PM UTC+5:30, Zahra Bagheri wrote:

سلام
کلاس
PowerVmAllocationPolicyMigrationAbstract
متدهای
OptimizeAllocation
و
FindHostForVm

To unsubscribe from this group and all its topics, send an email to clou...@googlegroups.com.

Rahmat Andishmand

unread,
Apr 2, 2020, 8:53:00 AM4/2/20
to cloudsim
hello zahra may i have your whatsaap number i have some question in cloudsim

Rahmat Andishmand

unread,
Apr 2, 2020, 9:04:34 AM4/2/20
to cloudsim
سلام زهرا  اگر امکانش است لطفا شماره واتساب خود تون را برایم بفرستین سوال دارم
Reply all
Reply to author
Forward
0 new messages