Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-620

Workbench: CH: Support difficulty comparator definition

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 7.0.0.Beta2
    • None
    • optaplanner-wb
    • None
    • NEW
    • NEW

      As the construction heuristic definition is now supported, it's essential we provide a way how to specify difficulty comparator when using related CH types (e.g. FIRST_FIT_DECREASING).

      Requirements:

      • allow comparing on object fields (including nested objects) in lexicographic order (ascending/descending order)
      • source generation should avoid using org.apache.commons.lang3.builder.CompareToBuilder, let's use methods available in java.util.Comparator instead

      The screen could look like this:

      Would might generate code like this:

          public int compare(Lecture o1, Lecture o2) {
              return Comparator
                      .comparing((Lecture l) -> l.getCourse().getTeacher().getAge(), Comparator.reverseOrder())
                      .thenComparing((Lecture l) -> l.getCourse().getStudentSize())
                      .compare(o1, o2);
          }
      

            mcimbora_jira Matej Čimbora (Inactive)
            mcimbora_jira Matej Čimbora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: