コードは次のとおりです。ラウンド ロビン スケジューリングの適用方法
public class RoundRobinVmLoadBalancer extends VmLoadBalancer
{
private Map<Integer, VirtualMachineState> vmStatesList;
private int currVm = -1;
public RoundRobinVmLoadBalancer(Map<Integer, VirtualMachineState> vmStatesList)
{
super();
this.vmStatesList = vmStatesList;
}
/* (non-Javadoc)
* @see cloudsim.ext.VMLoadBalancer#getVM()
*/
public int getNextAvailableVm(){
currVm++;
if (currVm >= vmStatesList.size()){
currVm = 0;
}
allocatedVm(currVm);
return currVm;
}
}
VmLoadBalancer
import java.util.Map;
import java.util.HashMap;
/**
* This is the base class defining the behaviour of a Virtual Machine load
balancer
* used by a {@link DatacenterController}. The main method all load balancers
should implement
* is <c
ode>public int getNextAvailableVm()</code>.
*
* This class provides a basic load balancing statistic collection that can be used by
* implementing classes. The implementing classes should call the <code>void allocatedVM(int currVm)</code>
* method to use the statisitics collection feature.
*
*/
abstract public class VmLoadBalancer
{
/** Holds the count of allocations for each VM */
protected Map<Integer, Integer> vmAllocationCounts;
/** No args contructor */
public VmLoadBalancer(){
vmAllocationCounts = new HashMap<Integer, Integer>();
}
/**
* The main contract of {@link VmLoadBalancer}. All load balancers should implement
* this method according to their specific load balancing policy.
*
* @return id of the next available Virtual Machine to which the next task should be
* allocated
*/
abstract public int getNextAvailableVm();
/**
* Used internally to update VM allocation statistics. Should be called by all impelementing
* classes to notify when a new VM is allocated.
*
* @param currVm
*/
protected void allocatedVm(int currVm){
Integer currCount = vmAllocationCounts.get(currVm);
if (currCount == null){
currCount = 0;
}
vmAllocationCounts.put(currVm, currCount + 1);
}
/**
* Returns a {@link Map} indexed by VM id and having the number of allocations for each VM.
* @return
*/
public Map<Integer, Integer> getVmAllocationCounts()
{
return vmAllocationCounts;
}
}
Round Robin のように、負荷分散ポリシーとして Ant Colony の最適化を適用したいと考えています。しかし、ラウンド ロビンがどのように実装されているかは明確ではありません。cloud_analyst の cloudsim プロジェクトに見られるラウンド ロビンのコードはありません。ACO を適用するにはどうすればよいですか。cloudsim に適用された ACO コード スニペットを親切に共有してください。