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

Score DRL: a then side that doesn't always call addConstraintMatch corrupts the score

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • 7.10.0.Final
    • 7.0.0.Beta7
    • optaplanner-core
    • None
    • NEW
    • NEW

      Presume this then side:

      rule "Minimum and maximum number of assignments"
              ...
          then
              int totalInt = $total.intValue();
              if ($contractLine.isMinimumEnabled() && totalInt < $contractLine.getMinimumValue()) {
                  scoreHolder.addSoftConstraintMatch(kcontext,
                          (totalInt - $contractLine.getMinimumValue()) * $contractLine.getMinimumWeight());
              } else if ($contractLine.isMaximumEnabled() && totalInt > $contractLine.getMaximumValue()) {
                  scoreHolder.addSoftConstraintMatch(kcontext,
                          ($contractLine.getMaximumValue() - totalInt) * $contractLine.getMaximumWeight());
              }
      end
      

      When this rule changes (not unmatches, but matches differently), and the original match added a soft constraint, but the new match does not add any soft constraint, then the original added soft constraint isn't undone (reverted).

      The reason is that in Drools we can listen to unmatch events, but we cannot listen to change events.

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: