martin-fleck / momot

Marrying Search-based Optimization and Model Transformation Technology
http://martin-fleck.github.io/momot/
17 stars 6 forks source link

Evaluating constraints leads to ArrayIndexOutOfBoundsException #4

Open sherzig opened 7 years ago

sherzig commented 7 years ago

Hi,

I'm trying to perform a check on each solution to see whether a set of pre-defined OCL invariants are satisified. This is what I use in the search configuration:

constraints = { OCLStructuralConstraintViolation : minimize { val d = Diagnostician.INSTANCE.validate(MomotUtil.getRoot(solution.execute())); if (d.getChildren().size() > 0) { IFitnessDimension.CONSTRAINT_VIOLATED; } else { IFitnessDimension.CONSTRAINT_OK; } } }

The search runs fine for a few seconds, but then throws the following exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.ArrayList.elementData(ArrayList.java:418) at java.util.ArrayList.get(ArrayList.java:431) at org.moeaframework.algorithm.ReferencePointNondominatedSortingPopulation.associateToReferencePoint(ReferencePointNondominatedSortingPopulation.java:560) at org.moeaframework.algorithm.ReferencePointNondominatedSortingPopulation.truncate(ReferencePointNondominatedSortingPopulation.java:639) at org.moeaframework.algorithm.ReferencePointNondominatedSortingPopulation.truncate(ReferencePointNondominatedSortingPopulation.java:691) at org.moeaframework.algorithm.NSGAII.iterate(NSGAII.java:97) at org.moeaframework.algorithm.AbstractAlgorithm.step(AbstractAlgorithm.java:161) at org.moeaframework.algorithm.PeriodicAction.step(PeriodicAction.java:108) at at.ac.tuwien.big.moea.experiment.executor.SearchExecutor.runAlgorithm(SearchExecutor.java:269) at at.ac.tuwien.big.moea.experiment.executor.SearchExecutor.runSingleSeed(SearchExecutor.java:301) at org.moeaframework.Executor.runSeeds(Executor.java:608) at at.ac.tuwien.big.moea.SearchExperiment.run(SearchExperiment.java:254) at at.ac.tuwien.big.moea.SearchExperiment.run(SearchExperiment.java:241) at momot.search.search.performSearch(search.java:374) at momot.search.search.main(search.java:397)

Could this be due to the array only being sized for objectives, but not constraints and objectives?

Also, is there a way to mark something as a "hard" constraint - i.e., the candidate solution is thrown away if those constraints are not satisified?

Thanks,

Sebastian

sherzig commented 7 years ago

Small update: this may be related to NSGAIII in some way - running with NSGAII or Random Search works just fine.

martin-fleck-at commented 7 years ago

Hi Sebastian,

You are absolutely right in that this is related to the NSGA-III algorithm. Basically, the fundamental difference between NSGA-II and NSGA-III lies in the way the niche preservation operation is performed. Unlike NSGA-II, NSGA-III starts with a set of reference points to select more well-distributed solutions with respect to the objectives.

From the place where the error occurs, it seems that the calculation for the Pareto surface based on the number of objectives, the number of inner divisions and number of outer divisions leads to problems. So, at this point, it seems that there is not much I can do. Do you get any console messages regarding the number of inner or outer divisions? How many objectives do you use? More than 1? Because for single-objectives, NSGA-III might be a bit overkill. You can also try setting different values for the inner and outer divisions in NSGA-III. You should be able to do so by using the method 'createNSGAIII' of the MOEA helper object, i.e., moea.createNSGAIII(divisionsOuter, divisionsInner, ...). The default values I used are 4 and 0.

sherzig commented 7 years ago

Hi Martin,

Thanks for the detailed reply! I'm using 4 objectives at the moment, plus 1 constraint.