Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. ArrayList aux = new ArrayList();
  2.         ArrayList BestVecino = new ArrayList();
  3.         aux = (ArrayList) this.solucion.clone();
  4.         int iReinicio = 0;
  5.         int nReinicio = 0;
  6.         for (int i = 0; i < 10000; i++) {
  7.             BestVecino = (ArrayList) this.solucion.clone();
  8.             while (i < 10000 && iReinicio < 100) {
  9.                 System.out.println("\nITERACION: " + (i + 1));
  10.                 aux = this.genVecinos(aux);
  11.                 System.out.print("\tRECORRIDO: ");
  12.                 for (int j = 0; j < aux.size(); j++) {
  13.                     System.out.print(aux.get(j) + " ");
  14.                 }
  15.                 System.out.println("\n\tCOSTE (km): " + this.calculoCoste(aux));
  16.  
  17.                 if (this.calculoCoste(aux) < this.calculoCoste(this.solucion)) {
  18.                     this.solucion = (ArrayList) aux.clone();
  19.                     iReinicio = 0;
  20.                     iteracion = i;
  21.                 } else {
  22.                     iReinicio++;
  23.                 }
  24.                 System.out.println("\tITERACIONES SIN MEJORA: " + iReinicio);
  25.                 System.out.println("\tLISTA TABU:");
  26.                 for (int k = 0; k < this.TABU.size(); k++) {
  27.                     System.out.println("\t" + (int) this.TABU.get(k).getX() + " " + (int) this.TABU.get(k).getY());
  28.                 }
  29.                 i++;
  30.             }
  31.             if (iReinicio == 100) {
  32.                 nReinicio++;
  33.                 iReinicio = 0;
  34.                 System.out.println("\n***************");
  35.                 System.out.println("REINICIO: " + nReinicio);
  36.                 System.out.println("***************");
  37.                 this.TABU = new ArrayList<>(); //reseteamos tabú
  38.                 aux = (ArrayList) this.solucion.clone();
  39.                 i--;
  40.             }
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement