Skip to content

Instantly share code, notes, and snippets.

@guiarn
Created March 21, 2016 13:31
Show Gist options
  • Save guiarn/ae0e71fbed89d6b6363d to your computer and use it in GitHub Desktop.
Save guiarn/ae0e71fbed89d6b6363d to your computer and use it in GitHub Desktop.
Example Crash FastPGA
import java.util.List;
import org.moeaframework.Executor;
import org.moeaframework.core.NondominatedPopulation;
import org.moeaframework.core.Solution;
import org.moeaframework.core.variable.EncodingUtils;
public class Gen_PFs {
private static void usage() {
System.err.println("Usage: Gen_PFs -a ALG_NAME " +
"-p PROBLEM_NAME -s POPULATION_SIZE " +
"-m MAX_FUNCS_EVAL -r NUMBER_SEEDS\n");
System.exit(-1);
}
public static void main(String[] args) {
String algName = "FastPGA", problemName = "ZDT2";
int seeds = 100, mfe = 10000, populSize = 100;
//parse arguments to set options
int n = args.length;
for (int i = 0; i < n; ++i) {
if (args[i].equals("-a") && i+1 < n)
algName = args[++i];
else if (args[i].equals("-p") && i+1 < n)
problemName = args[++i];
else if (args[i].equals("-s") && i+1 < n)
populSize = Integer.parseInt(args[++i]);
else if (args[i].equals("-m") && i+1 < n)
mfe = Integer.parseInt(args[++i]);
else if (args[i].equals("-r") && i+1 < n)
seeds = Integer.parseInt(args[++i]);
else usage();
}
//configure and run this experiment
List<NondominatedPopulation> result = new Executor()
.withProblem(problemName)
.withAlgorithm(algName)
.withProperty("populationSize", populSize)
.withMaxEvaluations(mfe)
.distributeOnAllCores()
.runSeeds(seeds);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment