Skip to content

Instantly share code, notes, and snippets.

@dhadka
Created July 27, 2016 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhadka/d3661b52fe0e81f103a5b4c2aedb20bc to your computer and use it in GitHub Desktop.
Save dhadka/d3661b52fe0e81f103a5b4c2aedb20bc to your computer and use it in GitHub Desktop.
RuntimeApproximationSets.java
Instrumenter instrumenter = new Instrumenter()
.withProblem("UF1")
.withFrequency(100)
.attachApproximationSetCollector();
new Executor()
.withProblem("UF1")
.withAlgorithm("NSGAII")
.withMaxEvaluations(10000)
.withInstrumenter(instrumenter)
.run();
Accumulator accumulator = instrumenter.getLastAccumulator();
List<Integer> xs = new ArrayList<Integer>();
List<Double> ys = new ArrayList<Double>();
for (int i = 0; i < accumulator.size("NFE"); i++) {
// determine the maximum objective value
double maxObj = Double.NEGATIVE_INFINITY;
for (Solution solution : (List<Solution>)accumulator.get("Approximation Set", i)) {
maxObj = Math.max(maxObj, solution.getObjective(0));
}
// update the series to plot
xs.add((Integer)accumulator.get("NFE", i));
ys.add(maxObj);
}
new Plot()
.line("Objective 1 (Max)", xs, ys)
.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment