Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Improve error message when @PlanningListVariable is used alongside a @PlanningVariable on different classes #683

Open
Christopher-Chianelli opened this issue Mar 5, 2024 · 4 comments
Labels
enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc.

Comments

@Christopher-Chianelli
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently, if you use a @PlanningVariable and a @PlanningListVariable on different classes, the following exception occurs:

java.lang.IllegalArgumentException: The config (QueuedValuePlacerConfig(ValueSelectorConfig(jobs), ListChangeMoveSelectorConfig(ValueSelectorConfig(null), null))) has no entityClass configured and because there are multiple in the entityClassSet ([class org.acme.foodpackaging.domain.Job, class org.acme.foodpackaging.domain.Line]), it cannot be deduced automatically.
	at ai.timefold.solver.core.impl.AbstractFromConfigFactory.getTheOnlyEntityDescriptor(AbstractFromConfigFactory.java:67)

Describe the solution you'd like
Ideally, the error message should improve by telling the user that @PlanningListVariable cannot be used with @PlanningVariable currently:

java.lang.IllegalArgumentException: There exists a PlanningListVariable (...), so there can be no PlanningVariable (...). Maybe used a chained model?

Describe alternatives you've considered
This issue will become stale once PlanningListVariable supports co-existing with other PlanningVariable(s)

Additional context
https://stackoverflow.com/q/78102453/9698517

@Christopher-Chianelli Christopher-Chianelli added enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. labels Mar 5, 2024
@Christopher-Chianelli Christopher-Chianelli changed the title Feat: Improve error message when @PlanningListVariable is used alongside a @PlanningVariable Feat: Improve error message when @PlanningListVariable is used alongside a @PlanningVariable on different classes Mar 5, 2024
@Christopher-Chianelli
Copy link
Contributor Author

If the @PlanningVariable and @PlanningListVariable are defined on the same class, there is a better error message:

java.lang.UnsupportedOperationException: Combining basic variables ([Line.product variable]) with list variables (Line.jobs variable) on a single planning entity (org.acme.foodpackaging.domain.Line) is not supported.

@triceo
Copy link
Contributor

triceo commented Mar 6, 2024

@Christopher-Chianelli That's an important distinction. We are absolutely sure we do not support combining list variables and basic variables on the same entity.

But are we so sure we don't support it on two different entity classes?
Because the original exception is just saying you need to configure the selector specifically for a particular entity, as there are two different entities. It's not saying that the combination is not supported.

@Christopher-Chianelli
Copy link
Contributor Author

I am pretty sure there are no tests for @PlanningVariable + @PlanningListVariable on different entities, so if it supported, it not tested. Additionally, that exception is from the default phase list/SoverConfig. Finally, the docs state

Planning list variable does not yet support ... coexistence with another list or basic planning variable.

@triceo
Copy link
Contributor

triceo commented Mar 6, 2024

The docs is ambiguous too - does "coexistence" mean "in the same solution" or "in the same entity class"? IMO this needs to be tested to know for sure.

If we can reconfigure the selector manually to two selectors, one for each entity, and it still blows up, then it's clear - we do not support this use case. (I think that this is the more likely outcome, I'm just not 100.0 % sure.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc.
Projects
None yet
Development

No branches or pull requests

2 participants