update
authorMart Lubbers <mart@martlubbers.net>
Wed, 12 Nov 2014 08:15:40 +0000 (09:15 +0100)
committerMart Lubbers <mart@martlubbers.net>
Wed, 12 Nov 2014 08:15:40 +0000 (09:15 +0100)
report/ass1.tex
report/report.tex
report/src/domaintask7.pl [new file with mode: 0644]
report/src/instancetask7.pl [new file with mode: 0644]
report/src/planner.pl

index 19e16ab..7826f14 100644 (file)
                crate(cratea, loc12, s) \wedge
                crate(crateb, loc13, s) \wedge
                crate(cratec, loc11, s)$
-
-
 \end{itemize}
 
 \subsubsection{Task 2: Actions}
 \begin{itemize}
        \item{Q5}\\
-               $Poss(move(x, y), s) \equiv \\
-               (\exists z: connected(x, y, z)) \wedge\\
-               \neg(crate(x, y, s))$
+               $\begin{array}{rl}
+                       Poss(move(x, y), s) & \equiv \\
+                               & (\exists z: connected(x, y, z)) \wedge\\
+                               & \neg(crate(x, y, s))
+               \end{array}$
        \item{Q6}\\
-               $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
-                               (\nexists \beta: crate(\beta, \alpha, s))))$
+               $\begin{array}{rl}
+                       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
+                                               (\nexists \beta: crate(\beta, \alpha, s))
+                                       )
+                               )
+               \end{array}$
        \item{Q7}\\
-               $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:
-                               z \neq move(x, \epsilon) \wedge
-                               z \neq 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)
+               $\begin{array}{rl}
+                       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:
+                                       z \neq move(x, \epsilon) \wedge
+                                       z \neq 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:
+                                       A \neq push(z, \alpha)\wedge
+                                       connected(z, y, \alpha)\wedge
+                                       crate(x, y, s)
                                )
-                       ) \vee\\
-                       (\exists z,\alpha:
-                               A \neq push(z, \alpha)\wedge
-                               connected(z, y, \alpha)\wedge
-                               crate(x, y, s)
-                       )
-               $
+               \end{array}$
 \end{itemize}
 
 \subsection{Part 2: Implementation}
 \subsubsection{Task 3: Translate Axioms}
 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}
+\begin{listing}[H]
+       \caption{Domain description task 1}
+       \prologcode{./src/domaintask1.pl}
+\end{listing}
 
 \subsubsection{Task 4: The Planning Problem in Figure 1}
-\inputminted{prolog}{./src/instancetask4.pl}
+\begin{listing}[H]
+       \caption{Instance description task 4}
+       \prologcode{./src/instancetask4.pl}
+\end{listing}
 
 \subsubsection{Task 5: Crates go to Any Goal Location}
-\inputminted{prolog}{./src/instancetask5.pl}
+\begin{listing}[H]
+       \caption{Instance description task 5}
+       \prologcode{./src/instancetask5.pl}
+\end{listing}
 
 \subsubsection{Task 6: Inverse Problem}
 
 \subsection{Part 3: Extending the domain}
+\subsubsection{Task 7: Unlocking the Crates}
+\begin{listing}[H]
+       \caption{Instance description task 7}
+       \prologcode{./src/instancetask7.pl}
+\end{listing}
+\begin{listing}[H]
+       \caption{Domain description task 7}
+       \prologcode{./src/domaintask7.pl}
+\end{listing}
 
 \subsection{Part 4: General questions}
 \subsubsection{Task 10: Sitcalc expressivity}
index 33d7304..6324f25 100644 (file)
@@ -1,22 +1,40 @@
 \documentclass[titlepage,a4paper]{article}
 
 \usepackage{fullpage}
+\usepackage{floatrow}
 \usepackage{lipsum}
 \usepackage{enumerate}
 \usepackage{amsmath}
 \usepackage{amssymb}
-\usepackage{listings}
 \usepackage{minted}
 
 \author{ Caspar Safarlou\and Mart Lubbers }
 \title{Knowledge Representation and Reasoning.\\Assignment 1}
 \date{\today}
 
-\lstset{
-       basicstyle=\ttfamily\footnotesize,
-}
-
 \everymath{\displaystyle}
+\floatsetup[listing]{style=Plaintop}
+
+\definecolor{mintedbackground}{rgb}{0.95,0.95,0.95}
+\newmintedfile[prologcode]{prolog}{
+       bgcolor=mintedbackground,
+       fontfamily=tt,
+       linenos=true,
+       numberblanklines=true,
+       numbersep=10pt,
+       numbersep=5pt,
+       gobble=0,
+       frame=leftline,
+       framerule=0.4pt,
+       framesep=2mm,
+       funcnamehighlighting=true,
+       tabsize=4,
+       obeytabs=false,
+       mathescape=false
+       showspaces=false,
+       showtabs =false,
+       texcl=false,
+}
 
 \begin{document}
 \maketitle
