title: Adding Ant Colony Optimization as Load balancing Policy across VM's in a single Data Center
body: <p><a href="http://cloudsim-setup.blogspot.in/2013/01/running-and-using-cloud-analyst.html" rel="nofollow noreferrer">running-and-using-cloud-analyst</a></p>
  
  <p>Here is code How Round Robin Scheduling is applied </p>
  
  <pre><code>public class RoundRobinVmLoadBalancer extends VmLoadBalancer 
  
  {
  
      private Map&lt;Integer, VirtualMachineState&gt; vmStatesList;
  
      private int currVm = -1;
  
      public RoundRobinVmLoadBalancer(Map&lt;Integer, VirtualMachineState&gt; vmStatesList)
  
      {
  
          super();
          this.vmStatesList = vmStatesList;
      }
  
      /* (non-Javadoc)
       * @see cloudsim.ext.VMLoadBalancer#getVM()
       */
      public int getNextAvailableVm(){
          currVm++;
  
          if (currVm &gt;= vmStatesList.size()){
              currVm = 0;
          }
  
          allocatedVm(currVm);
  
          return currVm;
  
      }
  }
  </code></pre>
  
  <p><strong>VmLoadBalancer</strong> </p>
  
  <pre><code>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 &lt;c
  ode&gt;public int getNextAvailableVm()&lt;/code&gt;.
   * 
   * This class provides a basic load balancing statistic collection that can be used by 
   * implementing classes. The implementing classes should call the  &lt;code&gt;void allocatedVM(int currVm)&lt;/code&gt;
   *  method to use the statisitics collection feature.
   * 
   */
  abstract public class VmLoadBalancer 
  {
  
  /** Holds the count of allocations for each VM */
  
  protected Map&lt;Integer, Integer&gt; vmAllocationCounts;
  
      /** No args contructor */
  
      public VmLoadBalancer(){
  
      vmAllocationCounts = new HashMap&lt;Integer, Integer&gt;();
  
      }
  
      /**
       * 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&lt;Integer, Integer&gt; getVmAllocationCounts()
  
  {
  
      return vmAllocationCounts;
  
  }
  
  }
  </code></pre>
  
  <p>Like Round Robin I want to apply Ant Colony optimization as Load Balancing Policy. But It is Not clear that How Round Robin is being implemented there is no code of Round Robin seen in cloud_analyst cloudsim project then how do i apply A C O , kindly share A C O code snippet applied in cloudsim</p>