[gecode-users] How do you debug your progam?
Guido Tack
tack at ps.uni-sb.de
Thu Jul 27 22:18:08 CEST 2006
Hi Roberto.
> I'm not referring to the C++ code, but to the set of constraint that
> describe your problem:
> I don't know if my question will be relevant for most of you, anyway,
> I would ask how do you debug your constraint program?
As you have already noticed, debugging constraint programs requires
different tools than debugging C++ programs.
> Of course, from a theoretical point of view, thinking before doing is
> a best-practice, but a bug could always occur and maybe you are not
> able to find it even after a deep analysis.
In many cases, there isn't even a real bug in your model, but it just
doesn't propagate enough and the search space is huge.
> [...]
>
> Any idea where to look?
>
> I would also ask if it is somewhat possible to "follow" the variable
> assignment procedure step-by-step (of course, on very simple example
> with few variables) in order to "visualize" the propagation of
> constraints and the backtracking points.
This is basically what one would use a graphical tool such as the
Mozart Explorer for. You get a visualization of (a part of) the
search tree, and you can click on the nodes and get information about
the state of the search at that point.
We don't have an explorer for Gecode yet, but we have one for our
Java interface Gecode/J. This is not officially released yet, but
quite functional. It has been used for teaching CP courses, and the
documentation and source code are available from the course pages, e.g.:
http://www.imit.kth.se/courses/2G1515/software.html
We are setting up web pages for Gecode/J at
http://www.gecode.org/gecodej
These are pretty preliminary right now, but you can expect to find
more content in a few days.
The downside of using Gecode/J is that you would have to re-model
your problem in Java. This is however not too hard, as the interface
is nearly the same as in C++.
> In other words, I would like to print out all the variable assignment,
> one by one, along with a message saying "Hey, I'm backtracking now!"
> or something like that.
If you just want some debugging output during search, and you don't
want to switch to Java for debugging, you can write your own
instrumented search engine. Take one of the available search engines
as a starting point, and simply add debugging output at the
appropriate places.
For instance, take the file gecode/search/dfs.icc and add some
debugging output to the DfsEngine::explore(void) function - you'll
immediately see the relevant parts.
> Do you think it would be possible (easily) with Gecode?
Gecode offers quite some flexibility, as it is easy to write your own
search engines. After all, something like the Gecode/J explorer is
written completely on top of the existing abstractions for search in
Gecode. I hope we can offer more debugging tools in the future, but
currently we are focusing on other issues.
Hope this helps a bit,
Guido
More information about the gecode-users
mailing list