A variant of the traveling salesman problem (visiting every city in a country only once, starting and ending in the same city, and moving between cities using the existing connections) where, in addition, we want to find out the length of the Hamiltonian cycle.
Solutions for this problem using CLP(FD)
and ASP
appear in
(Dovier et al. 2005),
with comparable performance. However, they show that the ASP
encoding is more compact, even if the CLP(FD)
version uses the
library predicate circuit/1
, which does the bulk of the work and
whose code is non-trivial.
We will show that also in this problem, where the ASP
solution is more
compact than that of CLP(FD)
, s(CASP)
is more expressive.
scasp hamiltonian_scasp.pl