Points. Points is the list of geometric coordinates associated with the nodes. Each element must have the form p(Id,X,Y), where Id is the node/value numeric integer identifier and X, Y are numeric coordinates. When a valid points list is supplied, the constraint automatically enables convex-hull based pruning on top of the standard Hall-set filtering. This geometric pruning is used unless it is explicitly switched off with geometry(off) (see Options below).
Supported Options are:
How to use. The graph is described by the user-provided facts point/3 (one point(Id,X,Y) fact per node, giving its coordinates) and edge/2 (one edge(From,To) fact per directed arc). The model collects the points, builds one successor variable per node whose domain is the set of out-neighbours, posts the constraint together with circuit/1, and searches for a Hamiltonian circuit. Because a valid points list is passed, convex-hull pruning is active (add geometry(off) to the option list to turn it off):
hcc_test(N, L, SN):-
findall(p(Id,X,Y), point(Id,X,Y), Lnodes),
(var(N) -> length(Lnodes, N) ; true),
length(L, N),
create_var_hcc(L, Lnodes),
hcc(L, Lnodes, _),
circuit(L),
search(L, 0, first_fail, indomain, complete, [backtrack(SN)]).
create_var_hcc([], []):- !.
create_var_hcc([X|L], [p(N,_,_)|LN]):-
concat_string(["Nex",N], Name),
set_var_name(X, Name),
findall(M, edge(N,M), Dom),
X :: Dom,
create_var_hcc(L, LN).
% Basic HCC, no geometry, no path pruning
hcc(Vars)
% HCC with path pruning, no geometry
hcc(Vars, [path(on)])
% Points provided but convex-hull pruning explicitly disabled
hcc(Vars, Points, [geometry(off)])
% Convex-hull pruning (from the points) plus path pruning
hcc(Vars, Points, [path(on)])