0

I am using Optaplanner with Quarkus, does anyone know if ProblemId can be accessed from ConstraintProvider? I'm using the SolverManager, and I would like to be able to fine-tune the Constraints based on the resolution request that uses parameters sent by the user and stored in H2. These parameters are stored with the ProblemId, and I would like to find them in the ConstraintProvider. Is this possible? Has anyone tried to do something similar?

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
Loïc
  • 157
  • 8

1 Answers1

1

A ConstraintProvider can write constraints based on any method of any problem fact or planning entity.

So it can do something with the @PlanningId annotated method of for example Lesson: from(Lesson.class).filter((lesson) -> lesson.getId() ...)

But I suspect what you want to do is @ConstraintConfiguration. See docs.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Hello Geoffrey, yes it can be a solution for part of my problem, I can maybe disable some constraints like that. I will try this : https://stackoverflow.com/questions/59751860/optaplanner-add-remove-constraints-dynamically to dynamically change the value of a ConstraintWeight. But there is another thing I would like to do: to be able to use user parameters for the limits of my constraints. For example having N days of rest between 2 shifts. N being variable and sent by the user. I think I will store these parameters in the planning entities to use them in the constraints mehods. – Loïc Aug 02 '21 at 17:48