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.
That
100hard
should probably be-100hard
.OptaPlanner will always output the solution with the highest score - that is the best solution. So solution A with score
100hard
is better than solution B with score0hard
, which is better than solution C with score-100hard
.I suspect you might have implemented a hard constraint that rewards instead of penalizes, unintentionally.
Practically yes (even if the answer is no internally). By default, OptaPlanner will assign all variables and output the best solution (= solution with the highest score) encountered during it's run. If it has encountered any solution with no hard constraints broken, the best solution it outputs will have no hard constraints broken.
But what if it didn't encounter any solution with no hard constriants broken?