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

Guido Tack tack at ps.uni-sb.de
Fri Apr 7 17:38:32 CEST 2006


Forwarding a message from Giuseppe Di Guglielmo:
> Suppose I have the parser, can I dinamically invoke gecode to create
variables and post the
> constraints?

Yes, you can. Suppose you know you will need n variables, and you have a
mapping from variable identifiers to integers. You create a new space.
Then you just dynamically create a VarArray of size n. For each constraint
that you parsed, you call its corresponding post function. E.g., if you
had a constraint "X >= Y", and you know X is variable iX and Y is variable
iY, you dynamically call something like
rel(space, vars[iX], IRT_GQ, vars[iY]);

As you can reference any variable through the array, and all the post
functions (like rel, linear, distinct etc.) take the space as their first
argument, all this is completely dynamic. In fact, this is a crucial
feature if you want to hook Gecode up to other programming systems.
There's an interface for Alice and one for Java that use Gecode
"dynamically", and people are working on Python and Mozart interfaces as
well.

Cheers,
   Guido

-- 
Guido Tack
http://www.ps.uni-sb.de/~tack




-- 
Guido Tack
http://www.ps.uni-sb.de/~tack






More information about the gecode-users mailing list