[gecode-users] Interacting with FlatZincSpaces, or: Gecode/JS bindings

Sebastian Kosch sebastian.kosch at mail.utoronto.ca
Fri Apr 10 16:03:41 CEST 2015


Hi,

I am playing with the idea of building a simple browser interface to
Gecode. I have tweaked the source so that it compiles to a asm.js blob
via emscripten -- notwithstanding the dozens of obvious reasons why
doing this is a dumb idea, I can now solve Flatzinc models in the
browser, and that's pretty cool.

I would like to do more than just input a Flatzinc string, of course,
and build something closer to Gist maybe. So I would like to either

a) write wrapper functions in C++ to interact with the Flatzinc model
after it's been read in. This code would go into the JS blob and allow
me to interact with the space from the browser (e.g. add/remove
variables and constraints, change options, restart searches etc.) -- or:

b) have an easier way of passing Javascript objects directly to Gecode
to manipulate the space.

(a potential option c) might be to integrate the Minizinc parser into
the JS blob, and to create a "proper" space in Gecode directly from
Minizinc instead of compiling to Flatzinc first, and then use a) ... but 
I'd rather not.)

In terms of a), what are my options beyond finding out which of the
variables are part of the optimization? Can I access Flatzinc
annotations on variables somehow? Is there a way to predict which
objects in the space correspond to which of the parts in the "original"
Minizinc model?

In terms of b), it appears that this was planned at some point (see
https://github.com/mattetti/Gecoder/blob/0352cf3b879d2f6764a4da6efe3fb2b1ff1b819c/vendor/gecode/win32/include/gecode/serialization.hh), 

but then dropped. Could I investigate this further, or did you come up
against hard reasons why that's not an option at all?

I hope all of this doesn't sound too crazy or convoluted. I'm looking
forward to your thoughts!

Sebastian





More information about the users mailing list