I am using JaCoP to solve logical equations. I want to impose a constraint and check if it is satisafiable or not. If yes, I want to impose the constraint and if not, I want to remove the constraint. So is there a way I can remove constraints on my store?
I tried copying the entire store to another store. But that did not seem to work. I am new to JaCoP library. So can any one help me with this? Thanks.
I have two comments.
1. Checking consistency using store.consistency() when returns false means that the store is inconsistent. When the method returns true it **only** means that the inconsistency cannot be detected. it might be that the set of constraints is consistent or might not be. Finite domain constraint solvers are not complete and it is one of their characteristics. Moreover, when the store is inconsistent it might be left in a state that cannot be used.
2. The constraint can be remove using constraint method removeConstraint(), but do not use it when consistency method returned false.
Thank you very much for the comments. I am not using consistency method. I am using a Depth first search as show in the example given in the documentation.
Search<IntVar> search = new DepthFirstSearch<IntVar>();
SelectChoicePoint<IntVar> select = new InputOrderSelect<IntVar>(store, v, new IndomainMin<IntVar>());
boolean result = search.labeling(store, select);
If my result is false and I remove the constraint does the store remain usable always? If that is so, I can use DFS instead of the consistency method.
Or else, can you tell me a way to copy the entire store and its vars and constraints to a temporary store?
Sure. You can use DFS to find out if something is consistent or not. It can be a good idea to set a flag to not assign a solution to variables and possibly increase a search level before search using
and decrease afterwords by using
It touches the solver rather deeply and you should be careful and aware of that ;)