The GFD library is an interface for ECLiPSe to Gecode’s finite domain constraint solver. Gecode (www.gecode.org) is an open-source toolkit for developing constraint-based systems in C++, and includes an integer finite domain constraint solver.
This interface provides a high degree of code compatibility with the finite domain portion of the IC library, and to a lesser extent, with the FD library as well. This means that programs originally written for the IC library should run with GFD with little modifications, beyond renaming any explicit reference to the ic family of modules. For example, here is a GFD program for N-Queens:
:- lib(gfd). queens_list(N, Board) :- length(Board, N), Board :: 1..N, (fromto(Board, [Q1|Cols], Cols, []) do ( foreach(Q2, Cols), param(Q1), count(Dist,1,_) do Q2 #\= Q1, Q2 - Q1 #\= Dist, Q1 - Q2 #\= Dist ) ), labeling(Board).
This version of the program is from an example IC version of N-Queens,
with just :- lib(ic)
replaced by :- lib(gfd)
. The
search is done in ECLiPSe, using GFD’s labeling/1
, which essentially
employs no heuristics in selecting the variable (input order) and choice of
value to label the selected variable to (from minimum).