[gecode-users] FlatZinc parser

Morten Boysen boysen at itu.dk
Thu Nov 6 21:37:28 CET 2008


Hi Guido

Thank you very much for the reply and the hints on where to look. I do 
have another question to you and the other developers of Gecode: What is 
the best environment to develop for Gecode in?

I have so far tried to use Visual Studio with the binary installation. 
This works well if I am simply using the interface as provided by the 
headers and dlls in the code.

However, I believe that what I am trying now with the FlatZinc parser is 
a bit unstandard and working with the FlatZinc parser code from within 
Visual Studio (this includes building the code) has proven to be quite a 
hassle. I have looked at the mailing list archive and I can see that 
Christian Schulte uses Windows to develop, but the build is performed 
using the GNU toolchain. What editors do you use, and how do you debug 
when you build using the GNU toolchain?

Do you have any recommendations on what is easiest if we are planning to 
modify the FlatZinc to Gecode program?

I apologize if this question has been answered before.

Kind regards
Morten Boysen

Guido Tack skrev:
> Hi!
> 
> Morten Boysen wrote:
>> 1) How do I as simple as possible create a FlatZincGecode instance from
>> a FlatZinc file? No propagation should occur or anything. The variables
>> should just simply be added to the FlatZincGecode instance along with
>> the constraints. This FlatZincGecode instance will then work as the
>> initial model.
> 
> Look at main.cc.  It uses the (probably not very intuitively named) 
> function solve from the flatzinc.hh header:
> 
> FZPrinter p;
> FlatZincGecode* fg = FlatZinc::solve(filename, p);
> 
>> 2) Is there a way to get the original name of a variable in the
>> FlatZincGecode instance and vice versa (I took a look at the Registry
>> class and it looked like it might have something to do with it, but I am
>> not sure).
> 
> The names are currently only represented indirectly as strings in the 
> FZPrinter, since they are only needed for output.  If you need the names 
> more explicitly, you'll have to transfer the intvarTable, boolvarTable, 
> and setvarTable from the FParseParm object (usually called pp in the 
> parser) to the FlatZincGecode object.  The tables map names to the 
> indices in the *VarArrays in FlatZincGecode.  In flazinc.yxx, there's a 
> function initfg that creates all the variables.  In that function, you 
> could create additional mappings in FlatZincGecode for the names.
> 
>> 3) What is the easiest way to read the entire domain of an integer
>> variable (not just the currently valid values, but also all the invalid
>> ones). This includes cases where the domain is not a range?
> 
> That information is not maintained (as the solver never needs it 
> anywhere).  The closest you can get is the domain specification from the 
> FlatZinc, which might already be smaller than the domain in the original 
> MiniZinc.  Again, you'd have to memorize that somewhere in 
> FlatZincGecode, this should be possible in the newIntVar, newBoolVar, 
> newSetVar functions.
> 
>> 4) Is there a way to read only the values of variables that has support,
>> and the values that have no support?
> 
> Inconsistent values are removed from the domains.  The only way to do 
> this would be to store the original domain, and compute the difference 
> (which you can do using our iterators).
> 
> Cheers,
>     Guido
> 





More information about the gecode-users mailing list