コード例 #1
0
ファイル: TestEj5.java プロジェクト: ilebrero/Algo3-TP3
  @Test
  public void testGrafo() {
    for (int i = 0; i < 100000000; i++) {
      Math.random();
    }

    GrafoPredicados grafo = generateStar(10, 10, 8);
    ArrayList<Tuple<Integer, Integer>> aristas = generateAristas(10, 10);
    int cantAristas = aristas.size();

    for (int i = 0; i < cantAristas; i++) {
      for (int j = 0; j < 100; j++) {
        Tuple<Integer, Integer> tuple = aristas.get(0);
        aristas.remove(0);
        grafo.connectMateria(tuple.getX(), tuple.getY());
      }

      double tiempoFinal = 0;
      Ejercicio3 ej;
      int conflictos1 = Integer.MAX_VALUE;
      for (int j = 0; j < 3; j++) {
        ej = new Ejercicio3(grafo);
        double tiempo = System.nanoTime();
        conflictos1 = Math.min(conflictos1, ej.checkColoreoFinal());
        tiempoFinal += (System.nanoTime() - tiempo) / 1000;
      }
      System.out.print(tiempoFinal + ";" + conflictos1 + ";");

      conflictos1 = 0;
      for (int j = 0; j < 3; j++) {
        Ejercicio2 ej2 = new Ejercicio2(grafo);
        double tiempo = System.nanoTime();
        if (ej2.solverWithBacktrack()) {
          conflictos1 = 0;
        } else {
          conflictos1 = 1;
        }
        tiempoFinal += (System.nanoTime() - tiempo) / 1000;
      }
      System.out.print(tiempoFinal + ";" + conflictos1 + ";");

      System.out.println();
    }
  }
コード例 #2
0
ファイル: TestEj5.java プロジェクト: ilebrero/Algo3-TP3
  //	@Test
  public void testEstrella() {
    for (int i = 0; i < 100000000; i++) {
      Math.random();
    }

    for (int i = 0; i < 1000; i++) {
      double tiempoFinal = 0;
      Ejercicio3 ej;
      GrafoPredicados grafo = generateStar(i, i, 100);
      int conflictos1 = Integer.MAX_VALUE;
      for (int j = 0; j < 3; j++) {
        ej = new Ejercicio3(grafo);
        double tiempo = System.nanoTime();
        conflictos1 = Math.min(conflictos1, ej.checkColoreo());
        tiempoFinal += (System.nanoTime() - tiempo) / 1000;
      }
      System.out.println(tiempoFinal + ";" + conflictos1);
    }
  }
コード例 #3
0
ファイル: TestEj5.java プロジェクト: ilebrero/Algo3-TP3
  @Test
  public void testGrafoBipartito() {
    for (int i = 0; i < 100000000; i++) {
      Math.random();
    }

    for (int i = 1; i < 1000; i++) {
      GrafoPredicados grafo = generateBiPartitoCompleto(i, i, 2);

      double tiempoFinal = 0;
      Ejercicio3 ej;
      int conflictos1 = Integer.MAX_VALUE;
      for (int j = 0; j < 3; j++) {
        ej = new Ejercicio3(grafo);
        double tiempo = System.nanoTime();
        conflictos1 = Math.min(conflictos1, ej.checkColoreoFinal());
        tiempoFinal += (System.nanoTime() - tiempo) / 1000;
      }
      System.out.print(tiempoFinal + ";" + conflictos1 + ";");

      conflictos1 = 0;
      for (int j = 0; j < 3; j++) {
        Ejercicio2 ej2 = new Ejercicio2(grafo);
        double tiempo = System.nanoTime();
        if (ej2.solverWithBacktrack()) {
          conflictos1 = 0;
        } else {
          conflictos1 = 1;
        }
        tiempoFinal += (System.nanoTime() - tiempo) / 1000;
      }
      System.out.print(tiempoFinal + ";" + conflictos1 + ";");

      System.out.println();
    }
  }