Esempio n. 1
0
  /**
   * Creates a new instance of problem CEC2009_UF8.
   *
   * @param numberOfVariables Number of variables.
   * @param solutionType The solution type must "Real" or "BinaryReal".
   */
  public CEC2009_UF8(String solutionType, Integer numberOfVariables) throws ClassNotFoundException {
    numberOfVariables_ = numberOfVariables.intValue();
    numberOfObjectives_ = 3;
    numberOfConstraints_ = 0;
    problemName_ = "CEC2009_UF8";

    upperLimit_ = new double[numberOfVariables_];
    lowerLimit_ = new double[numberOfVariables_];

    lowerLimit_[0] = 0.0;
    upperLimit_[0] = 1.0;
    lowerLimit_[1] = 0.0;
    upperLimit_[1] = 1.0;
    for (int var = 2; var < numberOfVariables_; var++) {
      lowerLimit_[var] = -2.0;
      upperLimit_[var] = 2.0;
    } // for

    if (solutionType.compareTo("BinaryReal") == 0) solutionType_ = new BinaryRealSolutionType(this);
    else if (solutionType.compareTo("Real") == 0) solutionType_ = new RealSolutionType(this);
    else {
      System.out.println("Error: solution type " + solutionType + " invalid");
      System.exit(-1);
    }
  } // CEC2009_UF7
Esempio n. 2
0
  // Ouvre un fichier de sortie pour ecrire les reponses
  public PrintStream fichierSortie() {
    PrintStream result = System.out;

    String nom = this.readarg.lireString("Nom du fichier de sortie ? ");

    if ("".equals(nom)) {
      nom = "/dev/null";
    }

    try {
      result = new PrintStream(nom);
    } catch (Exception e) {
      System.err.println("Erreur a l'ouverture du fichier " + nom);
      System.exit(1);
    }

    return result;
  }
Esempio n. 3
0
  public void go() {

    try {
      System.out.println("**");
      System.out.println("** Programme de test des algorithmes de graphe.");
      System.out.println("**");
      System.out.println();

      // On obtient ici le nom de la carte a utiliser.
      String nomcarte = this.readarg.lireString("Nom du fichier .map a utiliser ? ");
      DataInputStream mapdata = Openfile.open(nomcarte);

      boolean display =
          (1 == this.readarg.lireInt("Voulez-vous une sortie graphique (0 = non, 1 = oui) ? "));
      Dessin dessin = (display) ? new DessinVisible(800, 600) : new DessinInvisible();

      Graphe graphe = new Graphe(nomcarte, mapdata, dessin);

      // Boucle principale : le menu est accessible
      // jusqu'a ce que l'on quitte.
      boolean continuer = true;
      int choix;

      while (continuer) {
        this.afficherMenu();
        choix = this.readarg.lireInt("Votre choix ? ");

        // Algorithme a executer
        Algo algo = null;

        // Le choix correspond au numero du menu.
        switch (choix) {
          case 0:
            continuer = false;
            break;

          case 1:
            algo = new Connexite(graphe, this.fichierSortie(), this.readarg);
            break;

          case 2:
            algo = new Pcc(graphe, this.fichierSortie(), this.readarg);
            break;

          case 3:
            algo = new PccStar(graphe, this.fichierSortie(), this.readarg);
            break;

          case 4:
            algo = new Esclave(graphe, System.out, this.readarg);
            continuer = false;
            break;

          case 5:
            graphe.situerClick();
            break;

          case 6:
            String nom_chemin =
                this.readarg.lireString("Nom du fichier .path contenant le chemin ? ");
            graphe.verifierChemin(Openfile.open(nom_chemin), nom_chemin);
            break;

          default:
            System.out.println("Choix de menu incorrect : " + choix);
            System.exit(1);
        }

        if (algo != null) {
          algo.run();
        }
      }

      System.out.println("Programme termine.");
      System.exit(0);

    } catch (Throwable t) {
      t.printStackTrace();
      System.exit(1);
    }
  }