% map date to weekday (mon =1, ..., sun = 7); % The tour starts on Monday. weekday(1,1). weekday(D,W) :- D=D1+1, W=W1+1, weekday(D1,W1), W1 < 7. weekday(D,1) :- D=D1+1, weekday(D1,7). % connections with default costs (capitols of the Austrian federal states). conn(brg,ibk,2). conn(ibk,sbg,2). conn(ibk,vie,5). conn(ibk,kla,3). conn(sbg,kla,2). conn(sbg,gra,2). conn(sbg,lin,1). conn(sbg,vie,3). conn(kla,gra,2). conn(lin,stp,1). conn(lin,vie,2). conn(lin,gra,2). conn(gra,vie,2). conn(gra,eis,1). conn(stp,vie,1). conn(eis,vie,1). conn(stp,eis,2). conn(B,A,C) :- conn(A,B,C). city(T) :- conn(T,_,_). % costing: use default cost, if there are no extra costs % cost(A,B,W,C) :- conn(A,B,C), #int(W), 0 < W, W <= 7, not ecost(A,B,W). ecost(A,B,W) :- cost(A,B,W,C), conn(A,B,C1), C != C1. % Some example of an extra cost. cost(stp,eis,2,10). %cost(eis,stp,2,10). % ATTENTION: default costs are symmetric, ecosts are NOT! % The following rule does not suffice to guarantee symetrical % ecosts but caused bogus results: % % ecost(A,B,W) :- ecost(B,A,W).