當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。