start with pfl learning.

This commit is contained in:
Vitor Santos Costa
2012-06-22 19:00:12 +01:00
parent 5fe052a3ef
commit 87e0b67e76
10 changed files with 141 additions and 14 deletions

View File

@@ -21,7 +21,7 @@
append/3,
member/2]).
:- dynamic factor/5, skolem_in/2, skolem/2, preprocess/3, evidence/2, id/1.
:- dynamic factor/6, skolem_in/2, skolem/2, preprocess/3, evidence/2, id/1.
:- reexport(library(clpbn),
[clpbn_flag/2 as pfl_flag,
@@ -55,7 +55,7 @@ user:term_expansion( markov((Formula ; Phi ; Constraints)), pfl:factor(markov,Id
process_args(Formula, Id, 0, _, FList, []).
user:term_expansion( Id@N, L ) :-
atom(Id), number(N), !,
N1 is N + 1,
N1 is N + 1,
findall(G,generate_entity(1, N1, Id, G), L).
user:term_expansion( Goal, [] ) :-
preprocess(Goal, Sk,Var), !,
@@ -112,6 +112,10 @@ process_arg(Sk::D, Id, _I) -->
process_arg(Sk, Id, _I) -->
!,
{
% if :: been used before for this skolem
% just keep on using it,
% otherwise, assume it is t,f
( \+ \+ skolem(Sk,_D) -> true ; new_skolem(Sk,[t,f]) ),
assert(skolem_in(Sk, Id))
},
[Sk].
@@ -121,7 +125,7 @@ new_skolem(Sk,D) :-
skolem(Sk1, D1),
Sk1 =@= Sk,
!,
D1 = D.
( D1 = D -> true ; throw(pfl(permission_error(redefining_domain(Sk),D:D1)))).
new_skolem(Sk,D) :-
interface_predicate(Sk),
assert(skolem(Sk, D)).
@@ -155,7 +159,7 @@ get_pfl_parameters(Id,Out) :-
new_pfl_parameters(Id, NewPhi) :-
retract(factor(Type.Id,FList,FV,_Phi,Constraints)),
retract(factor(Type,Id,FList,FV,_Phi,Constraints)),
assert(factor(Type,Id,FList,FV,NewPhi,Constraints)),
fail.
new_pfl_parameters(_Id, _NewPhi).
@@ -179,5 +183,3 @@ get_factor_pvariable(Id,Var) :-
factor(_Type, Id,FList,_FV,_Phi,_Constraints),
member(Var, FList).