conjure-cp / conjure

Conjure: The Automated Constraint Modelling Tool
Other
94 stars 20 forks source link

Crash constructing prefixes of sequences. #571

Open pwn1 opened 1 year ago

pwn1 commented 1 year ago

Hi Oz,

Here's a tiny part of a model that constructs a set Valid (intended to be all prefixes of sequences in Subs).

Is the issue that you might have int(0..-1) for the length-0 prefixes?

language ESSENCE 1.3.0

$ Number of subscribers
given nSubs : int(1..)

letting Digit be domain int(0..9)

given Subs : matrix [ int(1..nSubs) ] of sequence of Digit

$  Shame there is no set comprehension. Needs toSet here. 
letting Valid be toSet([ [ s(j) | j : int(0..i) ]  | s <- Subs, i : int(-1..|s|) ])

And this is what happens if you put it into Conjure:

conjure: This should never happen, sorry!

However, it did happen, so it must be a bug. Please report it to us!

Conjure is actively maintained, we will get back to you as soon as possible.
You can help us by providing a minimal failing example.

Also include the repository version for this build: 008667d6a (2023-06-01 09:38:43 +0100)

Issue tracker: http://github.com/conjure-cp/conjure/issues

BUGFAIL at rule_ChooseReprForLocals
domainSizeOf infinite range: 1..

CallStack (from HasCallStack):
  error, called at src/Conjure/Bug.hs:17:15 in conjure-cp-2.5.0-J7nVvZRONHz6Zg6XNQCcrd:Conjure.Bug
  bug, called at src/Conjure/Bug.hs:39:21 in conjure-cp-2.5.0-J7nVvZRONHz6Zg6XNQCcrd:Conjure.Bug
pwn1 commented 1 year ago

Hi Oz, do you think this would be an easy fix or lots of work? @ozgurakgun

ozgurakgun commented 1 year ago

Hi Pete. Hard to know. As far as I can see for the toSet at the top level Conjure tries to create a top level decision variable which is unlikely to be what you want. How do you plan to use Valid in the rest of the model? If you send me a fuller model I can take another look.

pwn1 commented 1 year ago

Thanks Oz

The constraint that uses Valid just says something like "s in Valid -> ...." where s is a sequence decision variable. imagine s is the sequence of digits that someone dialled so far, and if that sequence is not in Valid then they are not going to be able to complete dialling a valid number.

pwn1 commented 1 year ago

Maybe I can avoid making Valid and just check the prefix condition some other way.