Skip to content

Commit

Permalink
Read epsilons and default max evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Oct 21, 2024
1 parent d3edc04 commit 5d4a592
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.moeaframework.algorithm.jmetal.adapters.JMetalAlgorithmAdapter;
import org.moeaframework.algorithm.jmetal.adapters.PermutationProblemAdapter;
import org.moeaframework.algorithm.jmetal.adapters.ProblemAdapter;
import org.moeaframework.core.DefaultEpsilons;
import org.moeaframework.core.Epsilons;
import org.moeaframework.core.Settings;
import org.moeaframework.core.Solution;
import org.moeaframework.core.TypedProperties;
Expand Down Expand Up @@ -576,10 +578,16 @@ private Algorithm newOMOPSO(TypedProperties properties, Problem problem) throws

SolutionListEvaluator evaluator = new SequentialSolutionListEvaluator();

Epsilons epsilons = DefaultEpsilons.getInstance().getEpsilons(problem);

if (epsilons.size() != 1) {
System.err.println("Multiple epsilon values configured for problem, but JMetal only supports 1");
}

OMOPSOBuilder builder = new OMOPSOBuilder(adapter, evaluator)
.setUniformMutation(uniformMutation)
.setNonUniformMutation(nonUniformMutation)
.setEta(properties.getDouble("epsilon", 0.0075));
.setEta(properties.getDouble("epsilon", epsilons.get(0)));
loadProperties(properties, builder);

return new JMetalAlgorithmAdapter(builder.build(), properties, adapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.moeaframework.algorithm.Algorithm;
import org.moeaframework.algorithm.AlgorithmException;
import org.moeaframework.algorithm.extension.Extensions;
import org.moeaframework.core.Settings;
import org.moeaframework.core.Solution;
import org.moeaframework.core.TypedProperties;
import org.moeaframework.core.population.NondominatedPopulation;
Expand Down Expand Up @@ -68,7 +69,8 @@ public JMetalAlgorithmAdapter(
ProblemAdapter<T> problem) {
super();
this.algorithm = algorithm;
this.maxEvaluations = (int)properties.getDouble("maxEvaluations", 25000);
this.maxEvaluations = (int)properties.getDouble("maxEvaluations",
Settings.DEFAULT_MAX_FUNCTION_EVALUATIONS);
this.problem = problem;
}

Expand Down

0 comments on commit 5d4a592

Please sign in to comment.