jmetalsp-spark/src/main/java/org/uma/jmetalsp/spark/evaluator/NSGAIIRunner.java
public static void main(String[] args) throws JMetalException, FileNotFoundException {
    Problem<DoubleSolution> problem;
    Algorithm<List<DoubleSolution>> algorithm;
    CrossoverOperator<DoubleSolution> crossover;
    MutationOperator<DoubleSolution> mutation;
    SelectionOperator<List<DoubleSolution>, DoubleSolution> selection;

    String problemName;
    if (args.length == 1) {
      problemName = args[0];
    } else {
      problemName = "org.uma.jmetalsp.spark.evaluator.ZDT1";
    }

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

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

    SparkConf sparkConf = new SparkConf();
    JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);

    Logger.getLogger("org").setLevel(Level.OFF);

    algorithm = new NSGAIIBuilder<DoubleSolution>(problem, crossover, mutation, 100)
            .setSelectionOperator(selection)
            .setMaxEvaluations(25000)
            .setSolutionListEvaluator(new SparkSolutionListEvaluator<DoubleSolution>(sparkContext))
            .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");

    new SolutionListOutput(population)
            .setSeparator("\t")
            .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
            .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
            .print();
  }
/**
   * @param args Command line arguments.
   * @throws FileNotFoundException
   * Invoking command to run the program in local model with 8 cores:
   * spark-submit --class="org.uma.jmetalsp.spark.evaluator.NSGAIIRunner" --master local[8]
     jmetalsp-spark/target/jmetalsp-spark-1.1-SNAPSHOT-jar-with-dependencies.jar
   */
@param args Command line arguments.
@param args Command line arguments .
public static void main(String[] args) throws JMetalException, FileNotFoundException {
    Problem<DoubleSolution> problem;
    Algorithm<List<DoubleSolution>> algorithm;
    CrossoverOperator<DoubleSolution> crossover;
    MutationOperator<DoubleSolution> mutation;
    SelectionOperator<List<DoubleSolution>, DoubleSolution> selection;
    String problemName;
    if (args.length == 1) {
      problemName = args[0];
    } else {
      problemName = "org.uma.jmetalsp.spark.evaluator.ZDT1";
    }
    problem = ProblemUtils.<DoubleSolution>loadProblem(problemName);
    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>());
    SparkConf sparkConf = new SparkConf();
    JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);
    Logger.getLogger("org").setLevel(Level.OFF);
    algorithm = new NSGAIIBuilder<DoubleSolution>(problem, crossover, mutation, 100)
            .setSelectionOperator(selection)
            .setMaxEvaluations(25000)
            .setSolutionListEvaluator(new SparkSolutionListEvaluator<DoubleSolution>(sparkContext))
            .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");
    new SolutionListOutput(population)
            .setSeparator("\t")
            .setVarFileOutputContext(new DefaultFileOutputContext("VAR.tsv"))
            .setFunFileOutputContext(new DefaultFileOutputContext("FUN.tsv"))
            .print();
  }
public static void main ( String [ ] args ) throws JMetalException , FileNotFoundException { Problem < DoubleSolution > problem ; Algorithm < List < DoubleSolution > > algorithm ; CrossoverOperator < DoubleSolution > crossover ; MutationOperator < DoubleSolution > mutation ; SelectionOperator < List < DoubleSolution > , DoubleSolution > selection ; String problemName ; if ( args . length == 1 ) { problemName = args [ 0 ] ; } else { problemName = "org.uma.jmetalsp.spark.evaluator.ZDT1" ; } problem = ProblemUtils . < DoubleSolution > loadProblem ( problemName ) ; 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 > ( ) ) ; SparkConf sparkConf = new SparkConf ( ) ; JavaSparkContext sparkContext = new JavaSparkContext ( sparkConf ) ; Logger . getLogger ( "org" ) . setLevel ( Level . OFF ) ; algorithm = new NSGAIIBuilder < DoubleSolution > ( problem , crossover , mutation , 100 ) . setSelectionOperator ( selection ) . setMaxEvaluations ( 25000 ) . setSolutionListEvaluator ( new SparkSolutionListEvaluator < DoubleSolution > ( sparkContext ) ) . 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" ) ; new SolutionListOutput ( population ) . setSeparator ( "\t" ) . setVarFileOutputContext ( new DefaultFileOutputContext ( "VAR.tsv" ) ) . setFunFileOutputContext ( new DefaultFileOutputContext ( "FUN.tsv" ) ) . print ( ) ; }
@param args Command line arguments.
@param args Command line arguments .