CSE505/Assignment2/A/tsp.lp
2024-03-09 17:30:02 -05:00

14 lines
312 B
Plaintext

#include "data20.lp".
% % Generate
{ cycle(X,Y) : path(X,Y) } = 1 :- node(X).
{ cycle(X,Y) : path(X,Y) } = 1 :- node(Y).
% Define
reached(Y) :- cycle(a,Y).
reached(Y) :- cycle(X,Y), reached(X).
% Test
:- node(Y), not reached(Y).
% Display
#show cycle/2.
% Optimize
#minimize { C,X,Y : cycle(X,Y), edge(X,Y,C) }.