From 1f7b839e851e777142108666f7c793aaa93141b0 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 2 May 2009 14:11:54 -0500 Subject: [PATCH] support exporting top-level-work as absolute path --- configure | 5 +- configure.in | 5 +- library/lammpi/Makefile.in | 1 + library/matlab/Makefile.in | 1 + library/matrices/Makefile.in | 1 + library/matrix/Makefile.in | 1 + library/mpi/Makefile.in | 1 + library/random/Makefile.in | 1 + library/regex/Makefile.in | 1 + library/rltree/Makefile.in | 1 + library/system/Makefile.in | 1 + library/tries/Makefile.in | 1 + library/yap2swi/Makefile.in | 1 + library/yap2swi/yap2swi.c | 2 +- packages/CLPBN/Makefile.in | 1 + packages/CLPBN/clpbn.yap | 41 +++++---- packages/CLPBN/clpbn/dists.yap | 15 +++- packages/CLPBN/clpbn/graphviz.yap | 18 ++-- packages/CLPBN/clpbn/table.yap | 112 ++++++++++++++++++++++-- packages/PLStream/Makefile.in | 1 + packages/ProbLog/problog.yap | 40 +++++++-- packages/ProbLog/simplecudd/Makefile.in | 1 + packages/chr | 2 +- packages/clpqr | 2 +- packages/jpl | 2 +- packages/sgml/Makefile.in | 3 +- 26 files changed, 209 insertions(+), 52 deletions(-) diff --git a/configure b/configure index c390359cf..4584f3ae7 100755 --- a/configure +++ b/configure @@ -7186,8 +7186,8 @@ fi SHLIB_CFLAGS="-fno-common" SHLIB_SUFFIX=".dylib" DO_SECOND_LD="" - SHLIB_LD="$CC -bundle -bundle_loader $abs_top_builddir/yap -L$abs_top_builddir -lYap -undefined dynamic_lookup -Wl,-x -dead-strip -dead_strip_dylibs" - LDFLAGS="-Wl,-x -dead_strip $LDFLAGS" +# SHLIB_LD="$CC -bundle -bundle_loader \$(abs_top_builddir)/yap -L\$(abs_top_builddir) -lYap -undefined dynamic_lookup -Wl,-x -dead-strip -dead_strip_dylibs" +# LDFLAGS="-Wl,-x -dead_strip -dead_strip_dylibs $LDFLAGS" SHLIB_LD="$CC -bundle -flat_namespace -undefined suppress" INSTALL_DLLS="" CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall -Wstrict-aliasing=2" @@ -7325,6 +7325,7 @@ then DYNLIB_LD="$CC -dynamiclib" PRE_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(abs_top_builddir)" EXTEND_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR)/Yap YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/Yap/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)" +# CROSS_SIMULATOR="DYLD_LIBRARY_PATH=." ;; *) case "$target_cpu" in diff --git a/configure.in b/configure.in index be73165bd..9689d8789 100644 --- a/configure.in +++ b/configure.in @@ -877,8 +877,8 @@ dnl Linux has both elf and a.out, in this case we found elf SHLIB_CFLAGS="-fno-common" SHLIB_SUFFIX=".dylib" DO_SECOND_LD="" - SHLIB_LD="$CC -bundle -bundle_loader $abs_top_builddir/yap -L$abs_top_builddir -lYap -undefined dynamic_lookup -Wl,-x -dead-strip -dead_strip_dylibs" - LDFLAGS="-Wl,-x -dead_strip $LDFLAGS" +# SHLIB_LD="$CC -bundle -bundle_loader \$(abs_top_builddir)/yap -L\$(abs_top_builddir) -lYap -undefined dynamic_lookup -Wl,-x -dead-strip -dead_strip_dylibs" +# LDFLAGS="-Wl,-x -dead_strip -dead_strip_dylibs $LDFLAGS" SHLIB_LD="$CC -bundle -flat_namespace -undefined suppress" INSTALL_DLLS="" CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall -Wstrict-aliasing=2" @@ -952,6 +952,7 @@ then DYNLIB_LD="$CC -dynamiclib" PRE_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(abs_top_builddir)" EXTEND_DYNLOADER_PATH="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR)/Yap YAPBOOTDIR=\$(DESTDIR)\$(SHAREDIR)/Yap/pl YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)" +# CROSS_SIMULATOR="DYLD_LIBRARY_PATH=." ;; *) case "$target_cpu" in diff --git a/library/lammpi/Makefile.in b/library/lammpi/Makefile.in index ee552ca06..5893f07ff 100644 --- a/library/lammpi/Makefile.in +++ b/library/lammpi/Makefile.in @@ -9,6 +9,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/matlab/Makefile.in b/library/matlab/Makefile.in index 6350f6513..efd14f2c2 100644 --- a/library/matlab/Makefile.in +++ b/library/matlab/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/matrices/Makefile.in b/library/matrices/Makefile.in index 5a3a4dce9..82e9ba729 100644 --- a/library/matrices/Makefile.in +++ b/library/matrices/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/matrix/Makefile.in b/library/matrix/Makefile.in index 5a3a4dce9..82e9ba729 100644 --- a/library/matrix/Makefile.in +++ b/library/matrix/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/mpi/Makefile.in b/library/mpi/Makefile.in index 6908c67d1..6c8cba93a 100644 --- a/library/mpi/Makefile.in +++ b/library/mpi/Makefile.in @@ -13,6 +13,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/random/Makefile.in b/library/random/Makefile.in index 7f98c7725..670806630 100644 --- a/library/random/Makefile.in +++ b/library/random/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/regex/Makefile.in b/library/regex/Makefile.in index 50d588ff7..7c6aecfea 100644 --- a/library/regex/Makefile.in +++ b/library/regex/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/rltree/Makefile.in b/library/rltree/Makefile.in index bf4f00ab7..c1752e328 100644 --- a/library/rltree/Makefile.in +++ b/library/rltree/Makefile.in @@ -9,6 +9,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/system/Makefile.in b/library/system/Makefile.in index 67c4ec094..7c92b60a1 100644 --- a/library/system/Makefile.in +++ b/library/system/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/tries/Makefile.in b/library/tries/Makefile.in index 675eb3c10..28c24f7e9 100644 --- a/library/tries/Makefile.in +++ b/library/tries/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/yap2swi/Makefile.in b/library/yap2swi/Makefile.in index 0ed38a85f..e768a3710 100644 --- a/library/yap2swi/Makefile.in +++ b/library/yap2swi/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/library/yap2swi/yap2swi.c b/library/yap2swi/yap2swi.c index 50826c937..1780980e0 100644 --- a/library/yap2swi/yap2swi.c +++ b/library/yap2swi/yap2swi.c @@ -1560,7 +1560,7 @@ PL_initialise(int myargc, char **myargv) init_args.Argv = myargv; init_args.Argc = myargc; - init_args.SavedState = "startup"; + init_args.SavedState = "startup.yss"; init_args.HeapSize = 0; init_args.StackSize = 0; init_args.TrailSize = 0; diff --git a/packages/CLPBN/Makefile.in b/packages/CLPBN/Makefile.in index 04935d5b8..87a1dd21f 100644 --- a/packages/CLPBN/Makefile.in +++ b/packages/CLPBN/Makefile.in @@ -45,6 +45,7 @@ CLPBN_PROGRAMS= \ $(CLPBN_SRCDIR)/hmm.yap \ $(CLPBN_SRCDIR)/jt.yap \ $(CLPBN_SRCDIR)/matrix_cpt_utils.yap \ + $(CLPBN_SRCDIR)/pgrammar.yap \ $(CLPBN_SRCDIR)/table.yap \ $(CLPBN_SRCDIR)/topsort.yap \ $(CLPBN_SRCDIR)/utils.yap \ diff --git a/packages/CLPBN/clpbn.yap b/packages/CLPBN/clpbn.yap index c4f507f2d..006ba9fc1 100644 --- a/packages/CLPBN/clpbn.yap +++ b/packages/CLPBN/clpbn.yap @@ -63,7 +63,8 @@ dist/4, get_dist/4, get_evidence_position/3, - get_evidence_from_position/3 + get_evidence_from_position/3, + additive_dists/6 ]). :- use_module('clpbn/evidence', @@ -130,7 +131,9 @@ clpbn_flag(parameter_softening,Before,After) :- {Var = Key with Dist} :- put_atts(El,[key(Key),dist(DistInfo,Parents)]), dist(Dist, DistInfo, Key, Parents), - add_evidence(Var,Key,DistInfo,El). + add_evidence(Var,Key,DistInfo,El) +% ,writeln({Var = Key with Dist}) +. check_constraint(Constraint, _, _, Constraint) :- var(Constraint), !. check_constraint((A->D), _, _, (A->D)) :- var(A), !. @@ -285,16 +288,23 @@ verify_attributes(_, _, []). bind_clpbn(T, Var, _, _, _) :- nonvar(T), !, ( add_evidence(Var,T) -> true ; writeln(T:Var), fail ). bind_clpbn(T, Var, Key, Dist, Parents) :- var(T), - get_atts(T, [key(Key1),dist(Dist1,Parents1)]), !, - bind_clpbns(Key, Dist, Parents, Key1, Dist1, Parents1), - ( + get_atts(T, [key(Key1),dist(Dist1,Parents1)]), +writeln(eq:Key:Key1), +( + bind_clpbns(Key, Dist, Parents, Key1, Dist1, Parents1) + -> + ( get_atts(T, [evidence(Ev1)]) -> bind_evidence_from_extra_var(Ev1,Var) - ; + ; get_atts(Var, [evidence(Ev)]) -> bind_evidence_from_extra_var(Ev,T) + ; + true + ) ; - true). + fail + ). bind_clpbn(_, Var, _, _, _, _) :- use(bnt), check_if_bnt_done(Var), !. @@ -309,6 +319,7 @@ bind_clpbn(T, Var, Key0, _, _, _) :- ( Key = Key0 -> true ; + % let us not loose whatever we had. add_evidence(Var,T) ). @@ -318,17 +329,11 @@ fresh_attvar(Var, NVar) :- % I will now allow two CLPBN variables to be bound together. %bind_clpbns(Key, Dist, Parents, Key, Dist, Parents). -bind_clpbns(Key, Dist, Parents, Key1, Dist1, Parents1) :- +bind_clpbns(Key, Dist, _Parents, Key1, Dist1, _Parents1) :- Key == Key1, !, - get_dist(Dist,Type,Domain,Table), - get_dist(Dist1,Type1,Domain1,Table1), - ( Dist == Dist1, - same_parents(Parents,Parents1) - -> - true - ; - throw(error(domain_error(bayesian_domain),bind_clpbns(var(Dist, Key, Type, Domain, Table, Parents),var(Dist1, Key1, Type1, Domain1, Table1, Parents1)))) - ). + get_dist(Dist,_Type,_Domain,_Table), + get_dist(Dist1,_Type1,_Domain1,_Table1), + Dist = Dist1. bind_clpbns(Key, _, _, _, Key1, _, _, _) :- Key\=Key1, !, fail. bind_clpbns(_, _, _, _, _, _, _, _) :- @@ -395,3 +400,5 @@ clpbn_run_solver(vel, LVs, LPs, State) :- clpbn_run_solver(jt, LVs, LPs, State) :- run_jt_solver(LVs, LPs, State). +add_keys(Key1+V1,_Key2,Key1+V1). + diff --git a/packages/CLPBN/clpbn/dists.yap b/packages/CLPBN/clpbn/dists.yap index 4028c93ba..898ce0d27 100644 --- a/packages/CLPBN/clpbn/dists.yap +++ b/packages/CLPBN/clpbn/dists.yap @@ -24,10 +24,11 @@ randomise_dist/1, uniformise_all_dists/0, uniformise_dist/1, - reset_all_dists/0 + reset_all_dists/0, + additive_dists/6 ]). -:- use_module(library(lists),[is_list/1,nth0/3]). +:- use_module(library(lists),[is_list/1,nth0/3,append/3]). :- use_module(library(matrix), [matrix_new/4, @@ -106,8 +107,10 @@ dist(V, Id, Key, Parents) :- var(Key), !, when(Key, dist(V, Id, Key, Parents)). dist(avg(Domain, Parents), avg(Domain), _, Parents). +dist(ip(Domain, Tabs, Parents), ip(Domain,Tabs), _, Parents). dist(max(Domain, Parents), max(Domain), _, Parents). dist(min(Domain, Parents), min(Domain), _, Parents). +dist(cons(Domain, Parent), cons(Domain), _, Parent). dist(p(Type, CPT), Id, Key, FParents) :- copy_structure(Key, Key0), distribution(Type, CPT, Id, Key0, [], FParents). @@ -219,6 +222,8 @@ get_dist_params(Id, Parms) :- get_dist_domain_size(avg(D,_), DSize) :- !, length(D, DSize). +get_dist_domain_size(ip(D,_,_), DSize) :- !, + length(D, DSize). get_dist_domain_size(Id, DSize) :- recorded(clpbn_dist_db, db(Id, _, _, _, _, _, DSize), _). @@ -231,6 +236,8 @@ get_dist_key(Id, Key) :- get_dist_nparams(Id, NParms) :- recorded(clpbn_dist_db, db(Id, _, _, _, _, NParms, _), _). +get_evidence_position(El, ip(Domain,_,_), Pos) :- !, + nth0(Pos, Domain, El), !. get_evidence_position(El, avg(Domain), Pos) :- !, nth0(Pos, Domain, El), !. get_evidence_position(El, Id, Pos) :- @@ -267,6 +274,7 @@ dist_new_table(Id, NewMat) :- fail. dist_new_table(_, _). +copy_structure(V, _) :- attvar(V), !. copy_structure(V, V) :- var(V), !. copy_structure(V, _) :- primitive(V), !. copy_structure(Key, Key0) :- @@ -314,3 +322,6 @@ reset_all_dists :- reset_all_dists. +additive_dists(ip(Domain,Tabs1), ip(Domain,Tabs2), Parents1, Parents2, ip(Domain,Tabs), Parents) :- + append(Tabs1, Tabs2, Tabs), + append(Parents1, Parents2, Parents). diff --git a/packages/CLPBN/clpbn/graphviz.yap b/packages/CLPBN/clpbn/graphviz.yap index 2666b59ce..6d81cf3da 100644 --- a/packages/CLPBN/clpbn/graphviz.yap +++ b/packages/CLPBN/clpbn/graphviz.yap @@ -36,8 +36,7 @@ info_ouput(Stream, [V|Output]) :- output_parents(Stream, [V]) :- !, - clpbn:get_atts(V,[key(Key)]), - output_key(Stream,Key). + output_v(V,Stream). output_parents(Stream, L) :- format(Stream,'{ ',[]), output_parents1(Stream,L), @@ -45,11 +44,13 @@ output_parents(Stream, L) :- output_parents1(_,[]). output_parents1(Stream,[V|L]) :- - clpbn:get_atts(V,[key(Key)]), - output_key(Stream,Key), - put_code(Stream, 0' ), + output_v(V,Stream), + put_code(Stream, 0' ), %' output_parents1(Stream,L). +output_v(V,Stream) :- + clpbn:get_atts(V,[key(Key)]), + output_key(Stream,Key). output_key(Stream, Key) :- output_key(Stream, 0, Key). @@ -57,11 +58,8 @@ output_key(Stream, Key) :- output_key(Stream, _, Key) :- primitive(Key), !, write(Stream, Key). -output_key(Stream, I0, Key) :- - Key =.. [Name|Args], - write(Stream, Name), - I is I0+1, - output_key_args(Stream, I, Args). +output_key(Stream, _, Key) :- + format(Stream, '"~w"', [Key]). output_key_args(_, _, []). output_key_args(Stream, I, [Arg|Args]) :- diff --git a/packages/CLPBN/clpbn/table.yap b/packages/CLPBN/clpbn/table.yap index e265058b2..12f882fdc 100644 --- a/packages/CLPBN/clpbn/table.yap +++ b/packages/CLPBN/clpbn/table.yap @@ -9,6 +9,8 @@ :- module(clpbn_table, [clpbn_table/1, + clpbn_tableallargs/1, + clpbn_table_nondet/1, clpbn_tabled_clause/2, clpbn_tabled_abolish/1, clpbn_tabled_asserta/1, @@ -23,9 +25,9 @@ ]). :- use_module(library(bhash), - [b_hash_new/2, + [b_hash_new/4, b_hash_lookup/3, - b_hash_insert/3]). + b_hash_insert/4]). :- meta_predicate clpbn_table(:), clpbn_tabled_clause(:.?), @@ -37,20 +39,43 @@ clpbn_tabled_number_of_clauses(:,-), clpbn_is_tabled(:). +:- use_module(library(terms), [ + instantiated_term_hash/4, + variant/2 + ]). + :- dynamic clpbn_table/3. +:- meta_predicate clpbn_table(:), clpbn_table_all_args(:). + :- initialization(init). init :- clpbn_reset_tables. clpbn_reset_tables :- - clpbn_reset_tables(1024). + clpbn_reset_tables(2048). clpbn_reset_tables(Sz) :- - b_hash_new(Tab, Sz), + b_hash_new(Tab, Sz, myf, myc), nb_setval(clpbn_tables, Tab). +myf(Key, Size, Index) :- + instantiated_term_hash(Key, -1, Size, Index). + +myc(A, B) :- + variant(A,B), + term_variables(A,L1), + term_variables(B,L2), + match_keys(L1,L2). + +match_keys([],[]). +match_keys([V1|L1],[V2|L2]) :- + clpbn:get_atts(V1,[key(K)]), + clpbn:get_atts(V2,[key(K)]), + match_keys(L1,L2). + + clpbn_table(M:X) :- !, clpbn_table(X,M). clpbn_table(X) :- @@ -65,7 +90,7 @@ clpbn_table((P1,P2),M) :- !, clpbn_table(F/N,M) :- functor(S,F,N), S =.. L0, - take_tail(L0, V, L1, V1, L2), + take_tail(L0, V, L1, V, L2), Key =.. L1, atom_concat(F, '___tabled', NF), L2 = [_|Args], @@ -73,12 +98,83 @@ clpbn_table(F/N,M) :- L0 = [_|OArgs], S2 =.. [NF|OArgs], asserta(clpbn_table(S, M, S2)), - assert((M:S :- nb_getval(clpbn_tables, Tab), ( b_hash_lookup(Key, V1, Tab) -> true ; M:S1, b_hash_insert(Tab, Key, V1) ; true), ( nonvar(V) -> clpbn_evidence:put_evidence(V, V1) ; V = V1 ), ! ) ). + assert( + (M:S :- + b_getval(clpbn_tables, Tab), + ( b_hash_lookup(Key, V1, Tab) -> + V1=V + ; + b_hash_insert(Tab, Key, V, NewTab), + b_setval(clpbn_tables,NewTab), + once(M:S2) + ) + ) + ). take_tail([V], V, [], V1, [V1]) :- !. take_tail([A|L0], V, [A|L1], V1, [A|L2]) :- take_tail(L0, V, L1, V1, L2). +clpbn_tableallargs(M:X) :- !, + clpbn_tableallargs(X,M). +clpbn_tableallargs(X) :- + prolog_load_context(module, M), + clpbn_tableallargs(X,M). + +clpbn_tableallargs(M:X,_) :- !, + clpbn_tableallargs(X,M). +clpbn_tableallargs((P1,P2),M) :- !, + clpbn_tableallargs(P1,M), + clpbn_tableallargs(P2,M). +clpbn_tableallargs(F/N,M) :- + functor(Key,F,N), + Key =.. [F|Args], + atom_concat(F, '___tabled', NF), + NKey =.. [NF|Args], + asserta(clpbn_table(Key, M, NKey)), + assert( + (M:Key :- + b_getval(clpbn_tables, Tab), + ( b_hash_lookup(Key, Out, Tab) -> + true + ; + b_hash_insert(Tab, Key, Out, NewTab), + b_setval(clpbn_tables, NewTab), + once(M:NKey) + ) + ) + ). + +clpbn_table_nondet(M:X) :- !, + clpbn_table_nondet(X,M). +clpbn_table_nondet(X) :- + prolog_load_context(module, M), + clpbn_table_nondet(X,M). + +clpbn_table_nondet(M:X,_) :- !, + clpbn_table_nondet(X,M). +clpbn_table_nondet((P1,P2),M) :- !, + clpbn_table_nondet(P1,M), + clpbn_table_nondet(P2,M). +clpbn_table_nondet(F/N,M) :- + functor(Key,F,N), + Key =.. [F|Args], + atom_concat(F, '___tabled', NF), + NKey =.. [NF|Args], + asserta(clpbn_table(Key, M, NKey)), + assert( + (M:Key :- writeln(in:Key), + b_getval(clpbn_tables, Tab), + ( b_hash_lookup(Key, Out, Tab) -> + fail + ; + b_hash_insert(Tab, Key, Out, NewTab), + b_setval(clpbn_tables, NewTab), + M:NKey + ) + ) + ). + user:term_expansion((P :- Gs), NC) :- clpbn_table(P, M, NP), prolog_load_context(module, M), !, @@ -86,11 +182,11 @@ user:term_expansion((P :- Gs), NC) :- NC = (:-true). in_table(K, V) :- - nb_getval(clpbn_tables, Tab), + b_getval(clpbn_tables, Tab), b_hash_lookup(K, V, Tab). store_in_table(K, V) :- - nb_getval(clpbn_tables, Tab), + b_getval(clpbn_tables, Tab), b_hash_insert(Tab, K, V). clpbn_tabled_clause(M:Head, Body) :- !, diff --git a/packages/PLStream/Makefile.in b/packages/PLStream/Makefile.in index b59e96035..70a2c8d1d 100644 --- a/packages/PLStream/Makefile.in +++ b/packages/PLStream/Makefile.in @@ -6,6 +6,7 @@ GCC=@GCC@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/packages/ProbLog/problog.yap b/packages/ProbLog/problog.yap index 058e641c4..b2216e155 100644 --- a/packages/ProbLog/problog.yap +++ b/packages/ProbLog/problog.yap @@ -24,6 +24,7 @@ problog_max/3, problog_exact/3, problog_montecarlo/3, + problog_table/1, get_fact_probability/2, set_fact_probability/2, get_fact/2, @@ -65,7 +66,10 @@ % op attaching probabilities to facts :- op( 550, yfx, :: ). +:- op( 1150, fx, problog_table ). +:- meta_predicate problog_table(:). + %%%%%%%%%%%%%%%%%%%%%%%% % control predicates on various levels %%%%%%%%%%%%%%%%%%%%%%%% @@ -99,6 +103,10 @@ :- dynamic dynamic_probability_fact/1. :- dynamic dynamic_probability_fact_extract/2. + +% keep a tab on tabling +:- dynamic problog_tabled/1. + % directory where ProblogBDD executable is located % automatically set during loading -- assumes it is in same place as this file (problog.yap) %:- getcwd(PD),retractall(problog_dir(_)),assert(problog_dir(PD)). @@ -221,8 +229,9 @@ user:term_expansion(P::Goal, problog:ProbFact) :- append(Args,[LProb],L1), probclause_id(ID), ProbFact =.. [ProblogName,ID|L1], + assert_static(prob_for_id(ID,P)), ( - (\+ var(P), P = t(TrueProb)) + (nonvar(P), P = t(TrueProb)) -> ( assert(tunable_fact(ID,TrueProb)), @@ -257,7 +266,7 @@ user:term_expansion(P::Goal, problog:ProbFact) :- assert(non_ground_fact(ID)) ), problog_predicate(Name, Arity, ProblogName). - + % introduce wrapper clause if predicate seen first time problog_predicate(Name, Arity, _) :- @@ -269,7 +278,6 @@ problog_predicate(Name, Arity, ProblogName) :- append(Args,[Prob],L1), ProbFact =.. [ProblogName,ID|L1], prolog_load_context(module,Mod), - assert( (Mod:OriginalGoal :- ProbFact, ( non_ground_fact(ID) @@ -342,12 +350,15 @@ reset_non_ground_facts :- % cut choice points if ID is ground (they'll all fail as ID is unique), % but not if it isn't (used to iterate over all facts when writing out probabilities for learning) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +get_fact_probability(ID,Prob) :- + ground(ID), !, + prob_for_id(ID,Prob). get_fact_probability(ID,Prob) :- ( - ground(ID) -> - get_internal_fact(ID,ProblogTerm,_ProblogName,ProblogArity),! + ground(ID) -> + get_internal_fact(ID,ProblogTerm,_ProblogName,ProblogArity),! ; - get_internal_fact(ID,ProblogTerm,_ProblogName,ProblogArity) + get_internal_fact(ID,ProblogTerm,_ProblogName,ProblogArity) ), arg(ProblogArity,ProblogTerm,Log), Prob is exp(Log). @@ -1131,6 +1142,8 @@ mc_prove(A) :- !, clean_sample :- reset_static_array(mc_sample), + problog_tabled(P), + abolish_table(P), fail. clean_sample. @@ -1142,3 +1155,18 @@ get_some_proof(Goal) :- (Used == [] -> Proof=true; reverse(Used,Proof)), insert_ptree(Proof,1). +problog_table(M:P) :- !, + problog_table(P,M). +problog_table(P) :- + prolog_load_context(module,M), + problog_table(P,M). + +problog_table(M:P,_) :- + problog_table(P,M). +problog_table((P1,P2),M) :- + problog_table(P1,M), + problog_table(P2,M). +problog_table(P,M) :- + table(M:P), + assert(problog_tabled(M:P)). + diff --git a/packages/ProbLog/simplecudd/Makefile.in b/packages/ProbLog/simplecudd/Makefile.in index a1955eca7..e11a3559f 100644 --- a/packages/ProbLog/simplecudd/Makefile.in +++ b/packages/ProbLog/simplecudd/Makefile.in @@ -5,6 +5,7 @@ prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ # # where the binary should be # diff --git a/packages/chr b/packages/chr index cba31e063..e071f01c1 160000 --- a/packages/chr +++ b/packages/chr @@ -1 +1 @@ -Subproject commit cba31e06301d475e572a2f377061c7b5014b4254 +Subproject commit e071f01c1d9015e6d3fabc73092a6e902541485a diff --git a/packages/clpqr b/packages/clpqr index 3cda12359..e3ee70d59 160000 --- a/packages/clpqr +++ b/packages/clpqr @@ -1 +1 @@ -Subproject commit 3cda12359a93d7d9e337cc564b7bfacf40fc8cb5 +Subproject commit e3ee70d5971a5af8c9a2a3a5fe8a1892c3777f2b diff --git a/packages/jpl b/packages/jpl index 884300248..eb6d27251 160000 --- a/packages/jpl +++ b/packages/jpl @@ -1 +1 @@ -Subproject commit 8843002483df3078583ca8495630a1b864a7999f +Subproject commit eb6d27251c2548c25e6d37fff2a27a014caaa7aa diff --git a/packages/sgml/Makefile.in b/packages/sgml/Makefile.in index 27bc6d1fc..7909b2d35 100644 --- a/packages/sgml/Makefile.in +++ b/packages/sgml/Makefile.in @@ -11,6 +11,7 @@ ifeq (@PROLOG_SYSTEM@,yap) prefix = @prefix@ ROOTDIR = $(prefix) EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ srcdir=@srcdir@ @@ -20,7 +21,7 @@ YAPLIBDIR=$(EROOTDIR)/lib/Yap SHAREDIR=$(ROOTDIR)/share/Yap SHELL=@SHELL@ -PL=@EXTEND_DYNLOADER_PATH@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup +PL=@EXTEND_DYNLOADER_PATH@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup.yss CHRDIR=$(SHAREDIR)/chr EXDIR=$(CHRDIR)/examples/chr LN_S=@LN_S@