Createdcenter datacenter0 = createDC(“DataCenter”);
broker = createBroker();
brokerId = broker.getId();
bvmlist = createVM();
coalition.add(“Coalition” + finalResult.get(key));
list1.add(“VM#” + String.valueOf(key));
Associate payoff for each coalition. Payoff depends on the quantity and quality of resources. The coalition that is able to satisfy a task with the least wastage of resources is entitled to a higher payoff.
//coalition of host1
System.out.println(“\n” + “coalition of host 1”);
capability[0] = h1Pe + h0Pe;
capability[1] = h1Pe + h2Pe;
capability[2] = h1Pe + h3Pe;
idx[0] = “10”;
idx[1] = “12”;
idx[2] = “13”;
for (int i = 0; i < vmlist.size(); i++) {
VirtualMachine vm = vmlist.get(i);
int numOfpe = vm.getNumberOfPes();
int sf = numOfpe + 1; // Scalling Factor
double payoff = 0.0;
int vid = vm.getId();
for (int j = 0; j < capability.length; j++) {
int dc = capability[j];
if (dc < numOfpe) {
payoff = ((double) dc – (double) numOfpe) * ((double) h0Pe / (double) dc);
} else if (dc == numOfpe) {
payoff = sf * ((double) h0Pe / (double) dc);
} else if (dc > numOfpe) {
payoff = (sf – (((double) dc – (double) numOfpe))) * ((double) h0Pe / (double) dc);
}
if (hmap.containsKey(vid)) {
double lastpf = hmap.get(vid);
if (payoff > lastpf) {
hmap.put(vid, payoff);
finalResult.put(vid, idx[j]);
}
} else {
hmap.put(vid, payoff);
finalResult.put(vid, idx[j]);
}
System.out.println(“VM#” + vm.getId() + ” ===> ” + payoff);
}
}
Task is allocated to the selected best coalition.
taskidList.add(String.valueOf(cllist.get(i)));
vmIdlist.add(String.valueOf(vmidlist.get(k)));
vmMipsList.add(String.valueOf(vmdisplay.get(k)));