Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I discover an error in finHostForVm function #167

Open
amrous opened this issue Sep 13, 2023 · 0 comments
Open

I discover an error in finHostForVm function #167

amrous opened this issue Sep 13, 2023 · 0 comments

Comments

@amrous
Copy link

amrous commented Sep 13, 2023

Dear CloudSim Development Team,

I hope this message finds you well.
I have been using CloudSim and recently came across what appears to be a potential issue in the implementation of the Power-aware, Best-Fit (PABFD) Virtual Machine allocation policy through the findHostForVm function.

The issue I've observed pertains to the calculation of powerDiff before and after creating a virtual machine on a given host. It seems that the original algorithm, as implemented in CloudSim, does not take into account the presence of other VMs that may already created on the host during the current vmList placement, before allocating the current VM.
To address this, I have made a modification to the code.
Instead of using host.getPower(), I suggest using getUtilizationOfCpuMips(host) to obtain the host's utilization.
This modification allows for a more accurate calculation of powerDiff while considering existing VMs on the host.
Additionally, when allocating a VM on a host that is switched off and has no utilization,
I propose that the cost should be based solely on powerAfterAllocation rather than powerAfterAllocation - powerBeforeAllocation.
This adjustment accounts for the fact that powerBeforeAllocation is equal to zero when the host is switched off.
Here is the modified code snippet that reflects these changes:

`public PowerHost findHostForVm2(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 (getUtilizationOfCpuMips(host) != 0 && isHostOverUtilizedAfterAllocation(host, vm)) {
				
				continue;
			}
			

			try {
				double powerAfterAllocation = getPowerAfterAllocation(host, vm);
				if (powerAfterAllocation != -1) {
					
					
					double powerDiff;
					if (getUtilizationOfCpuMips(host) == 0) {
						powerDiff=powerAfterAllocation;
					}
					else {
						powerDiff= powerAfterAllocation -host.getPowerModel().getPower(getUtilizationOfCpuMips(host)/ (host).getTotalMips());
						
						}
					
					if (powerDiff < minPower) {
						
						minPower = powerDiff;
						allocatedHost = host;
						
					}
				}
				
			} catch (Exception e) {
				
			}
			
			
		}
		
		
	}
	return allocatedHost;
}`

I kindly request your consideration of these suggestions for improving the accuracy of the PABFD algorithm in CloudSim.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant