From 1f2df8d09e7406b8f668780882f301a71619ce2c Mon Sep 17 00:00:00 2001 From: Caspar Safarlou Date: Mon, 17 Nov 2014 22:40:49 +0100 Subject: [PATCH] clarified names and comments --- report/src/task14.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/report/src/task14.pl b/report/src/task14.pl index 5e89e10..74f01a7 100644 --- a/report/src/task14.pl +++ b/report/src/task14.pl @@ -1,18 +1,18 @@ :- [diagnosis]. -generateHittingSetTree(SD, COMP, OBS, HS, HSTREE) :- %test with problem1(SD,COMP,OBS), generateHittingSetTree(SD,COMP,OBS,[],T). This needs to report node([a1], [node([a2], [leaf])]). - tp(SD, COMP, OBS, HS, CS) -> generateParts(SD, COMP, OBS, HS, CS, HSTREE) ; generateParts(_, _, _, _, [], HSTREE). %second part of the OR is needed to translate an empty conflict set into a leaf. +generateHittingSetTree(SD, COMP, OBS, HS, HSTREE) :- %test with problem1(SD,COMP,OBS), generateHittingSetTree(SD,COMP,OBS,[],HSTREE). This needs to report node([a1], [node([a2], [leaf])]). + tp(SD, COMP, OBS, HS, CS) -> generateParts(SD, COMP, OBS, HS, CS, HSTREE) ; generateParts(_,_,_,_, [], HSTREE). %second part of the OR is needed to translate an empty conflict set into a leaf. generateParts(_,_,_,_, [],leaf).%generates leaf if at the end of all possible conflict sets in a branch generateParts(SD, COMP, OBS, HS, CS, node(CS, RESTOFTREE)) :- %generates node if the conflict set isn't empty and goes on. repairBranch(SD, COMP, OBS, HS, CS, RESTOFTREE). %repairs the branch by branching out for each item in the conflict set and generating new conflict sets for the next node -repairBranch(SD, COMP, OBS, HS, [CS], [X]) :- %single item left in conflict set - append(HS, [CS], HSNEW), %add the used conflict set item for this branch to the new hitting set - generateHittingSetTree(SD, COMP, OBS, HSNEW, X). %find the next new conflict set with the new hitted item -repairBranch(SD, COMP, OBS, HS, [CSHEAD|CSTAIL], [X|Xs]) :- %multiple items left in conflict set +repairBranch(SD, COMP, OBS, HS, [CONFLICTITEM], [BRANCH]) :- %single item left in conflict set + append(HS, [CONFLICTITEM], HSNEW), %add the used conflict set item for this branch to the new hitting set + generateHittingSetTree(SD, COMP, OBS, HSNEW, BRANCH). %find the next new conflict set with the new hitted item +repairBranch(SD, COMP, OBS, HS, [CSHEAD|CSTAIL], [BRANCHHEAD|BRANCHTAIL]) :- %multiple items left in conflict set append(HS, [CSHEAD], HSNEW), %add the used conflict set item for this branch to the new hitting set - generateHittingSetTree(SD, COMP, OBS, HSNEW, X), %find the next new conflict set with the new hitted item - repairBranch(SD, COMP, OBS, HS, CSTAIL, Xs). %goes on in recursion for each item in the conflict set of the current node + generateHittingSetTree(SD, COMP, OBS, HSNEW, BRANCHHEAD), %find the next new conflict set with the new hitted item + repairBranch(SD, COMP, OBS, HS, CSTAIL, BRANCHTAIL). %goes on in recursion for each item in the conflict set of the current node \ No newline at end of file -- 2.20.1