Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList aux = new ArrayList();
- ArrayList BestVecino = new ArrayList();
- aux = (ArrayList) this.solucion.clone();
- int iReinicio = 0;
- int nReinicio = 0;
- for (int i = 0; i < 10000; i++) {
- BestVecino = (ArrayList) this.solucion.clone();
- while (i < 10000 && iReinicio < 100) {
- System.out.println("\nITERACION: " + (i + 1));
- aux = this.genVecinos(aux);
- System.out.print("\tRECORRIDO: ");
- for (int j = 0; j < aux.size(); j++) {
- System.out.print(aux.get(j) + " ");
- }
- System.out.println("\n\tCOSTE (km): " + this.calculoCoste(aux));
- if (this.calculoCoste(aux) < this.calculoCoste(this.solucion)) {
- this.solucion = (ArrayList) aux.clone();
- iReinicio = 0;
- iteracion = i;
- } else {
- iReinicio++;
- }
- System.out.println("\tITERACIONES SIN MEJORA: " + iReinicio);
- System.out.println("\tLISTA TABU:");
- for (int k = 0; k < this.TABU.size(); k++) {
- System.out.println("\t" + (int) this.TABU.get(k).getX() + " " + (int) this.TABU.get(k).getY());
- }
- i++;
- }
- if (iReinicio == 100) {
- nReinicio++;
- iReinicio = 0;
- System.out.println("\n***************");
- System.out.println("REINICIO: " + nReinicio);
- System.out.println("***************");
- this.TABU = new ArrayList<>(); //reseteamos tabú
- aux = (ArrayList) this.solucion.clone();
- i--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement