For more complicated problems you might want to change the output more
drastically. In this case you have to write and use your own
visualizers, which could naturally be problem specific, not like
fdbg_show/2
and fdbg_label_show/3
. As we described
earlier, currently there are two types of visualizers:
MyGlobalVisualizer([+Arg1, +Arg2, ...] +Constraint, +Actions)
This visualizer is passed in the constraint_hook
option. It must
have at least two arguments, these are the following:
Other arguments can be used for any purpose, for example to select the verbosity level of the visualizer. This way you don't have to modify your code if you would like to see less or more information. Note however, that the two obligatory arguments must appear at the end of the argument list.
When passing as an option to fdbg_on/1
, only the optional
arguments have to be specified; the two mandatory arguments
should be omitted. See FDBG Debugging Global Constraints for an
example.
MyLabelingVisualizer([+Arg1, +Arg2, ...] +Event, +ID, +Var)
This visualizer is passed in the labeling_hook
option. It must
have at least three arguments, these are the following:
library(clpfd)
's labeling
predicates (in this case, simply print it—FDBG will know how to
handle it) or by you; see FDBG Annotation.
The failure of a visualizer is ignored and multiple choices are cut by FDBG. Exceptions, on the other hand, are not caught.
FDBG provides several predicates to ease the work of the visualizer writers. These predicates are the following:
fdbg_annotate(
+Term0,
-Term,
-Variables)
fdbg_annotate(
+Term0,
+Actions,
-Term,
-Variables)
fdvar(Name, Var, FDSet)
fdbg_legend(
+Vars)
fdvar/3
compound terms returned by fdbg_annotate/[3,4]
.
fdbg_legend(
+Vars,
+Actions)