(a) generate: Generate multiple copies of all the     combinations as   .  Append as the position numbers of . Then append and to store the energies. (b) energy: Compute the dissimilarities of the possible clusters and store in energy. (c) find: Find the best solution. (d) count: Count the number of clusters. Now we present algorithms to implement the above procedures. (a) Generation of all the possible   solutions. Append values in order to store the energies. generate for     to     do for     to endfor for     to endfor for     to endfor for     downto endfor endfor . for     to endfor . (b) Energy computation. The problem is to compute totals of energy for those     where . Hence   and   .  The total energy is stored in   .  At the same time, the counting number of each bin is stored in the following     stickers. energy for     to     do endfor for     to     do for     to     do if   yes then endif endfor endfor for      to      do for      to      do for      to      do endfor endfor endfor (c) The next step is to find the best solution with least energy. If   yes in the final step, then we get the optimal solution. The final number     of clusters in stored in the last sticker. find , for     to     do , if     no then else endif endfor . (d) The final step is to count the number of clusters. It is stored in the last sticker while in the variable   . count for     to     do if   yes then endif endfor
Algorithm 3