Exemplo n.º 1
0
  private void TSPHillClimbingSearch(ProbTSPBoard TSPB, java.awt.TextArea a) {
    // System.out.println("\nTSP HillClimbing  -->");
    try {
      Problem problem =
          new Problem(
              TSPB,
              new ProbTSPSuccessorFunction(),
              new ProbTSPGoalTest(),
              new ProbTSPHeuristicFunction());
      Search search = new HillClimbingSearch();
      SearchAgent agent = new SearchAgent(problem, search);

      // System.out.println();
      printActions(agent.getActions(), a);
      // printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  private void TSPSimulatedAnnealingSearch(ProbTSPBoard TSPB, java.awt.TextArea a) {
    // System.out.println("\nTSP Simulated Annealing  -->");
    try {
      Problem problem =
          new Problem(
              TSPB,
              new ProbTSPSuccessorFunctionSA(),
              new ProbTSPGoalTest(),
              new ProbTSPHeuristicFunction());
      SimulatedAnnealingSearch search =
          new SimulatedAnnealingSearch(
              NiterS.getValue(),
              1000,
              ParKS.getValue(),
              numForm.parse(LambdaFT.getText()).doubleValue());
      // search.traceOn();
      SearchAgent agent = new SearchAgent(problem, search);

      printActions(agent.getActions(), a);
      // printInstrumentation(agent.getInstrumentation());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
  private void ejecutarMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_ejecutarMousePressed
    // TODO add your handling code here:
    Search search = null; // new DepthLimitedSearch(2*nc);;
    Problem problem =
        null; //  new Problem(p,new ProbAntenasSuccessorFunction(), new ProbAntenasGoalTest(),new
              // ProbAntenasHeuristicFunction());

    p.solucionInicial();
    // p.printAntenas();

    if (heur == 1)
      problem =
          new Problem(
              p,
              new ProbAntenasSuccessorFunction(),
              new ProbAntenasGoalTest(),
              new ProbAntenasHeuristicFunction());
    if (heur == 2)
      problem =
          new Problem(
              p,
              new ProbAntenasSuccessorFunction(),
              new ProbAntenasGoalTest(),
              new ProbAntenasHeuristicFunction2());
    if (heur == 3)
      problem =
          new Problem(
              p,
              new ProbAntenasSuccessorFunction(),
              new ProbAntenasGoalTest(),
              new ProbAntenasHeuristicFunction3());

    if (alg == 1) search = new HillClimbingSearch();
    if (alg == 2) search = new SimulatedAnnealingSearch(2000, 100, 5, 0.001);

    // p.printCobertura();
    // System.out.println("--"+p.calculaCobertura());

    //     Search search =  new BreadthFirstSearch(new TreeSearch());
    // Search search =  new HillClimbingSearch();
    try {
      Date d1, d2;
      Calendar a, b;

      d1 = new Date();
      SearchAgent agent = new SearchAgent(problem, search);
      d2 = new Date();

      a = Calendar.getInstance();
      b = Calendar.getInstance();
      a.setTime(d1);
      b.setTime(d2);

      long m = b.getTimeInMillis() - a.getTimeInMillis();

      tiempo.setText(m + " ms");
      ProbAntenasBoard pf = (ProbAntenasBoard) search.getGoalState();

      drawPanel1.setPlano(tp, pf.getState());
      // pf.printAntenas();
      // pf.printCobertura();
      // List actions=agent.getActions();
      // printActions(agent.getActions());

      printInstrumentation(agent.getInstrumentation());
      instrum.append("Cobertura: " + pf.calculaCobertura() + "\n");
      for (int i = 0; i < nc; i++)
        instrum.append("Antena " + i + ":" + pf.antenaToString(i) + "\n");

    } catch (Exception e) {
      e.printStackTrace();
    }
  } // GEN-LAST:event_ejecutarMousePressed