% Program: Seat arrangement -- version 1 % This version does not use the #domain definition % specify the number of person % to test this program run % lparse -c n=4 seat.lp | smodels % then run with % lparse -c n=3 seat.lp | smodels person(1..n). % specify the number of position position(1..n). % each position has exactly one person 1 {seat(P,S): person(P) } 1 :- position(S). % each person occupies only one seat :- person(P), position(P1), position(P2), neq(P1,P2), seat(P,P1), seat(P,P2). % removing seating arrangement where there is a % pair of 'dislike' persons seating next to % each other :- person(P), person(Q), position(SP), dislike(P, Q), seat(P, SP), P < n, seat(Q, SP+1). :- person(P), person(Q), dislike(P, Q), seat(P, n), seat(Q, 1). :- person(P), person(Q), position(SP), dislike(P, Q), seat(P, SP), SP > 1, seat(Q, SP-1). :- person(P), person(Q), dislike(P, Q), seat(P, 1), seat(Q, n). %% this is where you change the instance dislike(1,2). % the following declarations make the reading of % the stable model easier hide position(P). % hide atoms of the form position(X) from output hide person(P). % hide atoms of the form person(X) from output