CSE505/Assignment2/A/tsp.lp

14 lines
312 B
Plaintext
Raw Permalink Normal View History

2024-03-09 17:30:02 -05:00
#include "data20.lp".
2024-03-09 16:25:30 -05:00
% % Generate
{ cycle(X,Y) : path(X,Y) } = 1 :- node(X).
{ cycle(X,Y) : path(X,Y) } = 1 :- node(Y).
2024-03-09 17:30:02 -05:00
% Define
reached(Y) :- cycle(a,Y).
reached(Y) :- cycle(X,Y), reached(X).
% Test
:- node(Y), not reached(Y).
2024-03-09 16:25:30 -05:00
% Display
#show cycle/2.
% Optimize
2024-03-09 17:30:02 -05:00
#minimize { C,X,Y : cycle(X,Y), edge(X,Y,C) }.