Question

I am toying with drools planner as eventually I need to shape a rostering solution. I started from Drools Planner user guide, I succeeded in running the examples in Eclipse.

Trying to understand the differences between the simple and the HardAndSoft score types, I am trying to modify the NQueens example, changing the score from Simple to HardAndSoft.

I did as follows:

  1. In the nqueensSolverConfig.xml I set <scoreDefinitionType>HARD_AND_SOFT</scoreDefinitionType>.

  2. In the NQueens.java:

    • I set public class NQueens extends AbstractPersistable implements Solution<HardAndSoftScore> {...}

    • I changed SimpleScore related property and methods into corresponding HardAndSoftScore members:

    private HardAndSoftScore hsScore;

    public HardAndSoftScore getScore() { return hsScore; }

    public void setScore(HardAndSoftScore score) { this.hsScore = score; }

But when I run the solution I receive the following message:

"The scoreString (0) doesn't follow the 999hard/999soft pattern."

What is wrong?

Était-ce utile?

La solution

You 'll still have this in your solver config:

<termination>
  <scoreAttained>0</scoreAttained>
</termination>

Any score written in the solver config must be in the format of the score definition, so something like this:

<termination>
  <scoreAttained>0hard/0soft</scoreAttained>
</termination>

Note: you're probably off by looking at one of the "real" examples, such as course scheduling or nurse rostering, instead of N Queens.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top