Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Evidence
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Wurbel
Evidence
Commits
2550f207
Commit
2550f207
authored
1 year ago
by
Eric Würbel
Browse files
Options
Downloads
Patches
Plain Diff
to be tested
parent
7b56e5d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
evidence.pl
+1
-139
1 addition, 139 deletions
evidence.pl
with
1 addition
and
139 deletions
evidence.pl
+
1
−
139
View file @
2550f207
...
@@ -3,10 +3,8 @@
...
@@ -3,10 +3,8 @@
*/
*/
:-
module
(
evidence
,
[
:-
module
(
evidence
,
[
global_bba
/
4
,
beliefs
/
3
,
trace_global_bba
/
3
,
global_bba
/
4
,
trace_global_bba
/
3
,
global_lambda
/
4
,
lambda_beliefs
/
3
,
global_prio_bba
/
5
,
% +B,+Bis,+Strata,-GBBA,+Options
global_prio_bba
/
5
,
% +B,+Bis,+Strata,-GBBA,+Options
beliefs_prio
/
4
,
print_beliefs
/
1
,
print_beliefs
/
1
,
beliefs
/
4
,
% +Bis,+GBBA,-Bel,+Opts
beliefs
/
4
,
% +Bis,+GBBA,-Bel,+Opts
beliefs_prio
/
5
beliefs_prio
/
5
...
@@ -494,142 +492,6 @@ print_set_label([S|L]) :-
...
@@ -494,142 +492,6 @@ print_set_label([S|L]) :-
format
(
'~w~w'
,
[
S
,
X
]),
format
(
'~w~w'
,
[
S
,
X
]),
print_set_label
(
L
).
print_set_label
(
L
).
/*
*******************************************************************
*/
/*
using lambda masses instead of belief masses
*/
/*
*******************************************************************
*/
%! basic_lambda(+B, +Bis, -BBAs, +Opts) is det
%
% Compute the basic lambda assignments of subsets of B in
% collection Bis.
%
% The resulting BBAs is a list of triplets (BaseLabel, Set, Mass)
% where BaseLabel is a label denoting the Set (subbases are labeled
% with an integer starting from 1, the full base is labeled with 0).
%
% This label is present in the Bis list. Each element of this list is
% a Label/Set term where Set is a set.
%
basic_lambda
(
B
,
Bis
,
BBAs
,
Opts
)
:-
length
(
B
,
CardB
),
basic_lambda2
(
B
,
CardB
,
Bis
,
BBAs
,
Opts
).
%! basic_lambda2(+B, +CardB, +Bis, -BBAs) is det
%
% Utility predicate for basic_bbas/3.
basic_lambda2
(
_
,
_
,
[],
[],
_
).
basic_lambda2
(
B
,
CardB
,
[
N
/
Bi
|
Bis
],
[[([
N
],
Bi
,
BBABi
),
([
0
],
B
,
BBAB
)]|
BBAs
],
Opts
)
:-
length
(
Bi
,
CardBi
),
BBABi
#=
CardBi
,
BBAB
#=
CardB
-
CardBi
,
trace_bba
(
N
/
Bi
,
N
/
Bi
,
BBABi
,
Opts
,
1
),
% trace_bba should be ok.
trace_bba
(
N
/
Bi
,
0
/
B
,
BBAB
,
Opts
,
1
),
basic_lambda2
(
B
,
CardB
,
Bis
,
BBAs
,
Opts
).
%! combine_lambdas(+M1, +M2, -M12, +Options) is det
%
% combines two lambda belief assigments (the rule is inspired
% by the Dempster rule but uses integer arithmetic. It performs no
% normalization). each member of the lists is a tuple (Set, Mass).
combine_lambda
([],
_
,
[],
_
).
combine_lambda
([
Mass1
|
Masses1
],
Masses2
,
RMasses
,
Opts
)
:-
combine_lambda1
(
Mass1
,
Masses2
,
RMasses1
,
Opts
),
combine_lambda
(
Masses1
,
Masses2
,
RMasses2
,
Opts
),
append
(
RMasses1
,
RMasses2
,
RMasses
).
combine_lambda1
(
_
,
[],
[],
_
).
combine_lambda1
((
Label1
,
Set1
,
Mass1
),
[(
_
,
Set2
,
_
)|
L
],
Result
,
Opts
)
:-
% empty intersection case
ord_intersect
(
Set1
,
Set2
,
[]),
% empty intersection case
trace
(
'~w inter ~w = emptyset~n'
,
[
Set1
,
Set2
],
Opts
,
2
),
combine_lambda1
((
Label1
,
Set1
,
Mass1
),
L
,
Result
,
Opts
).
combine_lambda1
((
Label1
,
Set1
,
Mass1
),
[(
Label2
,
Set2
,
Mass2
)|
L
],
[(
RLabel
,
RSet
,
RMass
)|
Result
],
Opts
)
:-
ord_intersect
(
Set1
,
Set2
,
RSet
),
RSet
\
=
[],
% nonempty intersection case
RMass
#=
Mass1
*
Mass2
,
(
memberchk
(
0
,
Label1
)
->
RLabel
=
Label2
;
(
memberchk
(
0
,
Label2
)
->
RLabel
=
Label1
;
ord_union
(
Label1
,
Label2
,
RLabel
)
)
),
trace
(
'~w inter ~w = ~w : ~w~n'
,
[
Set1
,
Set2
,
RSet
,
RMass
],
Opts
,
2
),
combine_lambda1
((
Label1
,
Set1
,
Mass1
),
L
,
Result
,
Opts
).
%! merge_unique(+BBA1, -BBA2) is det
%
% Merge duplicate sets and add their masses.
merge_unique_lambda
([],
[]).
merge_unique_lambda
([(
Label
,
Set
,
M1
)|
B1
],
[(
Label
,
Set
,
M2
)|
B3
])
:-
collect_lambda_masses_unique
((
Label
,
Set
),
B1
,
Masses
,
B2
),
M2
#=
M1
+
Masses
,
merge_unique
(
B2
,
B3
).
%! collect_lambda_masses_unique(+LabelSet, +BBas, -Masses, -B2) is det
%
% Masses is the sum of all masses of be belief assignments in BBAs
% concerning (Label, Set). B2 containts the remaining
% assignments.
collect_lambda_masses_unique
(
_
,
[],
0
,
[]).
collect_lambda_masses_unique
((
Label
,
Set
),
[(
Label
,
Set
,
M1
)|
BBAs
],
Masses
,
FinalBBAs
)
:-
collect_masses_unique
((
Label
,
Set
),
BBAs
,
M2
,
FinalBBAs
),
Masses
#=
M1
+
M2
.
collect_lambda_masses_unique
((
Label
,
Set
),
[(
Label1
,
S1
,
M1
)|
BBAs
],
Masses
,
[(
Label1
,
S1
,
M1
)|
FinalBBAs
])
:-
(
Set
\
==
S1
;
Label
\
==
Label1
),
collect_lambda_masses_unique
((
Label
,
Set
),
BBAs
,
Masses
,
FinalBBAs
).
%! global_lambda(+B, +Bis, -GBBA, +Nonorm)
%
% B is the the belief base. Bis is the collection subsets of B which
% are maximal-consistent with mu (wrt set inclusion). GBBA is the
% computed global belied assignment.
%
global_lambda
(
B
,
Bis
,
GBBA
,
Opts
)
:-
trace
(
'---- basic BBAs --------------------------------------~n'
,
[],
Opts
,
1
),
basic_lambda
(
B
,
Bis
,
[
B1
|
BasicBBAs
],
Opts
),
global_lambda2
(
B1
,
BasicBBAs
,
GBBA
,
Opts
).
%! global_bba2(+BBa, +BBas, GBBA, Opts)
%
% Each BBa is a triplet (BaseLabel, Set, Mass)
% where Base Label is a label denoting the Set (subbases are labeled
% with an integer starting from 1, the full base is labeled with 0).
global_lambda2
(
B
,
[],
B
,
_
).
global_lambda2
(
B
,
[
BBa
|
BBas
],
GBBA
,
Opts
)
:-
trace
(
'---- combining ~w & ~w -----------------------------~n'
,
[
B
,
BBa
],
Opts
,
2
),
combine_lambda
(
B
,
BBa
,
B1
,
Opts
),
merge_unique_lambda
(
B1
,
B2
),
global_lambda2
(
B2
,
BBas
,
GBBA
,
Opts
).
%! lambda_beliefs(+Bis, +GBBA, -Bel)
%
% Bel is the set of beliefs for each Bi, given the global lambda BBA
% GBBA.
lambda_beliefs
([],
_
,
[]).
lambda_beliefs
([
Ni
/
Bi
|
Bis
],
GBBA
,
[(
Ni
,
Bi
,
Bel
)|
Bels
])
:-
lambda_belief
(
Ni
/
Bi
,
GBBA
,
Bel
),
lambda_beliefs
(
Bis
,
GBBA
,
Bels
).
lambda_belief
(
_
,
[],
0
).
lambda_belief
(
Ni
/
Bi
,
[(
Nj
,
Bj
,
M
)|
GBBA
],
Bel
)
:-
ord_subset
(
Bj
,
Bi
),
memberchk
(
Ni
,
Nj
),
lambda_belief
(
Ni
/
Bi
,
GBBA
,
Bel1
),
Bel
#=
M
+
Bel1
.
lambda_belief
(
Ni
/
Bi
,
[(
Nj
,
Bj
,
_
)|
GBBA
],
Bel
)
:-
(
\
+
ord_subset
(
Bj
,
Bi
)
;
\
+
memberchk
(
Ni
,
Nj
)
),
lambda_belief
(
Ni
/
Bi
,
GBBA
,
Bel
).
/*
********************************************************************
*/
/*
********************************************************************
*/
/*
test data
*/
/*
test data
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment