cell(1..M, 1..N) :- size(M, N).
timeStep(1..T) :- timeLimit(T).

% force start and end locations.
location(A, 1, I, J) :- start(A, I, J).
location(A, T, I, J) :- target(A, I, J), timeLimit(T).

% no teleportation
allowedMove(I, J, I, J) :- cell(I, J).
allowedMove(I, J, I, J+1) :- cell(I, J), cell(I, J+1).
allowedMove(I, J, I, J-1) :- cell(I, J), cell(I, J-1).
allowedMove(I, J, I+1, J) :- cell(I, J), cell(I+1, J).
allowedMove(I, J, I-1, J) :- cell(I, J), cell(I-1, J).

% generate possible locations
1 { location(A, T+1, K, L) : allowedMove(I, J, K, L) } 1 :- location(A, T, I, J), T < MAX, timeLimit(MAX).


% no ubiquity
:- location(A, T, I, J), location(A, T, I', J'), I != I'.
:- location(A, T, I, J), location(A, T, I', J'), J != J'.

% no disappearing
located(A, T) :- location(A, T, I, J).
:- agent(A), timeStep(T), not located(A, T).

% rule out vertex conflicts
:- location(A, T, I, J), blocked(I, J).

% rule out vertex conflicts
:- location(A, T, I, J), location(B, T, I, J), A != B.

% rule out edge conflicts
:- location(A, T, I, J), location(A, T+1, K, L), location(B, T, K, L), location(B, T+1, I, J), A != B.

#show location/4.

Resource created 6 years ago.

file: mapf-smarter.lp


Ian Dunkerley   0 upvotes • 6 years ago • 1 reply

I'm trying to compare the difference between this and the naive encoding ...

I'm trying to compare the difference between this and the naive encoding (the lecture recording ended just before it a...

Back to top

COMP4418 19T3 (Knowledge Representation and Reasoning) is powered by WebCMS3
CRICOS Provider No. 00098G