diff --git a/report/src/domaintask7.pl b/report/src/domaintask7.pl
new file mode 100644 (file)
index 0000000..f3a676a
--- /dev/null
@@ -0,0 +1,52 @@
+% ------------------------- Domain Definition -------------------------
+% --- Cross-file definitions ------------------------------------------
+:- multifile connected/3, crate/4, agent/2, key/3.
+
+% --- Primitive control actions ---------------------------------------
+primitive_action(move(_, _)).
+primitive_action(push(_, _)).
+primitive_action(pickup(_)).
+
+% --- Precondition for primitive actions ------------------------------
+poss(move(From, To), S) :-
+       agent(From, S),
+       connected(From, To, _),
+       not(crate(_, _, To, S)).
+
+poss(push(From, Direction), S) :-
+       agent(From, S),
+       connected(From, CrateLocation, Direction),
+       crate(_, Key, CrateLocation, S),
+       keyinbag(Key, S),
+       connected(CrateLocation, CrateTarget, Direction),
+       not(crate(_, _, CrateTarget, S)).
+
+poss(pickup(CurrentLocation), S) :-
+       agent(CurrentLocation, S),
+       key(_, CurrentLocation, S).
+
+% --- Successor state axioms ------------------------------------------
+agent(AgentPlek, result(A, S)) :-
+       A = move(_, AgentPlek);
+       A = push(OudeAgentPlek, Richting),
+               connected(OudeAgentPlek, AgentPlek, Richting);
+       not(A = move(AgentPlek, _)), not(A = push(AgentPlek, _)),
+               agent(AgentPlek, S).
+       
+crate(Krat, _, Kratplek, result(A, S)) :-
+       A = push(AgentPlek, Richting), 
+               connected(AgentPlek, OudeKratPlek, Richting),
+               connected(OudeKratPlek, Kratplek, Richting),
+               crate(Krat, _, OudeKratPlek, S);
+       not(A = push(AgentPlek2, Richting2)),
+               connected(AgentPlek2, Kratplek, Richting2),
+               crate(Krat, _, Kratplek, S).
+
+key(Key, Location, result(A, S)) :-
+       not(A = pickup(Location)), key(Key, Location, S).
+
+keyinbag(Key, result(A, S)) :-
+       agent(CurrentLocation, S),
+               A = pickup(CurrentLocation),
+               key(Key, CurrentLocation, S);
+       keyinbag(Key, S).
diff --git a/report/src/instancetask7.pl b/report/src/instancetask7.pl
new file mode 100644 (file)
index 0000000..6b89a70
--- /dev/null
@@ -0,0 +1,56 @@
+% ------------------------- Problem Instance --------------------------
+% --- Load domain definitions from an external file -------------------
+:- [domaintask7].
+
+% --- Definition of the initial state ---------------------------------
+connected(loc11, loc21, east).
+connected(loc11, loc12, north).
+connected(loc12, loc22, east).
+connected(loc12, loc13, north).
+connected(loc13, loc23, east).
+connected(loc13, loc14, north).
+connected(loc14, loc24, east).
+
+connected(loc21, loc31, east).
+connected(loc21, loc22, north).
+connected(loc22, loc32, east).
+connected(loc22, loc23, north).
+connected(loc23, loc33, east).
+connected(loc23, loc24, north).
+
+connected(loc31, loc32, north).
+connected(loc32, loc33, north).
+
+connected(loc21, loc11, west).
+connected(loc12, loc11, south).
+connected(loc22, loc12, west).
+connected(loc13, loc12, south).
+connected(loc23, loc13, west).
+connected(loc14, loc13, south).
+connected(loc24, loc14, west).
+
+connected(loc31, loc21, west).
+connected(loc22, loc21, south).
+connected(loc32, loc22, west).
+connected(loc23, loc22, south).
+connected(loc33, loc23, west).
+connected(loc24, loc23, south).
+
+connected(loc32, loc31, south).
+connected(loc33, loc32, south).
+
+crate(cratea, keya, loc23, s0).
+crate(crateb, keyb, loc22, s0).
+crate(cratec, keyc, loc12, s0).
+
+key(keya, loc21, s0).
+key(keyb, loc13, s0).
+key(keyc, loc14, s0).
+
+agent(loc24, s0).
+
+% --- Goal condition that the planner will try to reach ---------------
+goal(S) :-
+       crate(cratea, _, loc33, S),
+       crate(crateb, _, loc31, S),
+       crate(cratec, _, loc11, S).
index af47cad..b340a92 100644 (file)
@@ -71,7 +71,7 @@ result(E,S,result(E,S)) :- primitive_action(E), poss(E,S).
 :- dynamic debug/1.
 :- multifile debug/1.
 
-%debug(on).
+debug(on).
 debugoutput(A) :- debug(on), A, !; true.