// SMSEMA_Settings.java // // Authors: // Antonio J. Nebro <antonio@lcc.uma.es> // Juan J. Durillo <durillo@lcc.uma.es> // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. package jmetal.experiments.settings; import java.util.HashMap; import jmetal.metaheuristics.smsemoa.*; import jmetal.operators.crossover.Crossover; import jmetal.operators.crossover.CrossoverFactory; import jmetal.operators.mutation.Mutation; import jmetal.operators.mutation.MutationFactory; import jmetal.operators.selection.Selection; import jmetal.operators.selection.SelectionFactory; import jmetal.problems.ProblemFactory; import jmetal.core.*; import jmetal.experiments.Settings; import jmetal.qualityIndicator.QualityIndicator; import jmetal.util.JMException; /** * Settings class of algorithm SMSEMOA */ public class SMSEMOA_Settings extends Settings { public int populationSize_ ; public int maxEvaluations_ ; public double mutationProbability_ ; public double crossoverProbability_ ; public double crossoverDistributionIndex_ ; public double mutationDistributionIndex_ ; public double offset_ ; /** * Constructor * @throws JMException */ public SMSEMOA_Settings(String problem) throws JMException { super(problem) ; Object [] problemParams = {"Real"}; try { problem_ = (new ProblemFactory()).getProblem(problemName_, problemParams); } catch (JMException e) { // TODO Auto-generated catch block e.printStackTrace(); } populationSize_ = 100 ; maxEvaluations_ = 25000 ; mutationProbability_ = 1.0/problem_.getNumberOfVariables() ; crossoverProbability_ = 0.9 ; crossoverDistributionIndex_ = 20.0 ; mutationDistributionIndex_ = 20.0 ; offset_ = 100.0 ; } // SMSEMOA_Settings /** * Configure NSGAII with user-defined parameter settings * @return A NSGAII algorithm object * @throws jmetal.util.JMException */ public Algorithm configure() throws JMException { Algorithm algorithm ; Selection selection ; Crossover crossover ; Mutation mutation ; QualityIndicator indicators ; HashMap parameters ; // Operator parameters // Creating the algorithm. algorithm = new SMSEMOA(problem_) ; // Algorithm parameters algorithm.setInputParameter("populationSize",populationSize_); algorithm.setInputParameter("maxEvaluations",maxEvaluations_); algorithm.setInputParameter("offset", offset_); // Mutation and Crossover for Real codification parameters = new HashMap() ; parameters.put("probability", crossoverProbability_) ; parameters.put("distributionIndex", crossoverDistributionIndex_) ; crossover = CrossoverFactory.getCrossoverOperator("SBXCrossover", parameters); parameters = new HashMap() ; parameters.put("probability", mutationProbability_) ; parameters.put("distributionIndex", mutationDistributionIndex_) ; mutation = MutationFactory.getMutationOperator("PolynomialMutation", parameters); // Selection Operator parameters = null ; selection = SelectionFactory.getSelectionOperator("RandomSelection", parameters); // Add the operators to the algorithm algorithm.addOperator("crossover",crossover); algorithm.addOperator("mutation",mutation); algorithm.addOperator("selection",selection); // Creating the indicator object if ((paretoFrontFile_!=null) && (!paretoFrontFile_.equals(""))) { indicators = new QualityIndicator(problem_, paretoFrontFile_); algorithm.setInputParameter("indicators", indicators) ; } // if return algorithm ; } // configure } // SMSEMOA_Settings