I have a use case where I want to assign a salesperson to a list of appointments. Now, these salespeople have to travel from one point to another to reach the appointment location. I am using Optaplanner to schedule a list of salespersons for a bunch of appointments.
I have multiple constraints. Currently, I have implemented two constraints.
1. Sales rep work timing constraint.
2. A sales rep can accommodate at most one appointment at the same time.
Currently, when I ran these constraints individually it works fine and assigns correctly. However, when I add all the constraints and run the program, it is assigning some sales rep incorrectly. Even though some constraints are penalized but still OP selects the incorrect ones maybe it finds the best score among the penalized values.
Is there a way to completely reject a solution if we find any constraint(among multiples) violated?
For example, always choose a positive score and reject if a score has at least one negative value.
(5hard/3medium/2soft) > (1hard/0medium/0soft) but reject (6hard/-1medium/0soft)
Reject: 100hard/0medium/-1soft
Even if anyone score is negative then reject and only accept a score if it has all positive values.
Scores in OptaPlanner are compared based on their level, from left to right, hardest to softest. If a score level has a higher numeric value, it is considered better. If the numeric values for that level are equal, a softer level is considered.
In your example, the following is true:
Hard score 6 is better than hard score 5, and hard score 5 is better than hard score 1. If the solution represented by the first score is not in fact better than the second score, then you need to redefine your constraint weights to tell OptaPlanner that.
The score is a measure of solution quality. Better score means better solution. There is no working around that fact, it is something you have to accept.