[gecode-users] Populating a parsed FlatZinc model with data programmatically.

Guido Tack tack at gecode.org
Thu Aug 22 05:36:50 CEST 2013


On 22/08/2013, at 12:50 PM, Hugh Ferguson <hugh.ferguson at nzqa.govt.nz> wrote:

> I have looked through the guides, the API documentation, and the examples,
> and I haven't been able to find an answer to this question. Apologies if I
> have missed something obvious.
> 
> I have to build a system capable of solving literally hundreds of different
> but similar problems. In some cases, the peak volume is fairly high - on the
> order of 50K instances per day. Fortunately none of the instances will be
> large - less than 100 variables.
> 
> I am investigating defining the problems in FlatZinc files (constraints
> only), but programmatically populating the parsed models with data. I want
> to avoid the overhead of generating and then parsing a complete FlatZinc
> file (constraints + data) for each instance. 
> 
> Having looked at the documentation, with my limited knowledge of C++, I get
> the impression that it is possible to do this. Can anybody confirm my
> impression?

You would save the cost of generating the FlatZinc, but not the parsing time.  You can only parse FlatZinc that has all parameters instantiated, so you always have to pass the complete FlatZinc model to the parser.

The idea to use FlatZinc to communicate through the Java/C++ interface makes a lot of sense (if that's what you're planning to do), at least you don't have to worry at all about how to represent variables etc. And you don't have to write the models to files, the Gecode FlatZinc parser can read them from a string.  You can also get access to the solutions directly without printing them, so you don't have to parse the FlatZinc output again in Java.

Cheers,
Guido




More information about the users mailing list