org.uma.jmetal.runner.multiobjective.WASFGARunner Maven / Gradle / Ivy
package org.uma.jmetal.runner.multiobjective;
import org.uma.jmetal.algorithm.Algorithm;
import org.uma.jmetal.algorithm.multiobjective.wasfga.WASFGA;
import org.uma.jmetal.operator.CrossoverOperator;
import org.uma.jmetal.operator.MutationOperator;
import org.uma.jmetal.operator.SelectionOperator;
import org.uma.jmetal.operator.impl.crossover.PMXCrossover;
import org.uma.jmetal.operator.impl.mutation.PermutationSwapMutation;
import org.uma.jmetal.operator.impl.selection.BinaryTournamentSelection;
import org.uma.jmetal.problem.PermutationProblem;
import org.uma.jmetal.problem.multiobjective.MultiobjectiveTSP;
import org.uma.jmetal.solution.PermutationSolution;
import org.uma.jmetal.util.AbstractAlgorithmRunner;
import org.uma.jmetal.util.AlgorithmRunner;
import org.uma.jmetal.util.JMetalException;
import org.uma.jmetal.util.JMetalLogger;
import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator;
import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class WASFGARunner extends AbstractAlgorithmRunner {
/**
* @param args Command line arguments.
* @throws JMetalException
* @throws FileNotFoundException
* Invoking command:
java org.uma.jmetal.runner.multiobjective.WASFGABinaryRunner problemName [referenceFront]
*/
public static void main(String[] args) throws JMetalException, IOException {
/*Problem problem;
PermutationProblem> problem;
Algorithm> algorithm;
CrossoverOperator crossover;
MutationOperator mutation;
SelectionOperator, DoubleSolution> selection;*/
Algorithm>> algorithm;
PermutationProblem> problem;
CrossoverOperator> crossover;
MutationOperator> mutation;
SelectionOperator>, PermutationSolution> selection;
problem = new MultiobjectiveTSP("/tspInstances/kroA100.tsp", "/tspInstances/kroB100.tsp");
crossover = new PMXCrossover(0.9) ;
double mutationProbability = 0.2 ;
mutation = new PermutationSwapMutation(mutationProbability) ;
selection = new BinaryTournamentSelection>(new RankingAndCrowdingDistanceComparator>());
String referenceParetoFront = "" ;
List referencePoint = null;
//problem = ProblemUtils. loadProblem(problemName);
problem = new MultiobjectiveTSP("/tspInstances/kroA100.tsp", "/tspInstances/kroB100.tsp");
referencePoint = new ArrayList<>();
referencePoint.add(0.0);
referencePoint.add(0.0);
/*
double crossoverProbability = 0.9 ;
double crossoverDistributionIndex = 20.0 ;
crossover = new SBXCrossover(crossoverProbability, crossoverDistributionIndex) ;
double mutationProbability = 1.0 / problem.getNumberOfVariables() ;
double mutationDistributionIndex = 20.0 ;
mutation = new PolynomialMutation(mutationProbability, mutationDistributionIndex) ;
selection = new BinaryTournamentSelection(new RankingAndCrowdingDistanceComparator());*/
double epsilon = 0.01 ;
algorithm = new WASFGA>(problem, 100, 250, crossover, mutation, selection,
new SequentialSolutionListEvaluator>(),epsilon, referencePoint) ;
AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
.execute() ;
List> population = algorithm.getResult() ;
long computingTime = algorithmRunner.getComputingTime() ;
JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
printFinalSolutionSet(population);
if (!referenceParetoFront.equals("")) {
printQualityIndicators(population, referenceParetoFront) ;
}
}
}