当前位置: 首页>>代码示例>>Java>>正文


Java AlgorithmRunner.getComputingTime方法代码示例

本文整理汇总了Java中org.uma.jmetal.util.AlgorithmRunner.getComputingTime方法的典型用法代码示例。如果您正苦于以下问题:Java AlgorithmRunner.getComputingTime方法的具体用法?Java AlgorithmRunner.getComputingTime怎么用?Java AlgorithmRunner.getComputingTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.uma.jmetal.util.AlgorithmRunner的用法示例。


在下文中一共展示了AlgorithmRunner.getComputingTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * @param args Command line arguments.
 * @throws JMetalException
 * @throws FileNotFoundException
 * Invoking command:
java org.uma.jmetal.runner.multiobjective.AbYSSRunner problemName [referenceFront]
 */
public static void main(String[] args) throws Exception {
  DoubleProblem problem;
  Algorithm<List<DoubleSolution>> algorithm;
  String problemName ;

  String referenceParetoFront = "" ;
  if (args.length == 1) {
    problemName = args[0];
  } else if (args.length == 2) {
    problemName = args[0] ;
    referenceParetoFront = args[1] ;
  } else {
    problemName = "org.uma.jmetal.problem.multiobjective.zdt.ZDT1";
    referenceParetoFront = "jmetal-problem/src/test/resources/pareto_fronts/ZDT1.pf" ;
  }

  problem = (DoubleProblem) ProblemUtils.<DoubleSolution> loadProblem(problemName);

  Archive<DoubleSolution> archive = new CrowdingDistanceArchive<DoubleSolution>(100) ;

  algorithm = new ABYSSBuilder(problem, archive)
      .setMaxEvaluations(25000)
      .build();

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute();

  List<DoubleSolution> population = algorithm.getResult();
  long computingTime = algorithmRunner.getComputingTime();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

  printFinalSolutionSet(population);
  if (!referenceParetoFront.equals("")) {
    printQualityIndicators(population, referenceParetoFront) ;
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:45,代码来源:ABYSSRunner.java

示例2: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 */
public static void main(String[] args) throws Exception {

  Algorithm<DoubleSolution> algorithm;
  DoubleProblem problem = new Sphere() ;

  algorithm = new CovarianceMatrixAdaptationEvolutionStrategy.Builder(problem)
          .build() ;


  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
          .execute() ;

  DoubleSolution solution = algorithm.getResult() ;
  List<DoubleSolution> population = new ArrayList<>(1) ;
  population.add(solution) ;

  long computingTime = algorithmRunner.getComputingTime() ;

  new SolutionListOutput(population)
          .setSeparator("\t")
          .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
          .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
          .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");

}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:32,代码来源:CovarianceMatrixAdaptationEvolutionStrategyRunner.java

示例3: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * @param args Command line arguments.
 * @throws org.uma.jmetal.util.JMetalException
 * @throws java.io.IOException
 * @throws SecurityException
 * Invoking command:
java org.uma.jmetal.runner.multiobjective.DMOPSORunner problemName [referenceFront]
 */
public static void main(String[] args) throws Exception {
  DoubleProblem problem;
  Algorithm<List<DoubleSolution>> algorithm;

  String referenceParetoFront = "" ;

  String problemName ;
  if (args.length == 1) {
    problemName = args[0];
  } else if (args.length == 2) {
    problemName = args[0] ;
    referenceParetoFront = args[1] ;
  } else {
    problemName = "org.uma.jmetal.problem.multiobjective.zdt.ZDT1";
    referenceParetoFront = "../jmetal-problem/src/test/resources/pareto_fronts/ZDT1.pf" ;
  }

  problem = (DoubleProblem) ProblemUtils.<DoubleSolution> loadProblem(problemName);

  algorithm = new DMOPSO(problem, 100, 250, 0.0, 0.1, 0.0, 1.0, 1.5, 2.5, 1.5, 2.5, 0.1, 0.4, -1.0, -1.0,
          FunctionType.TCHE, "MOEAD_Weights", 2) ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute();

  List<DoubleSolution> population = algorithm.getResult();
  long computingTime = algorithmRunner.getComputingTime();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

  printFinalSolutionSet(population);
  if (!referenceParetoFront.equals("")) {
    printQualityIndicators(population, referenceParetoFront) ;
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:44,代码来源:DMOPSORunner.java

示例4: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * Usage: java org.uma.jmetal.runner.singleobjective.ElitistEvolutionStrategyRunner
 */
public static void main(String[] args) throws Exception {
  Algorithm<BinarySolution> algorithm;
  BinaryProblem problem = new OneMax(512) ;

  MutationOperator<BinarySolution> mutationOperator =
      new BitFlipMutation(1.0 / problem.getNumberOfBits(0)) ;

  algorithm = new EvolutionStrategyBuilder<BinarySolution>(problem, mutationOperator,
      EvolutionStrategyBuilder.EvolutionStrategyVariant.ELITIST)
      .setMaxEvaluations(25000)
      .setMu(1)
      .setLambda(10)
      .build() ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute() ;

  BinarySolution solution = algorithm.getResult() ;
  List<BinarySolution> population = new ArrayList<>(1) ;
  population.add(solution) ;

  long computingTime = algorithmRunner.getComputingTime() ;

  new SolutionListOutput(population)
      .setSeparator("\t")
      .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
      .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
      .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:37,代码来源:ElitistEvolutionStrategyRunner.java

示例5: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * Usage: java
 * org.uma.jmetal.runner.singleobjective.CoralReefsOptimizationRunner
 */
public static void main(String[] args) throws Exception {
	Algorithm<List<BinarySolution>> algorithm;
	BinaryProblem problem = new OneMax(512);

	CrossoverOperator<BinarySolution> crossoverOperator = new SinglePointCrossover(
			0.9);
	MutationOperator<BinarySolution> mutationOperator = new BitFlipMutation(
			1.0 / problem.getNumberOfBits(0));
	SelectionOperator<List<BinarySolution>, BinarySolution> selectionOperator = new BinaryTournamentSelection<BinarySolution>();

	algorithm = new CoralReefsOptimizationBuilder<BinarySolution>(problem,
			selectionOperator, crossoverOperator, mutationOperator)
			.setM(10).setN(10).setRho(0.6).setFbs(0.9).setFbr(0.1)
			.setFa(0.1).setPd(0.1).setAttemptsToSettle(3)
			.setComparator(new ObjectiveComparator<BinarySolution>(0))
			.build();

	AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(
			algorithm).execute();

	List<BinarySolution> population = algorithm.getResult();
	
	long computingTime = algorithmRunner.getComputingTime();

	new SolutionListOutput(population)
			.setSeparator("\t")
			.setVarFileOutputContext(
					new DefaultFileOutputContext("VAR.tsv"))
			.setFunFileOutputContext(
					new DefaultFileOutputContext("FUN.tsv")).print();

	JMetalLogger.logger.info("Total execution time: " + computingTime
			+ "ms");
	JMetalLogger.logger
			.info("Objectives values have been written to file FUN.tsv");
	JMetalLogger.logger
			.info("Variables values have been written to file VAR.tsv");

}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:44,代码来源:CoralReefsOptimizationRunner.java

示例6: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * Usage: java org.uma.jmetal.runner.singleobjective.SteadyStateGeneticAlgorithmRunner
 */
public static void main(String[] args) throws Exception {
  Algorithm<DoubleSolution> algorithm;
  DoubleProblem problem = new Sphere(20) ;

  CrossoverOperator<DoubleSolution> crossoverOperator =
      new SBXCrossover(0.9, 20.0) ;
  MutationOperator<DoubleSolution> mutationOperator =
      new PolynomialMutation(1.0 / problem.getNumberOfVariables(), 20.0) ;
  SelectionOperator<List<DoubleSolution>, DoubleSolution> selectionOperator = new BinaryTournamentSelection<DoubleSolution>() ;

  algorithm = new GeneticAlgorithmBuilder<DoubleSolution>(problem, crossoverOperator, mutationOperator)
      .setPopulationSize(100)
      .setMaxEvaluations(25000)
      .setSelectionOperator(selectionOperator)
      .setVariant(GeneticAlgorithmBuilder.GeneticAlgorithmVariant.STEADY_STATE)
      .build() ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute() ;

  long computingTime = algorithmRunner.getComputingTime() ;

  DoubleSolution solution = algorithm.getResult() ;
  List<DoubleSolution> population = new ArrayList<>(1) ;
  population.add(solution) ;

  new SolutionListOutput(population)
      .setSeparator("\t")
      .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
      .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
      .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");

  JMetalLogger.logger.info("Fitness: " + solution.getObjective(0)) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:42,代码来源:SteadyStateGeneticAlgorithmRunner.java

示例7: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  CrossoverOperator<BinarySolution> crossoverOperator;
  MutationOperator<BinarySolution> mutationOperator;
  SelectionOperator<List<BinarySolution>, BinarySolution> parentsSelection;
  SelectionOperator<List<BinarySolution>, List<BinarySolution>> newGenerationSelection;
  Algorithm<List<BinarySolution>> algorithm ;

  BinaryProblem problem ;

  String problemName ;
  if (args.length == 1) {
    problemName = args[0] ;
  } else {
    problemName = "org.uma.jmetal.problem.multiobjective.zdt.ZDT5";
  }

  problem = (BinaryProblem) ProblemUtils.<BinarySolution> loadProblem(problemName);

  crossoverOperator = new HUXCrossover(1.0) ;
  parentsSelection = new RandomSelection<BinarySolution>() ;
  newGenerationSelection = new RankingAndCrowdingSelection<BinarySolution>(100) ;
  mutationOperator = new BitFlipMutation(0.35) ;

  algorithm = new MOCHC45(problem, 100, 25000, 3, 0.05, 0.25, crossoverOperator, mutationOperator,
      newGenerationSelection, parentsSelection, new SequentialSolutionListEvaluator<BinarySolution>()) ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute() ;

  List<BinarySolution> population = (algorithm).getResult() ;
  long computingTime = algorithmRunner.getComputingTime() ;

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

  printFinalSolutionSet(population);
  //if (!referenceParetoFront.equals("")) {
  //  printQualityIndicators(population, referenceParetoFront) ;
  //}
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:40,代码来源:MOCHC45Runner.java

示例8: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
   * @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<DoubleSolution> problem;
    PermutationProblem<PermutationSolution<Integer>> problem;
    Algorithm<List<DoubleSolution>> algorithm;
    CrossoverOperator<DoubleSolution> crossover;
    MutationOperator<DoubleSolution> mutation;
    SelectionOperator<List<DoubleSolution>, DoubleSolution> selection;*/
    Algorithm<List<PermutationSolution<Integer>>> algorithm;
    PermutationProblem<PermutationSolution<Integer>> problem;
    CrossoverOperator<PermutationSolution<Integer>> crossover;
    MutationOperator<PermutationSolution<Integer>> mutation;
    SelectionOperator<List<PermutationSolution<Integer>>, PermutationSolution<Integer>> selection;

    problem = new MultiobjectiveTSP("/tspInstances/kroA100.tsp", "/tspInstances/kroB100.tsp");

    crossover = new PMXCrossover(0.9) ;

    double mutationProbability = 0.2 ;
    mutation = new PermutationSwapMutation<Integer>(mutationProbability) ;

    selection = new BinaryTournamentSelection<PermutationSolution<Integer>>(new RankingAndCrowdingDistanceComparator<PermutationSolution<Integer>>());
    String referenceParetoFront = "" ;
    List<Double> referencePoint = null;

    /*String problemName ;
    if (args.length == 1) {
      problemName = args[0];
    } else if (args.length == 2) {
      problemName = args[0] ;
      referenceParetoFront = args[1] ;
    } else {
      problemName = "org.uma.jmetal.problem.multiobjective.zdt.ZDT4";
      referenceParetoFront = "jmetal-problem/src/test/resources/pareto_fronts/ZDT4.pf" ;
    }*/

    //problem = ProblemUtils.<DoubleSolution> 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<DoubleSolution>(new RankingAndCrowdingDistanceComparator<DoubleSolution>());*/

    algorithm = new WASFGA<PermutationSolution<Integer>>(problem, 100, 250, crossover, mutation, selection,new SequentialSolutionListEvaluator<PermutationSolution<Integer>>(),referencePoint) ;

    AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
            .execute() ;

    List<PermutationSolution<Integer>> population = algorithm.getResult() ;
    long computingTime = algorithmRunner.getComputingTime() ;

    JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

    printFinalSolutionSet(population);
    if (!referenceParetoFront.equals("")) {
      printQualityIndicators(population, referenceParetoFront) ;
    }
  }
 
开发者ID:jMetal,项目名称:jMetal,代码行数:75,代码来源:WASFGARunner.java

示例9: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 *  Usage: java org.uma.jmetal.runner.singleobjective.StandardPSO2007Runner [cores]
 */
public static void main(String[] args) throws Exception {

  DoubleProblem problem;
  Algorithm<DoubleSolution> algorithm;
  SolutionListEvaluator<DoubleSolution> evaluator ;

  String problemName = "org.uma.jmetal.problem.singleobjective.Sphere" ;

  problem = (DoubleProblem) ProblemUtils.<DoubleSolution> loadProblem(problemName);

  int numberOfCores ;
  if (args.length == 1) {
    numberOfCores = Integer.valueOf(args[0]) ;
  } else {
    numberOfCores = DEFAULT_NUMBER_OF_CORES ;
  }

  if (numberOfCores == 1) {
    evaluator = new SequentialSolutionListEvaluator<DoubleSolution>() ;
  } else {
    evaluator = new MultithreadedSolutionListEvaluator<DoubleSolution>(numberOfCores, problem) ;
  }

  algorithm = new StandardPSO2007(problem,
          10 + (int) (2 * Math.sqrt(problem.getNumberOfVariables())),
          25000, 3, evaluator) ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute() ;

  DoubleSolution solution = algorithm.getResult() ;
  long computingTime = algorithmRunner.getComputingTime() ;

  List<DoubleSolution> population = new ArrayList<>(1) ;
  population.add(solution) ;
  new SolutionListOutput(population)
      .setSeparator("\t")
      .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
      .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
      .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");

  JMetalLogger.logger.info("Fitness: " + solution.getObjective(0)) ;
  JMetalLogger.logger.info("Solution: " + solution.getVariableValueString(0)) ;
  evaluator.shutdown();
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:53,代码来源:StandardPSO2007Runner.java

示例10: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * @param args Command line arguments.
 * @throws SecurityException
 * Invoking command:
java org.uma.jmetal.runner.multiobjective.NSGAIIMeasuresRunner problemName [referenceFront]
 */
public static void main(String[] args)
        throws JMetalException, InterruptedException, IOException {
  DoubleProblem problem;
  Algorithm<List<DoubleSolution>> algorithm;
  MutationOperator<DoubleSolution> mutation;

  String referenceParetoFront = "" ;

  String problemName ;
  if (args.length == 1) {
    problemName = args[0];
  } else if (args.length == 2) {
    problemName = args[0] ;
    referenceParetoFront = args[1] ;
  } else {
    problemName = "org.uma.jmetal.problem.multiobjective.zdt.ZDT4";
    referenceParetoFront = "jmetal-problem/src/test/resources/pareto_fronts/ZDT4.pf" ;
  }

  problem = (DoubleProblem) ProblemUtils.<DoubleSolution> loadProblem(problemName);

  BoundedArchive<DoubleSolution> archive = new CrowdingDistanceArchive<DoubleSolution>(100) ;

  double mutationProbability = 1.0 / problem.getNumberOfVariables() ;
  double mutationDistributionIndex = 20.0 ;
  mutation = new PolynomialMutation(mutationProbability, mutationDistributionIndex) ;

  int maxIterations = 250 ;
  int swarmSize = 100 ;

  algorithm = new SMPSOBuilder(problem, archive)
      .setMutation(mutation)
      .setMaxIterations(maxIterations)
      .setSwarmSize(swarmSize)
      .setRandomGenerator(new MersenneTwisterGenerator())
      .setSolutionListEvaluator(new SequentialSolutionListEvaluator<DoubleSolution>())
      .setVariant(SMPSOBuilder.SMPSOVariant.Measures)
      .build();

  /* Measure management */
  MeasureManager measureManager = ((SMPSOMeasures)algorithm).getMeasureManager() ;

  BasicMeasure<List<DoubleSolution>> solutionListMeasure = (BasicMeasure<List<DoubleSolution>>) measureManager
          .<List<DoubleSolution>>getPushMeasure("currentPopulation");
  CountingMeasure iterationMeasure = (CountingMeasure) measureManager.<Long>getPushMeasure("currentIteration");

  ChartContainer chart = new ChartContainer(algorithm.getName(), 200);
  chart.setFrontChart(0, 1, referenceParetoFront);
  chart.setVarChart(0, 1);
  chart.initChart();

  solutionListMeasure.register(new ChartListener(chart));
  iterationMeasure.register(new IterationListener(chart));

  /* End of measure management */

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm).execute();
  chart.saveChart("./chart", BitmapEncoder.BitmapFormat.PNG);

  List<DoubleSolution> population = algorithm.getResult();
  long computingTime = algorithmRunner.getComputingTime();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

  printFinalSolutionSet(population);
  if (!referenceParetoFront.equals("")) {
    printQualityIndicators(population, referenceParetoFront);
  }

}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:77,代码来源:SMPSOMeasuresWithChartsRunner.java

示例11: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 *  Usage: java org.uma.jmetal.runner.singleobjective.DifferentialEvolutionRunner [cores]
 */
public static void main(String[] args) throws Exception {

  DoubleProblem problem;
  Algorithm<DoubleSolution> algorithm;
  DifferentialEvolutionSelection selection;
  DifferentialEvolutionCrossover crossover;
  SolutionListEvaluator<DoubleSolution> evaluator ;

  problem = new Sphere(20) ;

  int numberOfCores ;
  if (args.length == 1) {
    numberOfCores = Integer.valueOf(args[0]) ;
  } else {
    numberOfCores = DEFAULT_NUMBER_OF_CORES ;
  }

  if (numberOfCores == 1) {
    evaluator = new SequentialSolutionListEvaluator<DoubleSolution>() ;
  } else {
    evaluator = new MultithreadedSolutionListEvaluator<DoubleSolution>(numberOfCores, problem) ;
  }

  crossover = new DifferentialEvolutionCrossover(0.5, 0.5, "rand/1/bin") ;
  selection = new DifferentialEvolutionSelection();

  algorithm = new DifferentialEvolutionBuilder(problem)
      .setCrossover(crossover)
      .setSelection(selection)
      .setSolutionListEvaluator(evaluator)
      .setMaxEvaluations(25000)
      .setPopulationSize(100)
      .build() ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute() ;

  DoubleSolution solution = algorithm.getResult() ;
  long computingTime = algorithmRunner.getComputingTime() ;

  List<DoubleSolution> population = new ArrayList<>(1) ;
  population.add(solution) ;
  new SolutionListOutput(population)
      .setSeparator("\t")
      .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
      .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
      .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");

  JMetalLogger.logger.info("Fitness: " + solution.getObjective(0)) ;

  evaluator.shutdown();
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:60,代码来源:DifferentialEvolutionRunner.java

示例12: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * @param args Command line arguments.
 * @throws org.uma.jmetal.util.JMetalException
 * @throws java.io.IOException
 * @throws SecurityException
 * @throws ClassNotFoundException
 * Invoking command:
java org.uma.jmetal.runner.multiobjective.NSGAIIIntegerRunner problemName [referenceFront]
 */
public static void main(String[] args) throws FileNotFoundException {
  Problem<IntegerSolution> problem;
  Algorithm<List<IntegerSolution>> algorithm;
  CrossoverOperator<IntegerSolution> crossover;
  MutationOperator<IntegerSolution> mutation;
  SelectionOperator<List<IntegerSolution>, IntegerSolution> selection;
  
  String problemName ;

  String referenceParetoFront = "" ;
  if (args.length == 1) {
    problemName = args[0];
  } else if (args.length == 2) {
    problemName = args[0] ;
    referenceParetoFront = args[1] ;
  } else {
    problemName = "org.uma.jmetal.problem.multiobjective.NMMin" ;
    referenceParetoFront = "";
  }

  problem = ProblemUtils.<IntegerSolution> loadProblem(problemName);

  double crossoverProbability = 0.9 ;
  double crossoverDistributionIndex = 20.0 ;
  crossover = new IntegerSBXCrossover(crossoverProbability, crossoverDistributionIndex) ;

  double mutationProbability = 1.0 / problem.getNumberOfVariables() ;
  double mutationDistributionIndex = 20.0 ;
  mutation = new IntegerPolynomialMutation(mutationProbability, mutationDistributionIndex) ;

  selection = new BinaryTournamentSelection<IntegerSolution>() ;

  algorithm = new NSGAIIBuilder<IntegerSolution>(problem, crossover, mutation)
          .setSelectionOperator(selection)
          .setMaxEvaluations(25000)
          .setPopulationSize(100)
          .build() ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
          .execute() ;

  List<IntegerSolution> population = algorithm.getResult() ;
  long computingTime = algorithmRunner.getComputingTime() ;

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

  printFinalSolutionSet(population);
  if (!referenceParetoFront.equals("")) {
    printQualityIndicators(population, referenceParetoFront) ;
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:61,代码来源:NSGAIIIntegerRunner.java

示例13: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * Usage: java org.uma.jmetal.runner.singleobjective.BinaryGenerationalGeneticAlgorithmRunner
 */
public static void main(String[] args) throws Exception {
  PermutationProblem<PermutationSolution<Integer>> problem;
  Algorithm<PermutationSolution<Integer>> algorithm;
  CrossoverOperator<PermutationSolution<Integer>> crossover;
  MutationOperator<PermutationSolution<Integer>> mutation;
  SelectionOperator<List<PermutationSolution<Integer>>, PermutationSolution<Integer>> selection;

  problem = new TSP("/tspInstances/kroA100.tsp");

  crossover = new PMXCrossover(0.9) ;

  double mutationProbability = 1.0 / problem.getNumberOfVariables() ;
  mutation = new PermutationSwapMutation<Integer>(mutationProbability) ;

  selection = new BinaryTournamentSelection<PermutationSolution<Integer>>(new RankingAndCrowdingDistanceComparator<PermutationSolution<Integer>>());

  algorithm = new GeneticAlgorithmBuilder<>(problem, crossover, mutation)
          .setPopulationSize(100)
          .setMaxEvaluations(250000)
          .setSelectionOperator(selection)
          .build() ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
          .execute() ;

  PermutationSolution<Integer> solution = algorithm.getResult() ;
  List<PermutationSolution<Integer>> population = new ArrayList<>(1) ;
  population.add(solution) ;

  long computingTime = algorithmRunner.getComputingTime() ;

  new SolutionListOutput(population)
          .setSeparator("\t")
          .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
          .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
          .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");

}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:46,代码来源:GenerationalGeneticAlgorithmTSPRunner.java

示例14: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * Usage: java org.uma.jmetal.runner.singleobjective.ParallelGenerationalGeneticAlgorithmRunner [cores]
 */
public static void main(String[] args) throws Exception {
  Algorithm<BinarySolution> algorithm;
  BinaryProblem problem = new OneMax(512) ;

  int numberOfCores ;
  if (args.length == 1) {
    numberOfCores = Integer.valueOf(args[0]) ;
  } else {
    numberOfCores = DEFAULT_NUMBER_OF_CORES ;
  }

  CrossoverOperator<BinarySolution> crossoverOperator = new SinglePointCrossover(0.9) ;
  MutationOperator<BinarySolution> mutationOperator = new BitFlipMutation(1.0 / problem.getNumberOfBits(0)) ;
  SelectionOperator<List<BinarySolution>, BinarySolution> selectionOperator = new BinaryTournamentSelection<BinarySolution>();

  GeneticAlgorithmBuilder<BinarySolution> builder = new GeneticAlgorithmBuilder<BinarySolution>(
      problem, crossoverOperator, mutationOperator)
      .setPopulationSize(100)
      .setMaxEvaluations(25000)
      .setSelectionOperator(selectionOperator)
      .setSolutionListEvaluator(new MultithreadedSolutionListEvaluator<BinarySolution>(numberOfCores, problem)) ;

  algorithm = builder.build() ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
      .execute() ;

  builder.getEvaluator().shutdown();

  BinarySolution solution = algorithm.getResult() ;
  List<BinarySolution> population = new ArrayList<>(1) ;
  population.add(solution) ;

  long computingTime = algorithmRunner.getComputingTime() ;

  new SolutionListOutput(population)
      .setSeparator("\t")
      .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
      .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
      .print();

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");
  JMetalLogger.logger.info("Objectives values have been written to file FUN.tsv");
  JMetalLogger.logger.info("Variables values have been written to file VAR.tsv");
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:49,代码来源:ParallelGenerationalGeneticAlgorithmRunner.java

示例15: main

import org.uma.jmetal.util.AlgorithmRunner; //导入方法依赖的package包/类
/**
 * @param args Command line arguments.
 * @throws JMetalException
 * @throws FileNotFoundException
 * Invoking command:
java org.uma.jmetal.runner.multiobjective.WASFGARunner problemName [referenceFront]
 */
public static void main(String[] args) throws JMetalException, FileNotFoundException {
  BinaryProblem problem;
  Algorithm<List<BinarySolution>> algorithm;
  CrossoverOperator<BinarySolution> crossover;
  MutationOperator<BinarySolution> mutation;
  SelectionOperator<List<BinarySolution>, BinarySolution> selection;
  String referenceParetoFront = "" ;
  List<Double> referencePoint = null;

  String problemName ;
  if (args.length == 1) {
    problemName = args[0];
  } else if (args.length == 2) {
    problemName = args[0] ;
    referenceParetoFront = args[1] ;
  } else {
    problemName = "org.uma.jmetal.problem.multiobjective.zdt.ZDT5";
  }

  problem = (BinaryProblem) ProblemUtils.<BinarySolution> loadProblem(problemName);
  
  referencePoint = new ArrayList<>();
  referencePoint.add(10.0);
  referencePoint.add(4.0);

  double crossoverProbability = 0.9 ;
  crossover = new SinglePointCrossover(crossoverProbability) ;

  double mutationProbability = 1.0 / problem.getNumberOfBits(0) ;
  mutation = new BitFlipMutation(mutationProbability) ;

  selection = new BinaryTournamentSelection<BinarySolution>() ;

  algorithm = new WASFGA<BinarySolution>(problem, 100, 250, crossover, mutation, selection,new SequentialSolutionListEvaluator<BinarySolution>(),referencePoint) ;

  AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm)
          .execute() ;

  List<BinarySolution> population = algorithm.getResult() ;
  long computingTime = algorithmRunner.getComputingTime() ;

  JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

  printFinalSolutionSet(population);
  if (!referenceParetoFront.equals("")) {
    printQualityIndicators(population, referenceParetoFront) ;
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:56,代码来源:WASFGABinaryRunner.java


注:本文中的org.uma.jmetal.util.AlgorithmRunner.getComputingTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。