[gecode-users] Problem with constraint

Ujhelyi Zoltan uz602 at hszk.bme.hu
Mon Aug 25 20:29:51 CEST 2008


Hello,

I tested the new Gecode/J 2.2.0. I am very grateful for your work, but  
it did not work for me as I expected. I modified the constraints as  
you showed, but it did not prove the required equality.

I copied your code into my sample program to test, but it did not help.

I got the following result with the equality of the two variable:

Variable #1: {0..1,3,5}
Variable #2: [0..5]
Summary:
	runtime:      6
	solutions:    1
   	propagations: 4
	failures:     0
	clones:       0
	commits:      0
	peak memory:  5KB
SS_SOLVED

I attached the my test code. If I changed to post method call (line  
58-59) with the rel constraint (line 60), the result become the  
expected: Gecode was able to prove the equality. I also tried with a  
Boolean Exp
	    BExpr expression = new BExpr(new Expr(new  
Expr(space.variable2).minus(space.variable1)), IRT_EQ,  
0,IntConLevel.ICL_DOM);
	    post(space, expression);
	    //rel(space, space.variable1, IRT_EQ, space.variable2,  
IntConLevel.ICL_DOM);

I used Java 1.6 in a Windows XP 32 bit system, in Eclipse environment.

If you could give me a hint what may I have done wrong, I would be  
very glad. Thank you for your help,
Zoltán Ujhelyi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExprTest.java
Type: application/octet-stream
Size: 1789 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20080825/f15aa733/attachment.obj>
-------------- next part --------------

On 2008.08.23., at 8:56, Guido Tack wrote:

> Hi!
>
> Please let me know if this is more or less what you wanted to use:
>
> BExpr be = new BExpr(new Expr(new  
> Expr(space.var2).minus(space.var1)), IRT_EQ, 0, ICL_DOM);
>
> The ICL argument is now part of the BExpr, so it means that the  
> linear constraint inside is propagated with ICL_DOM.  I hope that's  
> what you need.  It will be available in Gecode/J 2.2.0 (very  
> probably next week).
>
> Cheers,
> 	Guido
>
> Ujhelyi Zoltan wrote:
>
>> Hello,
>>
>> thank you for your reply.
>>
>> I understand the problem stated here, but I would like to ask whether
>> there is a solution to add a constraint like that to a Boolean
>> Expression with the domain consistent propagation (ICL_DOM).
>>
>> I did not found any possibilities for that looking in the Gecode/J
>> API, but it would help a lot for our project.
>>
>> Thank you,
>> Ujhelyi Zoltán
>> On 2008.08.11., at 11:34, Guido Tack wrote:
>>
>>> Could you please post to the mailing list? Thanks. Guido
>>>
>>> Am 11.08.2008 um 11:22 schrieb Ujhelyi Zoltan:
>>>
>>>> Hello,
>>>>
>>>> thank you for your reply.
>>>>
>>>> I understand the problem stated here, but I would like to ask
>>>> whether there is a solution to add a constraint like that to a
>>>> Boolen Expression with the domain consistent propagation (ICL_DOM).
>>>>
>>>> I did not found any possibilities for that looking in the Gecode/J
>>>> API, but it would help a lot for our project.
>>>> Thank you,
>>>> Zoltán Ujhelyi
>>>> On 2008.08.11., at 9:03, Guido Tack wrote:
>>>>
>>>>> Hi.
>>>>>
>>>>> As you've already found out, you have to use domain consistent
>>>>> propagation (ICL_DOM) to get the result you want.  You should be
>>>>> able to use post(space, new Expr(space.variable1), IRT_EQ, new
>>>>> Expr(space.variable2), ICL_DOM) to get the desired result.  I'm
>>>>> not 100% sure, but I think your solution that uses e=variable1-
>>>>> variable2, e=0 doesn't work because only the e=0 is propagated to
>>>>> domain consistency, while e=variable1-variable2 still only
>>>>> achieves bounds consistency.
>>>>>
>>>>> Cheers,
>>>>> 	Guido
>>>>>
>>>>> Ujhelyi Zoltan wrote:
>>>>>
>>>>>> Hello again,
>>>>>>
>>>>>> I have been experimenting with the questions raised in my
>>>>>> previous mail.
>>>>>>
>>>>>> I created a small Gecode space to be able to test the problem  
>>>>>> in a
>>>>>> smaller scale, where I did use two variables (variable1,  
>>>>>> variable2,
>>>>>> both IntVars with the domain {0,5}) and three constraints:
>>>>>> variable1
>>>>>> equals variable2, and variable2 cannot have the values 2 and 4.
>>>>>>
>>>>>> In all of my tests the latter two constraints are described like
>>>>>> that:
>>>>>>
>>>>>> post(space, new BExpr(space.variable1, IRT_NQ, 2));
>>>>>> post(space, new BExpr(space.variable1, IRT_NQ, 4));
>>>>>>
>>>>>> For the third constraint I had several tries. When I was using  
>>>>>> the
>>>>>> rel() clause to write the constraint, I got the expected result:
>>>>>>
>>>>>> Variable #1: {0..1,3,5}
>>>>>> Variable #2: {0..1,3,5}
>>>>>>
>>>>>> But when using a similar construct I would like to use in the
>>>>>> static
>>>>>> verifier, I got no result for the second variable, it can has all
>>>>>> values from it's domain.
>>>>>>
>>>>>> post(space, new BExpr(space.variable1, IRT_EQ, space.variable2));
>>>>>>
>>>>>> Reading about different propagators, I have been able to get the
>>>>>> expected result with the use of the ICL_DOM propagator, but only
>>>>>> if I
>>>>>> was posting the constraint directly, like that:
>>>>>>
>>>>>> post(space, new Expr(space.variable1), IRT_EQ, new
>>>>>> Expr(space.variable2),org.gecode.GecodeEnumConstants.ICL_DOM);
>>>>>>
>>>>>> But if I tried to translate the a BExprs to that form, I did not
>>>>>> succeed:
>>>>>>
>>>>>> 	    Expr expression = new Expr(new
>>>>>> Expr(space.variable2).minus(space.variable1));
>>>>>> 	    post(space, new Expr(expression), IRT_EQ, 0,
>>>>>> org.gecode.GecodeEnumConstants.ICL_DOM);
>>>>>>
>>>>>> Can you tell me a way how to enable this strong ICL_DOM  
>>>>>> propagators
>>>>>> meanwhile using the BExpr form, if it is possible? It would help
>>>>>> our
>>>>>> project a lot, it would simplify it's code.
>>>>>>
>>>>>> Thank you for your help,
>>>>>> Zoltán Ujhelyi
>>>>>> On 2008.08.09., at 18:30, Ujhelyi Zoltan wrote:
>>>>>>
>>>>>>> Hello all,
>>>>>>>
>>>>>>> we are currently trying to build a static checker system on  
>>>>>>> top of
>>>>>>> Gecode/J 2.1.1. (in an Eclipse environment), and we have found  
>>>>>>> an
>>>>>>> interesting case.
>>>>>>>
>>>>>>> In order to allow us greater flexibility we try to use the
>>>>>>> Expression
>>>>>>> API (it allows us to build constraints in a hierarchical  
>>>>>>> manner).
>>>>>>>
>>>>>>> I was testing the implementation, and found an interesting final
>>>>>>> result: there were to IntVars, which were supposed to be the
>>>>>>> same, did
>>>>>>> not have the same final ranges: one of them had {2,4}, but the
>>>>>>> other
>>>>>>> had {2,3,4}. I tried to trace back the code to look whether the
>>>>>>> constraints were wrong or not, and found the following  
>>>>>>> expression
>>>>>>> building term:
>>>>>>>
>>>>>>> BExpr expression = new BExpr(new Expr(variable1),relation, new
>>>>>>> Expr(variable2));
>>>>>>>
>>>>>>> Tracing the variables variable1 was a new variable, it hadn't  
>>>>>>> been
>>>>>>> constrained yet, while variable2's domain had been limited to  
>>>>>>> the
>>>>>>> values 2 and 4 (and they were the variables mentioned before in
>>>>>>> this
>>>>>>> letter), while the relation had the value IRT_EQ.
>>>>>>>
>>>>>>> I tried a post of the expression right after it's construction
>>>>>>> to see
>>>>>>> whether it helps or not:
>>>>>>> org.gecode.Gecode.post(space, expression);
>>>>>>>
>>>>>>> It did not solve the problem, but when I replaced the post
>>>>>>> method to
>>>>>>> the following rel call, the constraint handling was working as I
>>>>>>> expected it before.
>>>>>>>
>>>>>>> rel(space, variable1, IntRelType.IRT_EQ, variable2);
>>>>>>>
>>>>>>> I would like to know, whether this phenomenon is the intentional
>>>>>>> (maybe I do not understand something under the hood), or not.
>>>>>>> And if
>>>>>>> you could tell me a way to avoid it, I would be very glad.
>>>>>>>
>>>>>>> Thank you very much in advance for your help,
>>>>>>> Zoltán Ujhelyi
>>>>>>> _______________________________________________
>>>>>>> Gecode users mailing list
>>>>>>> users at gecode.org
>>>>>>> https://www.gecode.org/mailman/listinfo/gecode-users
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Gecode users mailing list
>>>>>> users at gecode.org
>>>>>> https://www.gecode.org/mailman/listinfo/gecode-users
>>>>>
>>>>
>>>
>>
>>
>> _______________________________________________
>> Gecode users mailing list
>> users at gecode.org
>> https://www.gecode.org/mailman/listinfo/gecode-users
>



More information about the gecode-users mailing list