From: Mart Lubbers Date: Mon, 17 Nov 2014 11:37:16 +0000 (+0100) Subject: updated task 12 and 13 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=ab5a40b0be9eb3b7d973150375e7ee0d05ca7d89;p=ker1415-1.git updated task 12 and 13 --- diff --git a/report/.Rhistory b/report/.Rhistory deleted file mode 100644 index e69de29..0000000 diff --git a/report/ass2.tex b/report/ass2.tex index 3ea2ea4..abdce8c 100644 --- a/report/ass2.tex +++ b/report/ass2.tex @@ -1,14 +1,27 @@ \subsection{Implementation of the hitting-set algorithm} \subsubsection{Task 12: Generate conflict} +\begin{listing}[H] + \caption{Generating conflict sets} + \prologcode{./src/task12.pl} +\end{listing} + \subsubsection{Task 13: Define your data structure} -Our datastructure uses the predicate node to signify nodes and leaf for leaves. A node contains a list of edge labels and another list (with the same length as the amound of edge labels) that contains nodes or leaves. The edge label corresponds with its order in the list it is in. -Good examples: -isHittingSetTree(node([a,b],[leaf,leaf])). -isHittingSetTree(node([a,b], [node([c,d], [leaf,leaf]), node([e,f], [leaf,leaf])])). -isHittingSetTree(node([a,b], [node([c,d], [node([g,h,i], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])). +\begin{listing}[H] + \caption{Hitting set datastructure} + \prologcode{./src/hs.pl} +\end{listing} +% Het doel van deze opdracht was om je datastructure te laten zien, je hebt +% alleen gezegd wat voor bomen geen hitting set kunnen zijn... -Wrong examples: +%Our datastructure uses the predicate node to signify nodes and leaf for leaves. A node contains a list of edge labels and another list (with the same length as the amound of edge labels) that contains nodes or leaves. The edge label corresponds with its order in the list it is in. +%Good examples: +%isHittingSetTree(node([a,b],[leaf,leaf])). +%isHittingSetTree(node([a,b], [node([c,d], [leaf,leaf]), node([e,f], [leaf,leaf])])). +%isHittingSetTree(node([a,b], [node([c,d], [node([g,h,i], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])). +% +%Wrong examples: +% +%isHittingSetTree(node([a,b], [node([c,d], [node([g,h], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])). -isHittingSetTree(node([a,b], [node([c,d], [node([g,h], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])). \subsubsection{Task 14: Implementation} diff --git a/report/report.out b/report/report.out index 7a7ad16..37cc07e 100644 --- a/report/report.out +++ b/report/report.out @@ -1,19 +1,19 @@ -\BOOKMARK [1][-]{section.1}{Assignment 1-1}{} -\BOOKMARK [2][-]{subsection.1.1}{Part 1: Modelling Sokoban}{section.1} -\BOOKMARK [3][-]{subsubsection.1.1.1}{Task 1: Knowledge base}{subsection.1.1} -\BOOKMARK [3][-]{subsubsection.1.1.2}{Task 2: Actions}{subsection.1.1} -\BOOKMARK [2][-]{subsection.1.2}{Part 2: Implementation}{section.1} -\BOOKMARK [3][-]{subsubsection.1.2.1}{Task 3: Translate Axioms}{subsection.1.2} -\BOOKMARK [3][-]{subsubsection.1.2.2}{Task 4: The Planning Problem in Figure 1}{subsection.1.2} -\BOOKMARK [3][-]{subsubsection.1.2.3}{Task 5: Crates go to Any Goal Location}{subsection.1.2} -\BOOKMARK [3][-]{subsubsection.1.2.4}{Task 6: Inverse Problem}{subsection.1.2} -\BOOKMARK [2][-]{subsection.1.3}{Part 3: Extending the domain}{section.1} -\BOOKMARK [3][-]{subsubsection.1.3.1}{Task 7: Unlocking the Crates}{subsection.1.3} -\BOOKMARK [2][-]{subsection.1.4}{Part 4: General questions}{section.1} -\BOOKMARK [3][-]{subsubsection.1.4.1}{Task 10: Sitcalc expressivity}{subsection.1.4} -\BOOKMARK [3][-]{subsubsection.1.4.2}{Task 11: Related work}{subsection.1.4} -\BOOKMARK [1][-]{section.2}{Assignment 1-2}{} -\BOOKMARK [2][-]{subsection.2.1}{Implementation of the hitting-set algorithm}{section.2} -\BOOKMARK [3][-]{subsubsection.2.1.1}{Task 12: Generate conflict}{subsection.2.1} -\BOOKMARK [3][-]{subsubsection.2.1.2}{Task 13: Define your data structure}{subsection.2.1} -\BOOKMARK [3][-]{subsubsection.2.1.3}{Task 14: Implementation}{subsection.2.1} +\BOOKMARK [1][-]{section.1}{Assignment 1-1}{}% 1 +\BOOKMARK [2][-]{subsection.1.1}{Part 1: Modelling Sokoban}{section.1}% 2 +\BOOKMARK [3][-]{subsubsection.1.1.1}{Task 1: Knowledge base}{subsection.1.1}% 3 +\BOOKMARK [3][-]{subsubsection.1.1.2}{Task 2: Actions}{subsection.1.1}% 4 +\BOOKMARK [2][-]{subsection.1.2}{Part 2: Implementation}{section.1}% 5 +\BOOKMARK [3][-]{subsubsection.1.2.1}{Task 3: Translate Axioms}{subsection.1.2}% 6 +\BOOKMARK [3][-]{subsubsection.1.2.2}{Task 4: The Planning Problem in Figure 1}{subsection.1.2}% 7 +\BOOKMARK [3][-]{subsubsection.1.2.3}{Task 5: Crates go to Any Goal Location}{subsection.1.2}% 8 +\BOOKMARK [3][-]{subsubsection.1.2.4}{Task 6: Inverse Problem}{subsection.1.2}% 9 +\BOOKMARK [2][-]{subsection.1.3}{Part 3: Extending the domain}{section.1}% 10 +\BOOKMARK [3][-]{subsubsection.1.3.1}{Task 7: Unlocking the Crates}{subsection.1.3}% 11 +\BOOKMARK [2][-]{subsection.1.4}{Part 4: General questions}{section.1}% 12 +\BOOKMARK [3][-]{subsubsection.1.4.1}{Task 10: Sitcalc expressivity}{subsection.1.4}% 13 +\BOOKMARK [3][-]{subsubsection.1.4.2}{Task 11: Related work}{subsection.1.4}% 14 +\BOOKMARK [1][-]{section.2}{Assignment 1-2}{}% 15 +\BOOKMARK [2][-]{subsection.2.1}{Implementation of the hitting-set algorithm}{section.2}% 16 +\BOOKMARK [3][-]{subsubsection.2.1.1}{Task 12: Generate conflict}{subsection.2.1}% 17 +\BOOKMARK [3][-]{subsubsection.2.1.2}{Task 13: Define your data structure}{subsection.2.1}% 18 +\BOOKMARK [3][-]{subsubsection.2.1.3}{Task 14: Implementation}{subsection.2.1}% 19 diff --git a/report/report.tex b/report/report.tex index 4515d75..eb2b224 100644 --- a/report/report.tex +++ b/report/report.tex @@ -9,7 +9,7 @@ \usepackage{minted} \usepackage{hyperref} -\author{Caspar Safarlou\and Mart Lubbers} +\author{Mart Lubbers\and \small Caspar Safarlou} \title{Knowledge Representation and Reasoning.\\Assignment 1} \date{\today} diff --git a/pl-files/hittingSetTree.pl b/report/src/hittingSetTree.pl similarity index 97% rename from pl-files/hittingSetTree.pl rename to report/src/hittingSetTree.pl index 925447c..e651d67 100644 --- a/pl-files/hittingSetTree.pl +++ b/report/src/hittingSetTree.pl @@ -10,4 +10,4 @@ isHittingSetTree2(node([X|Xs], [Y|Ys]), Z) :- append(Z, [X], Appended), %append label to list of checked labels isHittingSetTree2(Y, Appended), %go into depth isHittingSetTree2(node(Xs, Ys), Z). %go into width - \ No newline at end of file + diff --git a/report/src/hs.pl b/report/src/hs.pl new file mode 100644 index 0000000..53f3158 --- /dev/null +++ b/report/src/hs.pl @@ -0,0 +1,7 @@ +isHittingSetTree(_, leaf). +isHittingSetTree(_, node([], [])). +isHittingSetTree(VisitedLabels, node([CurLabel|Labels], [CurChild|Children])) :- + not(member(CurLabel, VisitedLabels)), + append(VisitedLabels, [CurChild], UpdatedVisitedLabels), + isHSTree(UpdatedVisitedLabels, CurChild), + isHSTree(VisitedLabels, node(Labels, Children)). diff --git a/report/src/task12.pl b/report/src/task12.pl new file mode 100644 index 0000000..aab80ad --- /dev/null +++ b/report/src/task12.pl @@ -0,0 +1,27 @@ +?- [diagnosis]. +% tp compiled 0.01 sec, 99 clauses +% diagnosis compiled 0.01 sec, 109 clases +true. + +?- problem1(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS). +SD = [all _G32: (and(_G32), ~ab(_G32)=> ... ], +COMP = [a1, a2], +OBS = [in1(a1), in2(a1), ~out(a1), in1(a2), in2(a2), ~out(a2)], +CS = [a1]. + +?- problem2(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS). +SD = [all _G32: (and(_G32), ~ab(_G32)=> ... ], +COMP = CS, CS = [a1, a2], +OBS = [in1(a1), ~in2(a1), out(a2)]. + +?- problem3(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS). +SD = [all _G32: (and(_G32), ~ab(_G32)=> ... ], +COMP = [a1, a2, o1], +OBS = [in1(a1), in2(a1), in1(a2), in2(a2), ~out(o1)], +CS = [a1, o1, a2]. + +?- fulladder(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS). +SD = [all _G32: (and(_G32), ~ab(_G32)=> .. ], +COMP = [a1, a2, x1, x2, r1], +OBS = [in1(fa), ~in2(fa), carryin(fa), out(fa), ~carryout(fa)], +CS = [a1, x1, a2, r1, x2].