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


Java AlgorithmRunner类代码示例

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


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

示例1: shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
@Test
public void shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem() throws Exception {
  DoubleProblem problem = new ZDT1() ;
  JMetalRandom.getInstance().setSeed(1446505566148L);
  algorithm = new GDE3Builder(problem)
          .setMaxEvaluations(25000)
          .setPopulationSize(100)
          .build() ;

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

  List<DoubleSolution> population = algorithm.getResult();

  /*
  Rationale: the default problem is ZDT4, and GDE3, configured with standard settings, should
  return 100 solutions
  */
  assertTrue(population.size() >= 99) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:20,代码来源:GDE3TestIT.java

示例2: shouldTheHypervolumeHaveAMininumValue

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
@Test
public void shouldTheHypervolumeHaveAMininumValue() throws Exception {
  DoubleProblem problem = new ZDT1() ;

  JMetalRandom.getInstance().setSeed(1446505566148L);
  algorithm = new GDE3Builder(problem)
          .setMaxEvaluations(25000)
          .setPopulationSize(100)
          .build() ;

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

  List<DoubleSolution> population = algorithm.getResult();

  QualityIndicator<List<DoubleSolution>, Double> hypervolume = new PISAHypervolume<>("/referenceFronts/ZDT4.pf") ;

  // Rationale: the default problem is ZDT1, and GDE3, configured with standard settings, should
  // return find a front with a hypervolume value higher than 0.66

  double hv = (Double)hypervolume.evaluate(population) ;

  assertTrue(hv > 0.66) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:24,代码来源:GDE3TestIT.java

示例3: shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
@Test
public void shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem() throws Exception {
  algorithm = new MOCellBuilder<DoubleSolution>(problem, crossover, mutation)
      .setArchive(new CrowdingDistanceArchive<DoubleSolution>(100))
      .build() ;

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

  List<DoubleSolution> population = algorithm.getResult();

  /*
  Rationale: the default problem is ZDT4, and MOCell, configured with standard settings, should
  return 100 solutions
  */
  assertTrue(population.size() >= 98) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:17,代码来源:MOCellIT.java

示例4: shouldTheAlgorithmReturnTheCorrectSolutionWhenSolvingProblemOneMax

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
@Test
public void shouldTheAlgorithmReturnTheCorrectSolutionWhenSolvingProblemOneMax() {
  int NUMBER_OF_BITS = 512 ;
  Algorithm<BinarySolution> algorithm;
  BinaryProblem problem = new OneMax(NUMBER_OF_BITS) ;

  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 GeneticAlgorithmBuilder<BinarySolution>(problem, crossoverOperator, mutationOperator)
          .setVariant(GeneticAlgorithmBuilder.GeneticAlgorithmVariant.STEADY_STATE)
          .setPopulationSize(50)
          .setMaxEvaluations(25000)
          .setSelectionOperator(selectionOperator)
          .build() ;

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

  BinarySolution solution = algorithm.getResult() ;
  assertEquals(NUMBER_OF_BITS, -1 * (int)solution.getObjective(0)) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:23,代码来源:SteadyStateGeneticAlgorithmTestIT.java

示例5: shouldTheAlgorithmReturnTheCorrectSolutionWhenSolvingProblemOneMax

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
@Test
public void shouldTheAlgorithmReturnTheCorrectSolutionWhenSolvingProblemOneMax() {
  int NUMBER_OF_BITS = 512 ;
  Algorithm<BinarySolution> algorithm;
  BinaryProblem problem = new OneMax(NUMBER_OF_BITS) ;

  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 GeneticAlgorithmBuilder<BinarySolution>(problem, crossoverOperator, mutationOperator)
          .setPopulationSize(50)
          .setMaxEvaluations(50000)
          .setSelectionOperator(selectionOperator)
          .build() ;

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

  BinarySolution solution = algorithm.getResult() ;
  assertEquals(NUMBER_OF_BITS, -1 * (int)solution.getObjective(0)) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:22,代码来源:GenerationalGeneticAlgorithmTestIT.java

示例6: shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
@Test
public void shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem() throws Exception {
  algorithm = new ABYSSBuilder(problem, archive)
      .build();

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

  List<DoubleSolution> population = algorithm.getResult();

  /*
  Rationale: the default problem is ZDT4, and AbYSS, configured with standard settings, should
  return 100 solutions
  */
  assertTrue(population.size() >= 98) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:16,代码来源:ABYSSIT.java

示例7: 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

示例8: 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

示例9: main

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
/**
 * @param args Command line arguments.
 * @throws SecurityException
 * Invoking command:
java org.uma.jmetal.runner.multiobjective.RandomSearchRunner problemName [referenceFront]
 */
public static void main(String[] args) throws JMetalException, FileNotFoundException {
  Problem<DoubleSolution> 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 = ProblemUtils.loadProblem(problemName);

  algorithm = new RandomSearchBuilder<DoubleSolution>(problem)
          .setMaxEvaluations(2500000)
          .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,代码行数:43,代码来源:RandomSearchRunner.java

示例10: 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

示例11: 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

示例12: 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

示例13: main

import org.uma.jmetal.util.AlgorithmRunner; //导入依赖的package包/类
/**
 * Usage: java org.uma.jmetal.runner.singleobjective.NonElitistEvolutionStrategyRunner
 */
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.NON_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,代码行数:38,代码来源:NonElitistEvolutionStrategyRunner.java

示例14: 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

示例15: main

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

  problem = new Rosenbrock(20) ;

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

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

  algorithm = new SMPSOBuilder(problem, archive)
      .setMutation(mutation)
      .setMaxIterations(25)
      .setSwarmSize(100)
      .setRandomGenerator(new MersenneTwisterGenerator())
      .setSolutionListEvaluator(new SequentialSolutionListEvaluator<DoubleSolution>())
      .build();

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

  List<DoubleSolution> 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");

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


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