Skip to content
Snippets Groups Projects
Commit 2700082a authored by Eric Würbel's avatar Eric Würbel
Browse files

some useful comments.

parent faf2f7ae
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,10 @@
% Bis.
%
% Uses rational arithmetic.
%
% We use the is/2 predicate instead of the more practical #=/2 from
% the clp(fd) module because it does not work whith rationals. We plan
% to investigate the use of clp(q).
basic_bbas(B, Bis, BBAs) :-
length(B, CardB),
basic_bba2(B, CardB, Bis, BBAs)
......@@ -33,6 +37,7 @@ basic_bba2(B, CardB, [Bi|Bis], [[(Bi, BBABi), (B, BBAB)]|BBAs]) :-
%! combinator(+M1, +M2, -M12) is det
%
% combines two belief assigments (Dempster rule).
% each member of the lists is a tuple (Set, Mass).
combine([], _, []).
combine([Mass1|Masses1], Masses2, RMasses) :-
combine1(Mass1, Masses2, RMasses1),
......@@ -42,12 +47,12 @@ combine([Mass1|Masses1], Masses2, RMasses) :-
combine1(_, [], []).
combine1((Set1, Mass1), [(Set2, _)|L], Result) :-
ord_intersect(Set1, Set2, []),
ord_intersect(Set1, Set2, []), % empty intersection case
combine1((Set1, Mass1), L, Result)
.
combine1((Set1, Mass1), [(Set2, Mass2)|L], [(RSet, RMass)|Result]) :-
ord_intersect(Set1, Set2, RSet),
RSet \= [],
RSet \= [], % nonempty intersection case
RMass is Mass1 * Mass2,
combine1((Set1, Mass1), L, Result)
.
......@@ -55,6 +60,9 @@ combine1((Set1, Mass1), [(Set2, Mass2)|L], [(RSet, RMass)|Result]) :-
%! normalize(+BBA, -NormBBA) is det
%
% Succeeds if NormBBA is the normalized version of BBA.
%
% In practice, normalisation takes place if the sum of the masses is
% not equal to 1.
normalize(M1, M1) :-
sum_mass(M1, 1).
......@@ -91,7 +99,7 @@ collect_masses_unique(Set, [(S1, M1)|BBAs], Masses, [(S1, M1)|FinalBBAs]) :-
%! add_all(+L, -Sum) is semidet
%
% Succeed is Sum is the sum of all elements in L. L is supposed to
% Succeed if Sum is the sum of all elements in L. L is supposed to
% contain rational numbers.
add_all([], 0).
add_all([N|L], S) :-
......@@ -110,7 +118,7 @@ sum_mass([(_,M)|L], S) :-
%! mult(+F, +L1, -L2) is semidet
%
% Multiply a BBA by a factor.
% Multiply a BBA L1 by a factor F.
mult(_, [], []).
mult(F, [(S1,N1)|L1], [(S1,N2)|L2]) :-
N2 is N1 * F,
......
......@@ -14,6 +14,8 @@
:- use_module(logic).
:- use_module(evidence).
%! go
%
% Main predicate.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment