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

	}
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" ) ; }
Usage: java
org.uma.jmetal.runner.singleobjective.CoralReefsOptimizationRunner