Search code examples
timefold

Basic TimeFold questions related to data modeling


I'm beginner on TimeFold, I have some basic questions

  1. Is it possible to fetch data from external database and update the
    PlanningSolution variables before every solve ? if not, what is the best solution to synchronize the PlanningSolution data with external database ?

  2. After solving a problem, I call the end point to get the result, in the same time, the data was changed by another user, is there a solution to be sure that the result still the best one ?

  3. Is it possible to apply the @ShadowVariable annotation to a list: on the use case of timeslot, I would like to generate all of available timeslots of all of available rooms, can I do that using TimeFold instead of define them manually ?

  4. Is it possible to configure a dynamic Constraints Provider: on the request I define the list of constraint to be included by the solver and others should be ignored


Solution

    1. Yes. The solution is a Java class like any other. If you know how to persist Java classes, you know how to persist a solution. SolutionManager.update(...) may be necessary to fill in values for shadow variables, assuming your database schema is normalized and doesn't store them.
    2. I do not understand your question. Solver is a class like any other - if you don't leak the reference, nobody else will be able to tweak it. But even if you did leak the reference, where did it leak to? Are we talking a multi-tenant server-side application? If so, why are your users allowed to touch other users' work? And what changes you're trying to guard against? Needs more clarity.
    3. Personally, I wouldn't use the solver for this. You have all the data you need to generate that list, so generate it yourself. It will be the fastest, simplest approach.
    4. Yes. See constraint configuration in Timefold Solver documentation.

    In the future, I recommend you ask questions individually. That way, you don't risk going against the rules of StackOverflow, and you also allow other users to more easily find your question and the answer, if they're solving the same problem.