From: Mart Lubbers Date: Tue, 11 Nov 2014 11:29:40 +0000 (+0100) Subject: update' X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=1aa8c87aefb35662e082cccb3498ea0ef4faa45f;p=ker1415-1.git update' --- diff --git a/report/Makefile b/report/Makefile index c61ac75..7e10403 100644 --- a/report/Makefile +++ b/report/Makefile @@ -1,6 +1,6 @@ all: - pdflatex report.tex - pdflatex report.tex + pdflatex -shell-escape report.tex + pdflatex -shell-escape report.tex clean: - rm -vf *.aux *.log *.pdf *.toc + rm -vf *.aux *.log *.pdf *.toc *.pyg diff --git a/report/ass1.tex b/report/ass1.tex index a495533..e08ff45 100644 --- a/report/ass1.tex +++ b/report/ass1.tex @@ -10,66 +10,70 @@ We use the functions $agent(X, S_i), crate(cratename, X, S_i)$ and $target(cratename, X)$ to easily represent the information. \item{Q3}\\ - \begin{lstlisting}[language=prolog] -connected(loc1-1, loc2-1, north), -connected(loc1-1, loc1-2, east), -connected(loc1-2, loc2-2, north), -connected(loc1-2, loc1-3, east), -connected(loc1-3, loc2-3, north), -connected(loc1-3, loc1-4, east), -connected(loc1-4, loc2-4, north), - -connected(loc2-1, loc3-1, north), -connected(loc2-1, loc2-2, east), -connected(loc2-2, loc3-2, north), -connected(loc2-2, loc2-3, east), -connected(loc2-3, loc3-3, north), -connected(loc2-3, loc2-4, east), - -connected(loc3-1, loc3-2, north), -connected(loc3-2, loc3-3, north), - -(connected(X, Y, east); \+connected(Y, X, west)), -(connected(X, Y, north); \+connected(Y, X, south)), - -crate(crate-c, loc2-1, s), -crate(crate-b, loc2-2, s), -crate(crate-a, loc2-3, s), - -target(crate-a, loc1-1), -target(crate-b, loc1-3), -target(crate-c, loc1-2), -agent(loc3-2, s).$ - \end{lstlisting} \item{Q4}\\ - \begin{lstlisting}[language=prolog] -target(X, Y), crate(X, Y, s). - \end{lstlisting} + \end{itemize} \subsubsection{Task 2: Actions} \begin{itemize} \item{Q5}\\ -$Poss(move(x, y), s) \equiv \neg(crate(x, y, s)) \wedge connected(x, y, _)$ + \begin{equation} + \begin{split} + Poss(move(x, y), s) \equiv &\\ + & (\exists z: connected(x, y, z)) \wedge\\ + & \neg(crate(x, y, s)) \wedge + \end{split} + \end{equation} + \item{Q6}\\ -$Poss(push(x, d), s) \equiv agent(x, s) \wedge (\exists c,z: crate(c, z, s) -\wedge connected(x, z, d) \wedge (\exists y: connected(z, y, d) \wedge \neg -(\exists a: crate(a, z, s))))$ + $Poss(push(x, y), s) \equiv\\ + agent(x, s) \wedge\\ + (\exists z: + connected(x, z, y) \wedge + (\exists \gamma: crate(\gamma, z, s)) + \wedge\\ + (\exists \alpha: + connected(z, \alpha, y) \wedge + \neg (\exists \beta: crate(\beta, \alpha, s))))$ \item{Q7}\\ -$connected(x, y, d) \rightarrow agent(y, do(move(x, y), s))\\ -connected(x, y, d) \rightarrow agent(y, do(push(x, d), s))\\ -connected(x, y, d) \wedge connected(y, z, d) \rightarrow - crate(c, z, do(push(x, d), s))$ + $agent(x, result(z, s)) \rightarrow\\ + (\exists y: z = move(y, x)) \vee\\ + (\exists \alpha: + z = push(\beta, \alpha) \wedge + connected(\beta, x, \alpha)) \vee\\ + (\exists \epsilon, \gamma: + not(z = move(x, \epsilon)) \wedge + not(z = push(x, \gamma)) \wedge + agent(x, s))\\ + crate(x, y, result(A, s)) \rightarrow\\ + (\exists z,alpha: + A = push(z, \alpha), + (\exists \beta: + connected(z, \beta, \alpha), + connected(\beta, y, \alpha), + crate(x, \beta, s) + ) + ) \vee\\ + (\exists z,\alpha: + not(A = push(z, \alpha)), + connected(z, y, \alpha), + crate(x, y, s) + ) + $ \end{itemize} \subsection{Part 2: Implementation} \subsubsection{Task 3: Translate Axioms} -\lstinputlisting[title={domaintask1.pl},language=prolog]{./src/domaintask1.pl} +The only optimization added to the file is the reverse move optimization, +disallowing the agent to reverse a move immediatly. +\inputminted{prolog}{./src/domaintask1.pl} \subsubsection{Task 4: The Planning Problem in Figure 1} -\lstinputlisting[title={instancetask1.pl},language=prolog]{./src/instancetask1.pl} +\inputminted{prolog}{./src/instancetask4.pl} \subsubsection{Task 5: Crates go to Any Goal Location} +\inputminted{prolog}{./src/instancetask5.pl} + \subsubsection{Task 6: Inverse Problem} \subsection{Part 3: Extending the domain} diff --git a/report/report.tex b/report/report.tex index 93cdcd2..33d7304 100644 --- a/report/report.tex +++ b/report/report.tex @@ -6,11 +6,9 @@ \usepackage{amsmath} \usepackage{amssymb} \usepackage{listings} +\usepackage{minted} -\author{ - Caspar Safarlou (s4205456)\\ - Mart Lubbers (s4109503) -} +\author{ Caspar Safarlou\and Mart Lubbers } \title{Knowledge Representation and Reasoning.\\Assignment 1} \date{\today} diff --git a/report/src/domaintask1.pl b/report/src/domaintask1.pl index 20f6593..f99e05a 100644 --- a/report/src/domaintask1.pl +++ b/report/src/domaintask1.pl @@ -10,7 +10,8 @@ primitive_action(push(_, _)). poss(move(From, To), S) :- agent(From, S), connected(From, To, _), - not(crate(_, To, S)). + not(crate(_, To, S)), + not(visited(To, S)). poss(push(From, Direction), S) :- agent(From, S), @@ -20,6 +21,9 @@ poss(push(From, Direction), S) :- not(crate(_, CrateTarget, S)). % --- Successor state axioms ------------------------------------------ +visited(Plek, result(A, _)) :- + A = move(Plek, _). + agent(AgentPlek, result(A, S)) :- A = move(_, AgentPlek); A = push(OudeAgentPlek, Richting), diff --git a/report/src/domaintask4.pl b/report/src/domaintask4.pl index cdbcfe6..f99e05a 100644 --- a/report/src/domaintask4.pl +++ b/report/src/domaintask4.pl @@ -10,7 +10,9 @@ primitive_action(push(_, _)). poss(move(From, To), S) :- agent(From, S), connected(From, To, _), - not(crate(_, To, S)). + not(crate(_, To, S)), + not(visited(To, S)). + poss(push(From, Direction), S) :- agent(From, S), connected(From, CrateLocation, Direction), @@ -19,6 +21,9 @@ poss(push(From, Direction), S) :- not(crate(_, CrateTarget, S)). % --- Successor state axioms ------------------------------------------ +visited(Plek, result(A, _)) :- + A = move(Plek, _). + agent(AgentPlek, result(A, S)) :- A = move(_, AgentPlek); A = push(OudeAgentPlek, Richting), diff --git a/report/src/domaintask5.pl b/report/src/domaintask5.pl index cdbcfe6..f99e05a 100644 --- a/report/src/domaintask5.pl +++ b/report/src/domaintask5.pl @@ -10,7 +10,9 @@ primitive_action(push(_, _)). poss(move(From, To), S) :- agent(From, S), connected(From, To, _), - not(crate(_, To, S)). + not(crate(_, To, S)), + not(visited(To, S)). + poss(push(From, Direction), S) :- agent(From, S), connected(From, CrateLocation, Direction), @@ -19,6 +21,9 @@ poss(push(From, Direction), S) :- not(crate(_, CrateTarget, S)). % --- Successor state axioms ------------------------------------------ +visited(Plek, result(A, _)) :- + A = move(Plek, _). + agent(AgentPlek, result(A, S)) :- A = move(_, AgentPlek); A = push(OudeAgentPlek, Richting), diff --git a/report/src/instancetask1.pl b/report/src/instancetask1.pl index a7b5b46..e555fb0 100644 --- a/report/src/instancetask1.pl +++ b/report/src/instancetask1.pl @@ -19,8 +19,8 @@ connected(loc22, loc23, north). connected(loc23, loc33, east). connected(loc23, loc24, north). -connected(loc31, loc32, east). -connected(loc32, loc33, east). +connected(loc31, loc32, north). +connected(loc32, loc33, north). % The other way around, west and south connected(loc21, loc11, west). @@ -38,11 +38,8 @@ connected(loc23, loc22, south). connected(loc33, loc23, west). connected(loc24, loc23, south). -connected(loc32, loc31, west). -connected(loc33, loc32, west). - -%connected(X, Y, east) :- connected(Y, X, west). -%connected(X, Y, north) :- connected(Y, X, south). +connected(loc32, loc31, south). +connected(loc33, loc32, south). crate(cratec, loc21, s0). crate(crateb, loc22, s0). @@ -56,8 +53,5 @@ agent(loc32, s0). % --- Goal condition that the planner will try to reach --------------- goal(S) :- crate(cratea, Targeta, S), target(cratea, Targeta), - crate(crateb, Targetb, S), target(crateb, Targetb), + crate(crateb, Targetb, S), target(crateb, Targetb). crate(cratec, Targetc, S), target(cratec, Targetc). -%goal(S) :- crate(cratea, Targeta, S), target(_, Targeta), -% crate(crateb, Targetb, S), target(_, Targetb), -% crate(cratec, Targetc, S), target(_, Targetc). diff --git a/report/src/instancetask4.pl b/report/src/instancetask4.pl index 9fade9c..8412e52 100644 --- a/report/src/instancetask4.pl +++ b/report/src/instancetask4.pl @@ -19,8 +19,8 @@ connected(loc22, loc23, north). connected(loc23, loc33, east). connected(loc23, loc24, north). -connected(loc31, loc32, east). -connected(loc32, loc33, east). +connected(loc31, loc32, north). +connected(loc32, loc33, north). % The other way around, west and south connected(loc21, loc11, west). @@ -38,24 +38,14 @@ connected(loc23, loc22, south). connected(loc33, loc23, west). connected(loc24, loc23, south). -connected(loc32, loc3-1, west). -connected(loc33, loc3-2, west). - -%connected(X, Y, east) :- connected(Y, X, west). -%connected(X, Y, north) :- connected(Y, X, south). +connected(loc32, loc31, south). +connected(loc33, loc32, south). crate(cratec, loc21, s0). crate(crateb, loc22, s0). crate(cratea, loc23, s0). -target(cratea, loc12). -target(crateb, loc13). -target(cratec, loc11). - agent(loc32, s0). % --- Goal condition that the planner will try to reach --------------- -%goal(S) :- forall(crate(Crate, Loc, S), target(Crate, Loc)). -goal(S) :- crate(cratea, Targeta, S), target(cratea, Targeta), - crate(crateb, Targetb, S), target(crateb, Targetb), - crate(cratec, Targetc, S), target(cratec, Targetc). +goal(S) :- crate(cratea, loc12, S), crate(crateb, loc13, S), crate(cratec, loc11, S). diff --git a/report/src/instancetask5.pl b/report/src/instancetask5.pl index 81cc483..e602ef7 100644 --- a/report/src/instancetask5.pl +++ b/report/src/instancetask5.pl @@ -19,8 +19,8 @@ connected(loc22, loc23, north). connected(loc23, loc33, east). connected(loc23, loc24, north). -connected(loc31, loc32, east). -connected(loc32, loc33, east). +connected(loc31, loc32, north). +connected(loc32, loc33, north). % The other way around, west and south connected(loc21, loc11, west). @@ -38,20 +38,18 @@ connected(loc23, loc22, south). connected(loc33, loc23, west). connected(loc24, loc23, south). -connected(loc32, loc3-1, west). -connected(loc33, loc3-2, west). +connected(loc32, loc31, south). +connected(loc33, loc32, south). crate(cratec, loc21, s0). crate(crateb, loc22, s0). crate(cratea, loc23, s0). -target(cratea, loc12). -target(crateb, loc13). -target(cratec, loc11). +target(loc12). +target(loc13). +target(loc11). agent(loc32, s0). % --- Goal condition that the planner will try to reach --------------- -goal(S) :- crate(cratea, Targeta, S), target(_, Targeta), - crate(crateb, Targetb, S), target(_, Targetb), - crate(cratec, Targetc, S), target(_, Targetc). +goal(S) :- crate(_, loc12, S), crate(_, loc13, S), crate(_, loc11, S).