Replies: 1 comment 2 replies
-
Hello @hyphz! I can see three ways of doing this:
As you can see, each approach has its benefits and downsides. Most often, we would use a shadow variable for this, understanding that the maintenance of shadow variables will cost you a little performance. |
Beta Was this translation helpful? Give feedback.
2 replies
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.
-
Is there a way to call a method on the solution class from a constraint? The ConstraintFactory seems to force you to use one of the ForEach variations, and to identify the list to go through by type rather than by name. Is there not an option to get the current Solution candidate?
Context: I'm experimenting with using Timefold to solve a simple box packing problem (spacefold?) Conveying a rule preventing boxes overlapping isn't too difficult as they are axis-aligned rectangles and can be checked using forEachUniquePair. However, I now need to check that each box is supported by either the bottom of a shelf or another box. The problem is that a box can be supported by any number of other boxes; obviously a loop through all combinations of boxes would be horribly slow. But support can be checked relatively easily by maintaining a grid voxel map of all boxes on each shelf. However this map could not be stored inside a single planning entity because it is a property of all of them. So if I have a method on the solution that checks for support, how can I call it from a constraint?
Beta Was this translation helpful? Give feedback.
All reactions