Dear Olivier, Oliver Shycle wrote: > Dear all, > > thanks to all your help and advices I successfully set up my user defined > reified constraints which no behave as I expect. The Constraint Library > Manual however left some unanswered questions. > On page 22 the manual says: > - Enforcing constraints: It seems to be better to unify the truth reified > values to variables to get active constraints. Is this correct? What do you exactly mean here? Do you mean: "I impose a reified constraint. Now, should I immediately impose that the corresponding boolean is true or false? E.g.: B#= X#>Y, labeling([B]), (other constraints) labeling(...other variables ...) " If this is the question, the answer is no. You should first impose all the constraints, then you perform search: B#= X#>Y, (other constraints) labeling(...all variables, including B ...) > What are > advantages and disadvantages of passive and active constraints? It is not a matter of advantages or disadvantages: in that page the manual says how the system works. The constraint remains passive (i.e., it can do nothing) until: - either B becomes bound - or the solver is able to infer that the original constraint (in the example, X#>Y) is true - or the solver is able to infer that the original constraint is false > - "In the event that the reified variable becomes bound to 0 then the > constraint should actively propagate its negation." How is this active > propagation ensured by my constraints? What do I have to regard? You have to write your propagation scheme for both the positive and the negative part of the constraint. If you use Propia, you have to write a predicate that considers all the possibilities: when the constraint is true, and when it is false. E.g., you want to write a new constraint that is true when the absolute value of X is greater than 10, and you want to do it with Propia. So, you start writing a predicate: abs10(X):- X #> 10. abs10(X):- X #< -10. Now you want it to work as a constraint, so you call it with abs10(X) infers most. Then you want to use it as a reified constraint, so you have to add an argument B, and you have to write a predicate with two arguments: abs10(X,1):- X #> 10. abs10(X,1):- X #< -10. abs10(X,0):- X #=< 10, X #>= -10. Notice that last clause: you have to write code that explains what happens when the constraint "absolute value of X is greater than 10" is false. This will "actively propagate its negation": you write code for this case. Finally, you embed everything in a new predicate that invokes abs10 as a Propia constraint: abs10_constr(X,B):- abs10(X,B) infers most. In this way you can combine it with other reified constraints, as in abs10_constr(X) or X #< 5. > - same for "actively propagate its normal semantics" The normal semantics, in the example, is "absolute value of X is greater than 10". I.e., you have to write code that explains what happens when this sentence is true. In the example there are two clauses: one when X is greater than 10, and one in which X is less than -10. I am not sure I understand your problem. Is your problem: "I have found a nice constraint C, but I want to negate it. I have two options: 1. I write from scratch a new constraint, called notC 2. I simply write neg(C) and it magically works" Option 2 does not exist, unless you take a very simple constraint (one of the constraints that are already reified). You only have option 1. Then, if you want, you can use your code to write C also as a reified constraint. Best, Marco -- Marco Gavanelli, Ph.D. in Computer Science Dept of Engineering University of Ferrara Tel/Fax +39-0532-97-4833 http://www.ing.unife.it/docenti/MarcoGavanelli/Received on Thu Apr 08 2010 - 16:18:35 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST