[gecode-users] extensional constraints with regular expressions

Christian Schulte cschulte at kth.se
Tue Oct 18 12:47:17 CEST 2011


Hi,

Sorry that is your bug and not Gecode's: the argument type to the repetition
operators in Gecode is "unsigned int". You give a negative argument that
then is silently cast to an unsigned int and the SEGFAULT then comes from
just running out of memory.

If you want to be alerted about these kind of implicit casts, please
increase the warning level of the compiler you use.

Cheers
Christian 

--
Christian Schulte, KTH, web.it.kth.se/~cschulte/


-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Kish Shen
Sent: Monday, October 17, 2011 2:09 AM
To: users at gecode.org
Subject: [gecode-users] extensional constraints with regular expressions

Hi,

I have just added support for extensional constraints to ECLiPSe's Gecode
interface, and I started testing the constraint with test cases, and I got a
seg fault when I used a negative number in the repeat count in a regular
expression.

The expression was supplied at the ECLiPSe level, but it should be
equivalent to:


REG r = REG(1)(-1, 3) + *REG(4);
extensional(home, x, r);

The seg fault happened in the call to extensional.

I am using Gecode 3.7.0.

For the following slightly different REG:

REG r = REG(1)(-1) + *REG(4);

the result of the call to extensional is that all the variables in x are 
given the domain 4, I assume from the *REG(4) part of the regular 
expression. Is this correct? To me, the use of a negative number here 
should be equivalent to using 0, i.e. repeat 1 at least -1 times is the 
same as repeating 1 at least 0 times.

I also implemented using DFA for the extensional constraint, but my 
first version of the code had some typo bugs in it that meant some of 
the arguments to create the DFA were not initialised:

int f(fsize);
DFA::Transition t[tsize);
...
DFA d(0, t, f);


The code was supposed to initialise f and t before the DFA d(0, t, f) 
line, so t and f had no valid values. What happen is that Gecode seem to 
go into a loop for the call -- is this because it is failing to find the 
-1 that should be in f?

I understand that the problem is because I did not initialise t and f, 
but is there anyway to avoid a loop, e.g. for an exception to bw raised? 
If the looping is due to the missing -1, would this be a problem, 
because it is probably quite easy for a user to forget to add a 
terminating -1 in their code (this actually would not be a problem for 
my code, as the interface code insert a -1, so the user do not have to)

Cheers,

Kish
-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.

_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users




More information about the users mailing list