[gecode-users] How to create a text-based interface to Gecode?

Grégoire Dooms dooms at info.ucl.ac.be
Fri Apr 7 16:09:25 CEST 2006


Giuseppe Di Guglielmo wrote:
> I need to pass runtime to a constraint solver ( Gecode :P ) some constraints
> as string and retrieve the possible results. I mean something like that:
>
> if (MY_MODULE.solve("X>=2 & Y<23") == SUCCESS) {
>    cout << MY_MODULE.retrieve("X") << endl;
>    cout << MY_MODULE.retrieve("Y") << endl;
> }
>
> In MY_MODULE I could use Gecode... but how? Can you post some small examples
> of Gecode use with constraints like the above one? 
>   
The constraints you are referring to are expressed the following way in 
Gecode:
rel(this, X, IRT_GE, 2);
rel(this, Y, IRT_LE, 23);

As Guido said, you will need to parse the string to convert it to 
constraint calls like the ones above.
For a complete list of all constraint on integers look at:
http://www.gecode.org/gecode-doc-latest/int_8hh.html

For how to express then solve a problem, look at the examples files on 
this page:
http://www.gecode.org/gecode-doc-latest/dir__2Ftmp_2Fbuild_2D1_2E0_2E1_2Fgecode_2Fexamples_2F.html

Hope this helps,
--
Grégoire





More information about the gecode-users mailing list