Solver seems to start breaking hard constraint when I add another planning variable #175
matthewjd24
started this conversation in
General
Replies: 2 comments 1 reply
-
Making the mold property of the Job class not nullable seems to fix it. I'm not sure why. It's not an accurate representation of my domain but I can work around it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
According to documentation (https://timefold.ai/docs/timefold-solver/latest/constraint-streams/constraint-streams.html#constraintStreamsForEach) the .forEach(Job.class) tracks only planning entities with non Null planning variable values. Try .forEachIncludingNullVars(Job.class) instead |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is a diagram of my domain model:

The issue I have is, when I add in the Mold as a planning variable, the solver starts breaking my hard constraint (the only one I've set up so far). Yet the HardSoftScore result is still
best score (0hard/0soft)
.The hard constraint applies a penalty when two jobs are assigned to the same Cycle (checked by getTimeslotID). The hard constraint:
I've rewritten this constraint multiple times in the hope that it's not behaving as I expect, but this issue persists.
My PlanningEntity (Job):
My PlanningSolution (TimeTable):
Things I've tried:
@PlanningVariable(nullable = true)
to@PlanningVariable(valueRangeProviderRefs = {"moldRange"}, nullable = true)
in the Job class and changing@ValueRangeProvider
to@ValueRangeProvider(id = "moldRange")
in my PlanningSolution.If I remove the Mold as a planning variable, it starts obeying the constraint again. I do not know why. I have published my project in a repository here: https://github.com/matthewjd24/OptaPlanner-Scheduler
Beta Was this translation helpful? Give feedback.
All reactions