[gecode-users] FlatZinc parser

Guido Tack tack at ps.uni-sb.de
Thu Nov 6 08:03:07 CET 2008


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2436 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20081106/854f326c/attachment.bin>


More information about the gecode-users mailing list