Menu

#28 Archive viewer crashes if an integer objective is sometimes infeasible

v1.0_(example)
closed
nobody
None
5
2014-02-04
2014-01-31
No

When using an objective that is assigned an integer value, the Archive viewer crashes in compare() if some individuals in the archive have set this objective to infeasible.

Bug description:

  • an evaluator adds an integer objective by: objectives.add(objective, intValue);
    or sets it to infeasible by: objectives.add(objective, Objective.INFEASIBLE);

  • Within Objectives.add(), as Objective.INFEASIBLE is implemented as null, the infeasible objective is mapped to a "new DoubleValue(null)".
    (org.opt4j.core.Objectives.add(Objectives.java:164)

  • the Archive viewer compares different individuals by using objectiveValueIndividual1.compareTo(objectiveValueIndividual2), which results in a ClassCastException, as in our case a Double is compared to an Integer.
    (org.opt4j.viewer.ArchiveWidget$Comp.compare(ArchiveWidget.java:421)

Exception in thread "Thread-3396" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
at org.opt4j.core.DoubleValue.compareTo(DoubleValue.java:82)
at org.opt4j.core.DoubleValue.compareTo(DoubleValue.java:28)
at org.opt4j.viewer.ArchiveWidget$Comp.compare(ArchiveWidget.java:421)
at org.opt4j.viewer.ArchiveWidget$Comp.compare(ArchiveWidget.java:395)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324)
at java.util.TimSort.sort(TimSort.java:189)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at org.opt4j.viewer.ArchiveWidget$3.run(ArchiveWidget.java:374)
at org.opt4j.core.config.visualization.DelayTask$DelayThread.run(DelayTask.java:71)

If the ArchiveViewer uses the involved objective as primary sorting element, all contained individuals have the objective inveasible, and a feasible individual is added to the archive, the bug is reproduceable.

Discussion

  • Martin Lukasiewycz

    Seems this was fixed very quickly by Felix in commit 154

     
    • Felix Reimann

      Felix Reimann - 2014-02-04

      True. It was definitely a bug in the viewer. However, I'm not sure if it is reasonable to add DoubleValue(null) in case of Objective.INFEASIBLE to an objective which contains IntegerValues (or others). You could expect that all values of a single objective have the same type.

       
  • Martin Lukasiewycz

    • status: open --> closed
     

Log in to post a comment.