/**
   * Configures the algorithms in each independent run
   *
   * @param problem The problem to solve
   * @param problemIndex
   */
  public synchronized void algorithmSettings(
      Problem problem, int problemIndex, Algorithm[] algorithm) {
    try {
      int numberOfAlgorithms = algorithmNameList_.length;

      Properties[] parameters = new Properties[numberOfAlgorithms];
      // Settings[] configuration = new Settings[algorithmName_.length];

      for (int i = 0; i < numberOfAlgorithms; i++) {
        parameters[i] = new Properties();
        parameters[i].setProperty("POPULATION_SIZE", "100");
        //        parameters[i].setProperty("MAX_EVALUATIONS", "500");
        parameters[i].setProperty("MAX_EVALUATIONS", "500000");
        //        parameters[i].setProperty("MAX_EVALUATIONS", "1000000");
        parameters[i].setProperty("ARCHIVE_SIZE", "100");
        parameters[i].setProperty("FEEDBACK", "20");
        parameters[i].setProperty("SPECIAL_SOLUTION", "OneMinmin");

        parameters[i].setProperty("SELECTION", "BinaryTournament");
        //        parameters[i].setProperty("SELECTION", "TournamentFour");

        parameters[i].setProperty("RECOMBINATION", "DPX");
        //        parameters[i].setProperty("RECOMBINATION", "UniformCrossover");
        parameters[i].setProperty("CROSSOVER_PROBABILITY", "0.9");

        parameters[i].setProperty("MUTATION", "RebalanceMutation");
        parameters[i].setProperty("MUTATION_ROUNDS", "1"); // Estaba a 16  !!!!!!!!!!!!
        parameters[i].setProperty("MUTATION_OVERLOAD_PERCENTAGE", "0.25");
        // parameters[i].setProperty("MUTATION_POLICY", "moderate");
        parameters[i].setProperty("MUTATION_POLICY", "simple");
        // parameters[i].setProperty("MUTATION_MODE", "strict");
        parameters[i].setProperty("MUTATION_MODE", "permissive");
        parameters[i].setProperty(
            "MUTATION_PROBABILITY", new Double(1.0 / problem.getNumberOfVariables()).toString());

        parameters[i].setProperty("LOCAL_SEARCH", "LMCTSLocalSearch");
      }

      if ((paretoFrontFile_ != null) && !paretoFrontFile_[problemIndex].equals("")) {
        for (int i = 0; i < numberOfAlgorithms; i++)
          parameters[i].setProperty("PARETO_FRONT_FILE", paretoFrontFile_[problemIndex]);
      } // if

      // for (int i = 0; i < numberOfAlgorithms; i++)
      //  algorithm[i] = new NSGAII_Settings(problem).configure(parameters[i]);

      //      algorithm[0] = new MOCell_Settings_CEC10(problem).configure(parameters[0]);
      //      algorithm[0] = new NSGAII_Settings_CEC10(problem).configure(parameters[0]);
      algorithm[0] = new IBEA_Settings_CEC10(problem).configure(parameters[0]);
      //      algorithm[3] = new MOEAD_Settings_CEC10(problem).configure(parameters[3]);

    } catch (JMException ex) {
      Logger.getLogger(NSGAIIStudy.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Example #2
0
  /**
   * @param args Command line arguments. The first (optional) argument specifies the problem to
   *     solve.
   * @throws JMException
   * @throws IOException
   * @throws SecurityException Usage: three options - jmetal.metaheuristics.mocell.MOCell_main -
   *     jmetal.metaheuristics.mocell.MOCell_main problemName -
   *     jmetal.metaheuristics.mocell.MOCell_main problemName ParetoFrontFile
   */
  public static void main(String[] args) throws JMException, IOException, ClassNotFoundException {
    Problem problem; // The problem to solve
    Algorithm algorithm; // The algorithm to use
    Operator mutation; // Mutation operator

    QualityIndicator indicators; // Object to get quality indicators

    // Logger object and file to store log messages
    logger_ = Configuration.logger_;
    fileHandler_ = new FileHandler("PAES_main.log");
    logger_.addHandler(fileHandler_);

    indicators = null;
    if (args.length == 1) {
      Object[] params = {"Real"};
      problem = (new ProblemFactory()).getProblem(args[0], params);
    } // if
    else if (args.length == 2) {
      Object[] params = {"Real"};
      problem = (new ProblemFactory()).getProblem(args[0], params);
      indicators = new QualityIndicator(problem, args[1]);
    } // if
    else { // Default problem
      problem = new Kursawe("ArrayReal", 3);
      // problem = new Fonseca("Real");
      // problem = new Kursawe("BinaryReal",3);
      // problem = new Water("Real");
      // problem = new ZDT4("Real", 1000);
      // problem = new WFG1("Real");
      // problem = new DTLZ1("Real");
      // problem = new OKA2("Real") ;
    } // else

    algorithm = new PAES(problem);

    // Algorithm parameters
    algorithm.setInputParameter("archiveSize", 100);
    algorithm.setInputParameter("biSections", 5);
    algorithm.setInputParameter("maxEvaluations", 25000);

    // Mutation (Real variables)
    mutation = MutationFactory.getMutationOperator("PolynomialMutation");
    mutation.setParameter("probability", 1.0 / problem.getNumberOfVariables());
    mutation.setParameter("distributionIndex", 20.0);

    // Mutation (BinaryReal variables)
    // mutation = MutationFactory.getMutationOperator("BitFlipMutation");
    // mutation.setParameter("probability",0.1);

    // Add the operators to the algorithm
    algorithm.addOperator("mutation", mutation);

    // Execute the Algorithm
    long initTime = System.currentTimeMillis();
    SolutionSet population = algorithm.execute();
    long estimatedTime = System.currentTimeMillis() - initTime;

    // Result messages
    // STEP 8. Print the results
    logger_.info("Total execution time: " + estimatedTime + "ms");
    logger_.info("Variables values have been writen to file VAR");
    population.printVariablesToFile("VAR");
    logger_.info("Objectives values have been writen to file FUN");
    population.printObjectivesToFile("FUN");

    if (indicators != null) {
      logger_.info("Quality indicators");
      logger_.info("Hypervolume: " + indicators.getHypervolume(population));
      logger_.info("GD         : " + indicators.getGD(population));
      logger_.info("IGD        : " + indicators.getIGD(population));
      logger_.info("Spread     : " + indicators.getSpread(population));
      logger_.info("Epsilon    : " + indicators.getEpsilon(population));
    } // if
  } // main
Example #3
0
  /**
   * Configure method. Change the default configuration
   *
   * @param settings
   * @return A problem with the settings indicated as argument
   * @throws jmetal.util.JMException
   * @throws ClassNotFoundException
   */
  public final Algorithm configure(Properties settings)
      throws JMException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {

    if (settings != null) {

      Field[] fields = this.getClass().getFields();

      for (int i = 0; i < fields.length; i++) {
        if (fields[i].getName().endsWith("_")) { // it is a configuration field
          // The configuration field is an integer
          if (fields[i].getType().equals(int.class) || fields[i].getType().equals(Integer.class)) {

            int value =
                Integer.parseInt(
                    settings.getProperty(fields[i].getName(), "" + fields[i].getInt(this)));

            fields[i].setInt(this, value);
          } else if (fields[i].getType().equals(double.class)
              || fields[i].getType().equals(Double.class)) {
            // The configuration field is a double
            double value =
                Double.parseDouble(
                    settings.getProperty(fields[i].getName(), "" + fields[i].getDouble(this)));

            if (fields[i].getName().equals("mutationProbability_") && value == 0) {
              if ((problem_.getSolutionType().getClass()
                      == Class.forName("jmetal.base.solutionType.RealSolutionType"))
                  || (problem_.getSolutionType().getClass()
                      == Class.forName("jmetal.base.solutionType.ArrayRealSolutionType"))) {
                value = 1.0 / problem_.getNumberOfVariables();
              } else if (problem_.getSolutionType().getClass()
                      == Class.forName("jmetal.base.solutionType.BinarySolutionType")
                  || problem_.getSolutionType().getClass()
                      == Class.forName("jmetal.base.solutionType.BinaryRealSolutionType")) {
                int length = problem_.getNumberOfBits();

                value = 1.0 / length;
                System.out.println("La probabilidad es : " + value);
              } else {
                int length = 0;
                for (int j = 0; j < problem_.getNumberOfVariables(); j++) {
                  length += problem_.getLength(j);
                }
                value = 1.0 / length;
              }
              fields[i].setDouble(this, value);
            } // if
            else {
              fields[i].setDouble(this, value);
            }
          } else {
            Object value = settings.getProperty(fields[i].getName(), null);

            if (value != null) {
              if (fields[i].getType().equals(jmetal.base.operator.crossover.Crossover.class)) {
                Object value2 = CrossoverFactory.getCrossoverOperator((String) value, settings);
                value = value2;
              }

              if (fields[i].getType().equals(jmetal.base.operator.mutation.Mutation.class)) {
                Object value2 = MutationFactory.getMutationOperator((String) value, settings);
                value = value2;
              }

              fields[i].set(this, value);
            }
          }
        }
      } // for

      // At this point all the fields have been read from the properties
      // parameter. Those fields representing crossover and mutations should also
      // be initialized. However, there is still mandatory to configure them
      for (int i = 0; i < fields.length; i++) {
        if (fields[i].getType().equals(jmetal.base.operator.crossover.Crossover.class)
            || fields[i].getType().equals(jmetal.base.operator.mutation.Mutation.class)) {
          Operator operator = (Operator) fields[i].get(this);
          // This field stores a crossover operator
          String tmp = fields[i].getName();
          String aux = fields[i].getName().substring(0, tmp.length() - 1);

          for (int j = 0; j < fields.length; j++) {
            if (i != j) {
              if (fields[j].getName().startsWith(aux)) {
                // The field is a configuration parameter of the crossover
                tmp = fields[j].getName().substring(aux.length(), fields[j].getName().length() - 1);

                if ((fields[j].get(this) != null)) {
                  System.out.println(fields[j].getName());
                  if (fields[j].getType().equals(int.class)
                      || fields[j].getType().equals(Integer.class)) {
                    operator.setParameter(tmp, fields[j].getInt(this));
                  } else if (fields[j].getType().equals(double.class)
                      || fields[j].getType().equals(Double.class)) {
                    operator.setParameter(tmp, fields[j].getDouble(this));
                  }
                }
              }
            }
          }
        }
      }
      // At this point, we should compare if the pareto front have been added
      paretoFrontFile_ = settings.getProperty("paretoFrontFile_", "");
    }

    return configure();
  } // configure
Example #4
0
  /**
   * @param args Command line arguments.
   * @throws JMException
   * @throws IOException
   * @throws SecurityException Usage: three choices - jmetal.metaheuristics.nsgaII.NSGAII_main -
   *     jmetal.metaheuristics.nsgaII.NSGAII_main problemName -
   *     jmetal.metaheuristics.nsgaII.NSGAII_main problemName paretoFrontFile
   */
  public static void main(String[] args) throws JMException, IOException, ClassNotFoundException {
    Problem problem; // The problem to solve
    Algorithm algorithm; // The algorithm to use
    Operator crossover; // Crossover operator
    Operator mutation; // Mutation operator
    Operator selection; // Selection operator

    QualityIndicator indicators; // Object to get quality indicators

    // Logger object and file to store log messages
    logger_ = Configuration.logger_;
    fileHandler_ = new FileHandler("IBEA.log");
    logger_.addHandler(fileHandler_);

    indicators = null;
    if (args.length == 1) {
      Object[] params = {"Real"};
      problem = (new ProblemFactory()).getProblem(args[0], params);
    } // if
    else if (args.length == 2) {
      Object[] params = {"Real"};
      problem = (new ProblemFactory()).getProblem(args[0], params);
      indicators = new QualityIndicator(problem, args[1]);
    } // if
    else { // Default problem
      problem = new Kursawe("Real", 3);
      // problem = new Kursawe("BinaryReal", 3);
      // problem = new Water("Real");
      // problem = new ZDT1("ArrayReal", 100);
      // problem = new ConstrEx("Real");
      // problem = new DTLZ1("Real");
      // problem = new OKA2("Real") ;
    } // else

    algorithm = new IBEA(problem);

    // Algorithm parameters
    algorithm.setInputParameter("populationSize", 100);
    algorithm.setInputParameter("archiveSize", 100);
    algorithm.setInputParameter("maxEvaluations", 25000);

    // Mutation and Crossover for Real codification
    crossover = CrossoverFactory.getCrossoverOperator("SBXCrossover");
    crossover.setParameter("probability", 1.0);
    crossover.setParameter("distribuitionIndex", 20.0);
    mutation = MutationFactory.getMutationOperator("PolynomialMutation");
    mutation.setParameter("probability", 1.0 / problem.getNumberOfVariables());
    mutation.setParameter("distributionIndex", 20.0);

    /* Mutation and Crossover Binary codification */
    /*
    crossover = CrossoverFactory.getCrossoverOperator("SinglePointCrossover");
    crossover.setParameter("probability",0.9);
    mutation = MutationFactory.getMutationOperator("BitFlipMutation");
    mutation.setParameter("probability",1.0/80);
    */

    /* Selection Operator */
    selection = new BinaryTournament(new FitnessComparator());
    // Add the operators to the algorithm
    algorithm.addOperator("crossover", crossover);
    algorithm.addOperator("mutation", mutation);
    algorithm.addOperator("selection", selection);

    // Execute the Algorithm
    long initTime = System.currentTimeMillis();
    SolutionSet population = algorithm.execute();
    long estimatedTime = System.currentTimeMillis() - initTime;

    // Print the results
    logger_.info("Total execution time: " + estimatedTime + "ms");
    logger_.info("Variables values have been writen to file VAR");
    population.printVariablesToFile("VAR");
    logger_.info("Objectives values have been writen to file FUN");
    population.printObjectivesToFile("FUN");

    if (indicators != null) {
      logger_.info("Quality indicators");
      logger_.info("Hypervolume: " + indicators.getHypervolume(population));
      logger_.info("GD         : " + indicators.getGD(population));
      logger_.info("IGD        : " + indicators.getIGD(population));
      logger_.info("Spread     : " + indicators.getSpread(population));
      logger_.info("Epsilon    : " + indicators.getEpsilon(population));
    } // if
  } // main