Search code examples
droolsoptaplanner

OptaPlanner : I tried to print out the justificationList of ConstraintMatch, but got objects of SubnetworkTuple which are not my domain classes


I'm using OptaPlanner to solve a planning problem. I use drools to do score calculation. When I tried to print out the justificationList of each constraintMatch, I got objects which are instances of SubnetworkTuple besides my domain class objects. These seem to be objects that are used in its internal implementation.

I have not used drools rule engine before :) . And this is my first time to use OptaPlanner. As far I know, justificationList should contain all objects that are involved in that rule.

drools rule:

rule "roomPriority"
    when
        EduClassRoomPriority($left : leftEduClass, $right : rightEduClass, $priority : priority)
        exists(LectureOfEduClass(eduClass == $left,$room1 : room ) and LectureOfEduClass(eduClass == $right, $room1 != room))
    then
        scoreHolder.addSoftConstraintMatch(kcontext,-$priority);
end

java:

for (ConstraintMatchTotal constraintMatchTotal : constraintMatchTotals) {
                String constraintName = constraintMatchTotal.getConstraintName();
                Score totalScore = constraintMatchTotal.getScore();
                Set<ConstraintMatch> constraintMatchSet = constraintMatchTotal.getConstraintMatchSet();
                logger.info(totalScore.toShortString() + " constraint(" + constraintName + ") has " + constraintMatchSet.size() + " matches");
                for (ConstraintMatch constraintMatch : constraintMatchSet) {
                    List<Object> justificationList = constraintMatch.getJustificationList();
                    Score score = constraintMatch.getScore();
                    logger.info(score.toShortString() + justificationList.toString());
                }
            }

I wonder what I can do to fix that problem, because these extra objects would confuse users. I can do instance of check. But That shouldn't be the right way to resolve it.

Thank everyone in advance.


Solution

  • Caused and fixed by https://issues.jboss.org/browse/DROOLS-4423 for 7.26.