Incrementally solving CLP(FD)

When I tried to solve a problem, I faced a situation when it requires solving a CLP(FD) incrementally.
For example, let M be a model of a CLP(FD). To solve it, we just need to query the model in prolog like
:- M.
Then it generates all domains for variables. But when we solve it again, the FD solver propagate the FD again. In this situation, I have questions:

  1. Is there any way to save the result after constraint propagation about domains of all variable? And later load the saved result, and without recalculation of propagation, we can use the result in a query?

  2. If it is possible, we can incrementally solve a model such as “M, C1, C2, C3” where “C1”, “C2” and “C3” are additional constraints. That is,
    (a) first solve “M”,
    (b) next add the constraint “C1” and solve the with the result of “M”. Not solve “M,C1” from scratch.
    (c) next add “C2” and solve with the result of (B), and so on.

  3. Also if we can backtrack the adding and solving in CLP(FD), it will be very helpful for my research.

I studied attribute variables for CLP(FD) but no idea. If you have any idea, please let me know it.
Thank you!

  1. Regarding saving the result, have you already looked into fd_dom/2? It gives you the domain of a clpfd variable; here’s a usage example.
  2. This one sounds like a general Prolog question, not that I know how to solve it.
  3. I’m not sure if this is what you had in mind, but label/1 basically forces a value to the variables given; an example.

I’m not exactly clear on the nature of the problem. For your situation, do the results returned affect later runs of the algorithm?

It seems like the Constraint Handling Rules extensions could handle that. If not, I’d search for papers on adaptive constraint handling.

Thank you for your advice.

Yes, I know the use of fd_dom, and what I need is to save the information of domains as a record of the current state of FD model and load later for solving together with additional constraints. In the execution process, two queries are needed. So is there any way to save the information in a file and load it in the second query?

In fact, I am going to embed prolog app to solve FD problems in a program in C++.
In solving a problem in C++, I need to solve FD subproblems which requires embedding prolog engines. What I do is that I provide an initial FD submodel to SWI-Prolog and get some information about satisfiability. With the result, C++ part proceeds more and generate another FD subproblem to be solved in SWI-Prolog. The new submodel is almost the same as the initial submodel with additional constraints. So instead of solving the new model from scratch, I want to execute constraint propagation on the resulted state from the initial submodel. It saves computational time in long run.

Well, if it is possible, I want to generate many prolog engines, to feed submodels, which are almost the same as the initial model but a few constraints, into the engines, and to solve them in parallel processing. I tried to use many prolog engines but a problem is still I need to solve FD submodels from scratch all the time.