hp.pl vervangen door isHittingSet.pl en report en comments bij code bijgewerkt
[ker1415-1.git] / report / src / task14part2.pl
index ebbe8fa..26c15bf 100644 (file)
@@ -1,6 +1,6 @@
 :- [task14part1].\r
        \r
-% Adding a variable for the current path\r
+% Adding a variable for the current path.\r
 extractDiagnoses(HSTree,Diagnoses):-\r
        extractDiagnoses2(HSTree, Diagnoses, []).       \r
 \r
@@ -25,32 +25,33 @@ getLengthSmallestSet([Diagnosis], DiagnosisLength):-
        % Calls length single diagnosis\r
        length(Diagnosis,DiagnosisLength). \r
 getLengthSmallestSet([HeadDiagnosis|RestOfDiagnoses], Minimal):-\r
-       % Recursively gets the length of tail\r
+       % Recursively gets the length of tail.\r
        getLengthSmallestSet(RestOfDiagnoses, RestLength),\r
-       % Initialises length of the head diagnosis\r
+       % Initialises length of the head diagnosis.\r
        length(HeadDiagnosis,HeadLength),\r
-       % Gets minimal length of diagnoses\r
+       % Gets minimal length of diagnoses.\r
        Minimal is min(HeadLength, RestLength).\r
 \r
 filterLength(X,Y):-\r
        length(Y, LengthY),\r
-       %checks if the set isn't bigger than the checked set\r
+       %Checks if the set isn't bigger than the smallest set.\r
        X \== LengthY. \r
 \r
-% Deze functie moet opnieuw geschreven worden, hij moet de subsetminimal\r
-% opleveren en niet de kleinste diagnoses\r
+\r
 getSubsetMinimalDiagnoses(DiagnosesSets, MinimalDiagnosesSets):- \r
+       %Gets the length of the smallest set to prune the diagnoses. \r
+       %Break so that there will be no backtracking if something goes wrong.\r
        getLengthSmallestSet(DiagnosesSets,Length),!,\r
        % Excludes sets that are bigger than the smallest set\r
        exclude(filterLength(Length), DiagnosesSets, MinimalDiagnosesSets).\r
 \r
-% Function that returns minimal hitting sets from a problem\r
-subsetMinimalDiagnoses(SD, COMP, OBS, MinimalDiagnosesSets) :-\r
-       % Generate hitting tree\r
+% Function that returns minimal hitting sets from a problem.\r
+subsetMinimalDiagnoses(SD, COMP, OBS, HsTree, DiagnosesSets, MinimalDiagnosesSets) :-\r
+       % Generate hitting tree.\r
        generateHittingSetTree(SD, COMP, OBS, [], HsTree),\r
        write(HsTree),\r
-       % Get diagnoses out of the hitting tree\r
+       % Get diagnoses out of the hitting tree.\r
        extractDiagnoses(HsTree, DiagnosesSets),\r
        write(DiagnosesSets),\r
-       % Determine subset minimal diagnoses\r
+       % Determine smallest diagnoses.\r
        getSubsetMinimalDiagnoses(DiagnosesSets, MinimalDiagnosesSets).\r