TimefoldAI / TimefoldAI/timefold-solver
Feat: planning variables outside of the value range should be allowed for pinned planning entities
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 228
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 46
Description
Is your feature request related to a problem? Please describe.
Our use case involves the following:
- Initial planning done by a Timefold-based service
- Manual adjustment by human planners
- Automatic re-planning done with the same Timefold service when conditions are different than expected (e.g. supply disruptions). In this case almost all planning entities are frozen, except for those whose values need to be adjusted.
A different value range is used in step 3 than in step 1, and it is also possible for the human planners to have adjusted planning variables to be outside the original range.
Currently, when these (pinned) planning entities with planning variables outside of the set range are sent to the service, the following error is thrown:
File core\src\main\java\ai\timefold\solver\core\impl\score\director\AbstractScoreDirector.java, line 880-884.
if (!valueRange.contains(value)) {
throw new IllegalStateException(
"The value (%s) from the planning variable (%s) has been assigned to the entity (%s), but it is outside of the related value range %s."
.formatted(value, variableDescriptor.getVariableName(), entity, valueRange));
}
Describe the solution you'd like
I would like to add the following condition to the following lines, to allow planning variables outside the range when the planning entity is pinned (I know the below code probably doesn't meet your standards):
if (!valueRange.contains(value) && !entity.isPinned()) {
...
Describe alternatives you've considered
Currently I work around this by not adding these planning entities to the @PlanningEntityCollectionProperty collection. In our case this works, but the above solution would be neater.
Additional context
I don't really know the code base, so I'm unsure how much work this would be beyond just updating the if-condition above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in core/src/main/java/ai/timefold/solver/core/impl/score/director/AbstractScoreDirector.java around lines 880-884 and trace how pinned planning entities and value ranges are represented. Check existing tests for planning-variable range validation, then verify that pinned entities with out-of-range values are accepted while the current validation remains for unpinned entities.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100