[gecode-users] advice on building interface (with Haskell)

Mikael Zayenz Lagerkvist zayenz at kth.se
Fri Jan 12 22:43:22 CET 2007


HI,

The purpose of the copy function is to allow construction of a copy, a
sort of virtual constructor.

The copy constructor for a Space needs to update it's references to
interesting variables, and construct copies of any other specific data
structures. Without updating the variables, one can not access them in
the copy.

In the Alice bindings to Gecode, all the constructed variables are
collected in variable arrays in a Space akin to your proposed
SimpleSpace, one array per variable type. The AliceML interface can
then reference variables in a specific Space (for example, a solution)
using the index into these arrays. The GeOz project (which aims to
interface Gecode with Mozart) does something similar for managing
variables.

This is probably the best way to manage variables in a simple
interface to Gecode.

The Gecode/J Java wrapper, as a contrast, uses a more complicated
scheme which allows Java Spaces to implement their own copy-method and
copy-constructor. This is probably overkill for a simple interface to
Gecode

Cheers,
Mikael

On 1/12/07, Jorge Marques Pelizzoni <jpeliz at icmc.usp.br> wrote:
>
>
> Hi, all! I am considering interfacing Haskell with gecode, although I'm
> totally unexperiened with the latter (!). Actually, I have a Mozart/Oz
> background and can see the strong resemblance between the two systems, but
> there are some points that are not quite clear to me. First of all, do you
> think using a simple, fixed subclass of Space instantiating the copy
> methods with something like this:
>
> SimpleSpace(bool share, SimpleSpace &other): Space(share, other) { }
>
> virtual Space* copy(bool share) {
>   return new SimpleSpace(share,*this);
> }
>
> would do the job? I mean: my idea would be to create such objects and
> (indirectly, from Haskell) apply propagator-imposing functions (post,
> etc.) on them. Have you done anything much different for Alice?
>
> My real doubt is: how far one can go with such a naïve copy semantics? I
> often noticed specialized versions of copy in the examples...
>
> Thanks in advance. Cheers,
>
> Jorge M. Pelizzoni
> ICMC - Universidade de São Paulo
>
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>


-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/




More information about the gecode-users mailing list