You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(72) |
Jul
(30) |
Aug
(31) |
Sep
(41) |
Oct
(22) |
Nov
(70) |
Dec
(98) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(194) |
Feb
(127) |
Mar
(47) |
Apr
(83) |
May
(154) |
Jun
(149) |
Jul
(49) |
Aug
(64) |
Sep
(98) |
Oct
(104) |
Nov
(99) |
Dec
(109) |
| 2003 |
Jan
(72) |
Feb
(105) |
Mar
(76) |
Apr
(66) |
May
(20) |
Jun
(51) |
Jul
(67) |
Aug
(16) |
Sep
(24) |
Oct
(52) |
Nov
(43) |
Dec
(92) |
| 2004 |
Jan
(16) |
Feb
(145) |
Mar
(137) |
Apr
(140) |
May
(29) |
Jun
(214) |
Jul
(167) |
Aug
(202) |
Sep
(188) |
Oct
(228) |
Nov
(283) |
Dec
(250) |
| 2005 |
Jan
(107) |
Feb
(162) |
Mar
(100) |
Apr
(110) |
May
(144) |
Jun
(19) |
Jul
(23) |
Aug
(127) |
Sep
(20) |
Oct
(76) |
Nov
(85) |
Dec
(171) |
| 2006 |
Jan
(86) |
Feb
(134) |
Mar
(213) |
Apr
(70) |
May
(81) |
Jun
(25) |
Jul
(6) |
Aug
(36) |
Sep
(20) |
Oct
(21) |
Nov
(368) |
Dec
(164) |
| 2007 |
Jan
(239) |
Feb
(126) |
Mar
(148) |
Apr
(24) |
May
(48) |
Jun
(238) |
Jul
(18) |
Aug
(13) |
Sep
(59) |
Oct
(73) |
Nov
(224) |
Dec
(39) |
| 2008 |
Jan
(53) |
Feb
(92) |
Mar
(134) |
Apr
(81) |
May
(53) |
Jun
(210) |
Jul
(31) |
Aug
(38) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2009 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Vitor S. C. <vs...@us...> - 2008-06-11 11:08:20
|
Update of /cvsroot/yap/library In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11340/library Modified Files: rbtrees.yap Log Message: some nice extra predicatesy Index: rbtrees.yap =================================================================== RCS file: /cvsroot/yap/library/rbtrees.yap,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- rbtrees.yap 8 Jun 2008 08:05:11 -0000 1.14 +++ rbtrees.yap 11 Jun 2008 11:08:25 -0000 1.15 @@ -20,6 +20,7 @@ rb_apply/4, % +T, +Key, :G, -TN rb_lookupall/3, % +Key, -Value, +T rb_insert/4, % +T0, +Key, ?Value, -TN + rb_insert_new/4, % +T0, +Key, ?Value, -TN rb_delete/3, % +T, +Key, -TN rb_delete/4, % +T, +Key, -Val, -TN rb_visit/2, % +T, -Pairs @@ -346,13 +347,6 @@ fix_root(TreeI,Tree). % -% make sure the root is always black. -% -fix_root(black(L,K,V,R),black(L,K,V,R)). -fix_root(red(L,K,V,R),black(L,K,V,R)). - - -% % Cormen et al present the algorithm as % (1) standard tree insertion; % (2) from the viewpoint of the newly inserted node: @@ -402,6 +396,53 @@ fix_right(Flag0, black(L,K0,V0,IR), NT, Flag) ). +% We don't use parent nodes, so we may have to fix the root. + +%% rb_insert_new(+T0, +Key, ?Value, -TN) +% +% Add a new element with key Key and Value to the tree T0 creating a +% new red-black tree TN. Duplicated elements are not allowed. + +insert_new(Tree0,Key,Val,Nil,Tree) :- + insert_new_2(Tree0,Key,Val,Nil,TreeI,_), + fix_root(TreeI,Tree). + +% +% actual insertion, copied from insert2 +% +insert_new_2(black([],[],[],[]), K, V, Nil, T, Status) :- !, + T = red(Nil,K,V,Nil), + Status = not_done. +insert_new_2(red(L,K0,V0,R), K, V, Nil, NT, Flag) :- + ( K @< K0 + -> NR = R, + NT = red(NL,K0,V0,R), + insert_new_2(L, K, V, Nil, NL, Flag) + ; K == K0 -> + fail + ; + NT = red(L,K0,V0,NR), + insert2(R, K, V, Nil, NR, Flag) + ). +insert_new_2(black(L,K0,V0,R), K, V, Nil, NT, Flag) :- + ( K @< K0 + -> insert_new_2(L, K, V, Nil, IL, Flag0), + fix_left(Flag0, black(IL,K0,V0,R), NT, Flag) + ; K == K0 -> + fail + ; + insert_new_2(R, K, V, Nil, IR, Flag0), + fix_right(Flag0, black(L,K0,V0,IR), NT, Flag) + ). + +% +% make sure the root is always black. +% +fix_root(black(L,K,V,R),black(L,K,V,R)). +fix_root(red(L,K,V,R),black(L,K,V,R)). + + + % % How to fix if we have inserted on the left % |
|
From: Vitor S. C. <vs...@us...> - 2008-06-11 11:08:20
|
Update of /cvsroot/yap/C In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11340/C Modified Files: arrays.c Log Message: some nice extra predicatesy Index: arrays.c =================================================================== RCS file: /cvsroot/yap/C/arrays.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- arrays.c 1 Jul 2007 00:14:35 -0000 1.48 +++ arrays.c 11 Jun 2008 11:08:24 -0000 1.49 @@ -692,6 +692,95 @@ WRITE_UNLOCK(pp->ArRWLock); } +static void +ClearStaticArray(StaticArrayEntry *pp) +{ + statarray_elements old_v = pp->ValueOfVE; + static_array_types type = pp->ArrayType; + Int dim = - pp->ArrayEArity, i; + + /* change official size */ + if (pp->ArrayEArity >= 0){ + return; + } + WRITE_LOCK(pp->ArRWLock); + switch(type) { + case array_of_ints: + memset((void *)pp->ValueOfVE.ints,0,sizeof(int)*dim); + break; + case array_of_chars: + memset((void *)pp->ValueOfVE.chars,0,sizeof(char)*dim); + break; + case array_of_uchars: + memset((void *)pp->ValueOfVE.uchars,0,sizeof(unsigned char)*dim); + break; + case array_of_doubles: + memset((void *)pp->ValueOfVE.floats,0,sizeof(double)*dim); + break; + case array_of_ptrs: + memset((void *)pp->ValueOfVE.ptrs,0,sizeof(void *)*dim); + break; + case array_of_atoms: + for (i = 0; i< dim; i++) + pp->ValueOfVE.atoms[i] = TermNil; + break; + case array_of_dbrefs: + for (i = 0; i < dim; i++) { + Term t0 = pp->ValueOfVE.dbrefs[i]; + if (t0 != 0L) { + DBRef ptr = DBRefOfTerm(t0); + + if (ptr->Flags & LogUpdMask) { + LogUpdClause *lup = (LogUpdClause *)ptr; + LOCK(lup->ClLock); + lup->ClRefCount--; + if (lup->ClRefCount == 0 && + (lup->ClFlags & ErasedMask) && + !(lup->ClFlags & InUseMask)) { + UNLOCK(lup->ClLock); + Yap_ErLogUpdCl(lup); + } else { + UNLOCK(lup->ClLock); + } + } else { + ptr->NOfRefsTo--; + if (ptr->NOfRefsTo == 0 && + (ptr->Flags & ErasedMask) && + !(ptr->Flags & InUseMask)) { + Yap_ErDBE(ptr); + } + } + } + pp->ValueOfVE.dbrefs[i] = 0L; + } + break; + case array_of_terms: + for (i = 0; i < dim; i++) { + DBTerm *ref = pp->ValueOfVE.terms[i]; + + if (ref != NULL) { + Yap_ReleaseTermFromDB(ref); + } + pp->ValueOfVE.terms[i] = NULL; + } + break; + case array_of_nb_terms: + for (i = 0; i < dim; i++) { + Term told = pp->ValueOfVE.lterms[i].tstore; + CELL *livep = &(pp->ValueOfVE.lterms[i].tlive); + + RESET_VARIABLE(livep); + /* recover space */ + if (IsApplTerm(told)) { + Yap_ReleaseTermFromDB((DBTerm *)RepAppl(told)); + } + pp->ValueOfVE.lterms[i].tstore = old_v.lterms[i].tstore; + } + break; + } + WRITE_UNLOCK(pp->ArRWLock); +} + /* create an array (?Name, + Size) */ static Int p_create_array(void) @@ -1008,6 +1097,37 @@ } } +/* resize a static array (+Name, + Size, +Props) */ +/* does not work for mmap arrays yet */ +static Int +p_clear_static_array(void) +{ + Term t = Deref(ARG1); + + if (IsVarTerm(t)) { + Yap_Error(INSTANTIATION_ERROR,t,"clear a static array"); + return FALSE; + } + else if (IsAtomTerm(t)) { + /* resize a named array */ + Atom a = AtomOfTerm(t); + StaticArrayEntry *pp = RepStaticArrayProp(RepAtom(a)->PropsOfAE); + + while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty) + pp = RepStaticArrayProp(pp->NextOfPE); + if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { + Yap_Error(PERMISSION_ERROR_RESIZE_ARRAY,t,"clear a static array"); + return FALSE; + } else { + ClearStaticArray(pp); + return TRUE; + } + } else { + Yap_Error(TYPE_ERROR_ATOM,t,"clear a static array"); + return FALSE; + } +} + /* Close a named array (+Name) */ static Int p_close_static_array(void) @@ -2368,6 +2488,7 @@ Yap_InitCPred("dynamic_update_array", 3, p_assign_dynamic, SafePredFlag); Yap_InitCPred("add_to_array_element", 4, p_add_to_array_element, SafePredFlag); Yap_InitCPred("array_element", 3, p_access_array, 0); + Yap_InitCPred("reset_static_array", 1, p_clear_static_array, SafePredFlag); Yap_InitCPred("close_static_array", 1, p_close_static_array, SafePredFlag); Yap_InitCPred("$sync_mmapped_arrays", 0, p_sync_mmapped_arrays, SafePredFlag|HiddenPredFlag); Yap_InitCPred("$compile_array_refs", 0, p_compile_array_refs, SafePredFlag|HiddenPredFlag); |
|
From: Fabrizio R. <rz...@us...> - 2008-06-09 17:57:27
|
Update of /cvsroot/yap/cplint In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv13532 Modified Files: cplint_yap.c lpadsld.pl testlpadsldit.pl Added Files: testlpadslditc.pl testlpadslditr.pl Log Message: added a new version of iterative deepening --- NEW FILE: testlpadslditc.pl --- /* LPAD and CP-Logic reasoning suite Copyright (c) 2007, Fabrizio Riguzzi Test file for lpadsld.pl, case where the body is grounded Use :-t. to execute the test */ :-source. :-use_module(library(lpadsld)). epsilon(0.000001). close_to(V,T):- epsilon(E), TLow is T-E, THigh is T+E, TLow<V, V<THigh. t:- format("~nTesting iterative deepening lpadsld.yap~n~n",[]), files(F), statistics(runtime,[_,_]), set(ground_body,true), set(depth_bound,7), set(min_error,0.05), format("~nGround body~n~n",[]), test_filesi(F,ground_body(true)), statistics(runtime,[_,T]), T1 is T /1000, format("Test successful, time ~f secs.~n",[T1]). t:- format("Test unsuccessful.~n",[]). test_filesi([],_GB). test_filesi([H|T],GB):- library_directory(LD), atom_concat(LD,'/cplint/examples/',ExDir), atom_concat(ExDir,H,NH), p(NH),!, findall(A,test(A,H,GB),L), test_alli(H,L), test_filesi(T,GB). test_alli(_F,[]). test_alli(F,[H|T]):- copy_term(H,NH), NH=(s(Q,_P),close_to('P',P)),!, format("~a ~p.~n",[F,NH]), sic(Q,PL,PU,_Time),!, format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), P>=PL-1e-7,P=<PU+1e-7, test_alli(F,T). test_alli(F,[H|T]):- copy_term(H,NH), NH=(sc(Q,E,_P),close_to('P',P)), format("~a ~p.~n",[F,NH]), scic(Q,E,PL,PU,_Time),!, format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), P>=PL-1e-10,P=<PU+1e-10, test_alli(F,T). files([ exapprox, exrange, threesideddice, mendel, coin2,ex,trigger,throws,light ]). test((s([death],P),close_to(P,0.305555555555556)),trigger,_). test((s([throws(mary),throws(john),break],P),close_to(P,0.46)),throws,_). test((s([throws(mary),throws(john),\+break],P),close_to(P,0.04)),throws,_). test((s([\+ throws(mary),throws(john),break],P),close_to(P,0.3)),throws,_). test((s([\+ throws(mary),throws(john),\+ break],P),close_to(P,0.2)),throws,_). test((s([push,replace],P),close_to(P,0.5)),light,_). test((s([push,light],P),close_to(P,0.5)),light,_). test((s([push,light,replace],P),close_to(P,0)),light,_). test((s([light,replace],P),close_to(P,0)),light,_). test((s([light],P),close_to(P,0.5)),light,_). test((s([replace],P),close_to(P,0.5)),light,_). test((s([\+ cites_cited(c1,p1)],P),close_to(P,0.7)),paper_ref_not,_). test((s([cites_citing(c1,p1)],P),close_to(P,0.14)),paper_ref_not,_). test((s([cites_cited(c1,p1)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p2)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p4)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p3)],P),close_to(P,0.228)),paper_ref,_). test((s([cites_cited(c1,p5)],P),close_to(P,0.228)),paper_ref,_). test((s([female(f)],P),close_to(P,0.6)),female,_). test((s([male(f)],P),close_to(P,0.4)),female,_). test((s([a],P),close_to(P,0.1719)),exapprox,ground_body(true)). test((s([a],P),close_to(P,0.099)),exapprox,ground_body(false)). test((s([a(1)],P),close_to(P,0.2775)),exrange,_). test((s([a(2)],P),close_to(P,0.36)),exrange,_). test((s([on(0,1)],P),close_to(P,0.333333333333333)),threesideddice,_). test((s([on(1,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((s([on(2,1)],P),close_to(P,0.148148147703704)),threesideddice,_). test((s([on(3,1)],P),close_to(P,0.0987654320987654)),threesideddice,_). test((s([on(4,1)],P),close_to(P,0.0658436213991769)),threesideddice,_). test((sc([on(2,1)],[on(0,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((sc([on(2,1)],[on(1,1)],P),close_to(P,0.333333333333333)),threesideddice,_). test((sc([on(4,1)],[on(1,1)],P),close_to(P, 0.148148148148148)),threesideddice,_). test((sc([on(5,1)],[on(2,1)],P),close_to(P, 0.148148148148148)),threesideddice,_). test((s([cg(s,1,p)],P),close_to(P,0.75)),mendel,_). test((s([cg(s,1,w)],P),close_to(P,0.25)),mendel,_). test((s([cg(s,2,p)],P),close_to(P,0.25)),mendel,_). test((s([cg(s,2,w)],P),close_to(P,0.75)),mendel,_). test((s([cg(f,2,w)],P),close_to(P,0.5)),mendel,_). test((s([cg(s,2,w)],P),close_to(P,0.75)),mendel,_). test((s([a],P),close_to(P,0.226)),ex,_). test((s([heads(coin1)],P),close_to(P,0.51)),coin2,_). test((s([heads(coin2)],P),close_to(P,0.51)),coin2,_). test((s([tails(coin1)],P),close_to(P,0.49)),coin2,_). test((s([tails(coin2)],P),close_to(P,0.49)),coin2,_). test((s([student_rank(jane_doe,h)],P),close_to(P,0.465)),student,_). test((s([student_rank(jane_doe,l)],P),close_to(P,0.535)),student,_). test((s([course_rat(phil101,h)],P),close_to(P,0.330656)),student,_). test((s([course_rat(phil101,l)],P),close_to(P,0.669344)),student,_). test((s([professor_ability(p0,h)],P),close_to(P,0.5)),school,_). test((s([professor_ability(p0,m)],P),close_to(P,0.4)),school,_). test((s([professor_ability(p0,l)],P),close_to(P,0.1)),school,_). test((s([professor_popularity(p0,h)],P),close_to(P,0.531)),school,_). test((s([professor_popularity(p0,l)],P),close_to(P,0.175)),school,_). test((s([professor_popularity(p0,m)],P),close_to(P,0.294)),school,_). test((sc([professor_ability(p0,h)],[professor_popularity(p0,h)],P),close_to(P,0.847457627118644)),school,_). test((sc([professor_ability(p0,l)],[professor_popularity(p0,h)],P),close_to(P,0.00188323917137476)),school,_). test((sc([professor_ability(p0,m)],[professor_popularity(p0,h)],P),close_to(P,0.150659133709981)),school,_). test((sc([professor_popularity(p0,h)],[professor_ability(p0,h)],P),close_to(P,0.9)),school,_). test((sc([professor_popularity(p0,l)],[professor_ability(p0,h)],P),close_to(P,0.01)),school,_). test((sc([professor_popularity(p0,m)],[professor_ability(p0,h)],P),close_to(P,0.09)),school,_). test(( s([registration_grade(r0,1)],P),close_to(P,0.06675)),school,_). test(( s([registration_grade(r0,2)],P),close_to(P,0.16575)),school,_). test(( s([registration_grade(r0,3)],P),close_to(P, 0.356)),school,_). test(( s([registration_grade(r0,4)],P),close_to(P,0.4115)),school,_). test((sc([registration_grade(r0,1)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.15)),school,_). test((sc([registration_grade(r0,2)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.285)),school,_). test((sc([registration_grade(r0,3)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.424)),school,_). test((sc([registration_grade(r0,4)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.141)),school,_). test((sc([registration_grade(r0,1)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.05)),school,_). test((sc([registration_grade(r0,2)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.15)),school,_). test((sc([registration_grade(r0,3)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.6)),school,_). test((sc([registration_grade(r0,4)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.2)),school,_). test((sc([registration_grade(r0,1)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.01)),school,_). test((sc([registration_grade(r0,2)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.02)),school,_). test((sc([registration_grade(r0,3)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.12)),school,_). test((sc([registration_grade(r0,4)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.85)),school,_). test((s([registration_satisfaction(r0,1)],P),close_to(P,0.15197525)),school,_). test((s([registration_satisfaction(r0,2)],P),close_to(P,0.1533102)),school,_). test((s([registration_satisfaction(r0,3)],P),close_to(P,0.6947145)),school,_). test((sc([registration_satisfaction(r0,1)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.0959225)),school,_). test((sc([registration_satisfaction(r0,2)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.124515)),school,_). test((sc([registration_satisfaction(r0,3)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.7795625)),school,_). test((sc([registration_satisfaction(r0,1)],[registration_grade(r0,4)],P),close_to(P,0.04)),school,_). test((sc([registration_satisfaction(r0,2)],[registration_grade(r0,4)],P),close_to(P,0.06)),school,_). test((sc([registration_satisfaction(r0,3)],[registration_grade(r0,4)],P),close_to(P,0.9)),school,_). test((sc([registration_satisfaction(r0,1)],[registration_grade(r0,1)],P),close_to(P,0.528)),school,_). test((sc([registration_satisfaction(r0,2)],[registration_grade(r0,1)],P),close_to(P,0.167)),school,_). test((sc([registration_satisfaction(r0,3)],[registration_grade(r0,1)],P),close_to(P,0.305)),school,_). test((sc([ registration_grade(r0,1)],[registration_satisfaction(r0,3)],P),close_to(P,0.0293052037923492)),school,_). test((sc([ registration_grade(r0,2)],[registration_satisfaction(r0,3)],P),close_to(P, 0.114760451955444)),school,_). test((sc([ registration_grade(r0,3)],[registration_satisfaction(r0,3)],P),close_to(P,0.322837654892765)),school,_). test((sc([ registration_grade(r0,4)],[registration_satisfaction(r0,3)],P),close_to(P,0.533096689359442)),school,_). test((s([course_rating(c0,h)],P),close_to(P,0.5392099)),school,_). test((s([course_rating(c0,l)],P),close_to(P, 0.2)),school,_). test((s([course_rating(c0,m)],P),close_to(P,0.2607901)),school,_). test((sc([course_difficulty(c0,h)],[course_rating(c0,h)],P),close_to(P,0.235185778302661)),school,_). test((sc([course_difficulty(c0,l)],[course_rating(c0,h)],P),close_to(P,0.259096503977393)),school,_). test((sc([course_difficulty(c0,m)],[course_rating(c0,h)],P),close_to(P,0.505717717719945)),school,_). test((s([course_difficulty(c0,h)],P),close_to(P,0.25)),school,_). test((s([course_difficulty(c0,l)],P),close_to(P,0.25)),school,_). test((s([course_difficulty(c0,m)],P),close_to(P,0.5)),school,_). test((s([student_ranking(s0,h)],P),close_to(P,0.6646250000000005)),school_simple,_). test((s([student_ranking(s0,l)],P),close_to(P,0.33537499999999987)),school_simple,_). --- NEW FILE: testlpadslditr.pl --- /* LPAD and CP-Logic reasoning suite Copyright (c) 2007, Fabrizio Riguzzi Test file for lpadsld.pl, case where the body is grounded Use :-t. to execute the test */ :-source. :-use_module(library(lpadsld)). epsilon(0.000001). close_to(V,T):- epsilon(E), TLow is T-E, THigh is T+E, TLow<V, V<THigh. t:- format("~nTesting iterative deepening lpadsld.yap~n~n",[]), files(F), statistics(runtime,[_,_]), set(ground_body,true), set(depth_bound,1), set(min_error,0.05), format("~nGround body~n~n",[]), test_filesi(F,ground_body(true)), statistics(runtime,[_,T]), T1 is T /1000, format("Test successful, time ~f secs.~n",[T1]). t:- format("Test unsuccessful.~n",[]). test_filesi([],_GB). test_filesi([H|T],GB):- library_directory(LD), atom_concat(LD,'/cplint/examples/',ExDir), atom_concat(ExDir,H,NH), p(NH),!, findall(A,test(A,H,GB),L), test_alli(H,L), test_filesi(T,GB). test_alli(_F,[]). test_alli(F,[H|T]):- copy_term(H,NH), NH=(s(Q,_P),close_to('P',P)),!, format("~a ~p.~n",[F,NH]), sir(Q,PL,PU,_Time),!, format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), P>=PL-1e-7,P=<PU+1e-7, test_alli(F,T). test_alli(F,[H|T]):- copy_term(H,NH), NH=(sc(Q,E,_P),close_to('P',P)), format("~a ~p.~n",[F,NH]), scir(Q,E,PL,PU,_Time),!, format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), P>=PL-1e-10,P=<PU+1e-10, test_alli(F,T). files([ %exapprox,exrange, threesideddice, mendel, coin2,ex,trigger,throws,light]). test((s([death],P),close_to(P,0.305555555555556)),trigger,_). test((s([throws(mary),throws(john),break],P),close_to(P,0.46)),throws,_). test((s([throws(mary),throws(john),\+break],P),close_to(P,0.04)),throws,_). test((s([\+ throws(mary),throws(john),break],P),close_to(P,0.3)),throws,_). test((s([\+ throws(mary),throws(john),\+ break],P),close_to(P,0.2)),throws,_). test((s([push,replace],P),close_to(P,0.5)),light,_). test((s([push,light],P),close_to(P,0.5)),light,_). test((s([push,light,replace],P),close_to(P,0)),light,_). test((s([light,replace],P),close_to(P,0)),light,_). test((s([light],P),close_to(P,0.5)),light,_). test((s([replace],P),close_to(P,0.5)),light,_). test((s([\+ cites_cited(c1,p1)],P),close_to(P,0.7)),paper_ref_not,_). test((s([cites_citing(c1,p1)],P),close_to(P,0.14)),paper_ref_not,_). test((s([cites_cited(c1,p1)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p2)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p4)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p3)],P),close_to(P,0.228)),paper_ref,_). test((s([cites_cited(c1,p5)],P),close_to(P,0.228)),paper_ref,_). test((s([female(f)],P),close_to(P,0.6)),female,_). test((s([male(f)],P),close_to(P,0.4)),female,_). test((s([a],P),close_to(P,0.1719)),exapprox,ground_body(true)). test((s([a],P),close_to(P,0.099)),exapprox,ground_body(false)). test((s([a(1)],P),close_to(P,0.2775)),exrange,_). test((s([a(2)],P),close_to(P,0.36)),exrange,_). test((s([on(0,1)],P),close_to(P,0.333333333333333)),threesideddice,_). test((s([on(1,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((s([on(2,1)],P),close_to(P,0.148148147703704)),threesideddice,_). test((s([on(3,1)],P),close_to(P,0.0987654320987654)),threesideddice,_). test((s([on(4,1)],P),close_to(P,0.0658436213991769)),threesideddice,_). test((sc([on(2,1)],[on(0,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((sc([on(2,1)],[on(1,1)],P),close_to(P,0.333333333333333)),threesideddice,_). test((sc([on(4,1)],[on(1,1)],P),close_to(P, 0.148148148148148)),threesideddice,_). test((sc([on(5,1)],[on(2,1)],P),close_to(P, 0.148148148148148)),threesideddice,_). test((s([cg(s,1,p)],P),close_to(P,0.75)),mendel,_). test((s([cg(s,1,w)],P),close_to(P,0.25)),mendel,_). test((s([cg(s,2,p)],P),close_to(P,0.25)),mendel,_). test((s([cg(s,2,w)],P),close_to(P,0.75)),mendel,_). test((s([cg(f,2,w)],P),close_to(P,0.5)),mendel,_). test((s([cg(s,2,w)],P),close_to(P,0.75)),mendel,_). test((s([a],P),close_to(P,0.226)),ex,_). test((s([heads(coin1)],P),close_to(P,0.51)),coin2,_). test((s([heads(coin2)],P),close_to(P,0.51)),coin2,_). test((s([tails(coin1)],P),close_to(P,0.49)),coin2,_). test((s([tails(coin2)],P),close_to(P,0.49)),coin2,_). test((s([student_rank(jane_doe,h)],P),close_to(P,0.465)),student,_). test((s([student_rank(jane_doe,l)],P),close_to(P,0.535)),student,_). test((s([course_rat(phil101,h)],P),close_to(P,0.330656)),student,_). test((s([course_rat(phil101,l)],P),close_to(P,0.669344)),student,_). test((s([professor_ability(p0,h)],P),close_to(P,0.5)),school,_). test((s([professor_ability(p0,m)],P),close_to(P,0.4)),school,_). test((s([professor_ability(p0,l)],P),close_to(P,0.1)),school,_). test((s([professor_popularity(p0,h)],P),close_to(P,0.531)),school,_). test((s([professor_popularity(p0,l)],P),close_to(P,0.175)),school,_). test((s([professor_popularity(p0,m)],P),close_to(P,0.294)),school,_). test((sc([professor_ability(p0,h)],[professor_popularity(p0,h)],P),close_to(P,0.847457627118644)),school,_). test((sc([professor_ability(p0,l)],[professor_popularity(p0,h)],P),close_to(P,0.00188323917137476)),school,_). test((sc([professor_ability(p0,m)],[professor_popularity(p0,h)],P),close_to(P,0.150659133709981)),school,_). test((sc([professor_popularity(p0,h)],[professor_ability(p0,h)],P),close_to(P,0.9)),school,_). test((sc([professor_popularity(p0,l)],[professor_ability(p0,h)],P),close_to(P,0.01)),school,_). test((sc([professor_popularity(p0,m)],[professor_ability(p0,h)],P),close_to(P,0.09)),school,_). test(( s([registration_grade(r0,1)],P),close_to(P,0.06675)),school,_). test(( s([registration_grade(r0,2)],P),close_to(P,0.16575)),school,_). test(( s([registration_grade(r0,3)],P),close_to(P, 0.356)),school,_). test(( s([registration_grade(r0,4)],P),close_to(P,0.4115)),school,_). test((sc([registration_grade(r0,1)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.15)),school,_). test((sc([registration_grade(r0,2)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.285)),school,_). test((sc([registration_grade(r0,3)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.424)),school,_). test((sc([registration_grade(r0,4)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.141)),school,_). test((sc([registration_grade(r0,1)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.05)),school,_). test((sc([registration_grade(r0,2)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.15)),school,_). test((sc([registration_grade(r0,3)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.6)),school,_). test((sc([registration_grade(r0,4)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.2)),school,_). test((sc([registration_grade(r0,1)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.01)),school,_). test((sc([registration_grade(r0,2)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.02)),school,_). test((sc([registration_grade(r0,3)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.12)),school,_). test((sc([registration_grade(r0,4)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.85)),school,_). test((s([registration_satisfaction(r0,1)],P),close_to(P,0.15197525)),school,_). test((s([registration_satisfaction(r0,2)],P),close_to(P,0.1533102)),school,_). test((s([registration_satisfaction(r0,3)],P),close_to(P,0.6947145)),school,_). test((sc([registration_satisfaction(r0,1)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.0959225)),school,_). test((sc([registration_satisfaction(r0,2)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.124515)),school,_). test((sc([registration_satisfaction(r0,3)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.7795625)),school,_). test((sc([registration_satisfaction(r0,1)],[registration_grade(r0,4)],P),close_to(P,0.04)),school,_). test((sc([registration_satisfaction(r0,2)],[registration_grade(r0,4)],P),close_to(P,0.06)),school,_). test((sc([registration_satisfaction(r0,3)],[registration_grade(r0,4)],P),close_to(P,0.9)),school,_). test((sc([registration_satisfaction(r0,1)],[registration_grade(r0,1)],P),close_to(P,0.528)),school,_). test((sc([registration_satisfaction(r0,2)],[registration_grade(r0,1)],P),close_to(P,0.167)),school,_). test((sc([registration_satisfaction(r0,3)],[registration_grade(r0,1)],P),close_to(P,0.305)),school,_). test((sc([ registration_grade(r0,1)],[registration_satisfaction(r0,3)],P),close_to(P,0.0293052037923492)),school,_). test((sc([ registration_grade(r0,2)],[registration_satisfaction(r0,3)],P),close_to(P, 0.114760451955444)),school,_). test((sc([ registration_grade(r0,3)],[registration_satisfaction(r0,3)],P),close_to(P,0.322837654892765)),school,_). test((sc([ registration_grade(r0,4)],[registration_satisfaction(r0,3)],P),close_to(P,0.533096689359442)),school,_). test((s([course_rating(c0,h)],P),close_to(P,0.5392099)),school,_). test((s([course_rating(c0,l)],P),close_to(P, 0.2)),school,_). test((s([course_rating(c0,m)],P),close_to(P,0.2607901)),school,_). test((sc([course_difficulty(c0,h)],[course_rating(c0,h)],P),close_to(P,0.235185778302661)),school,_). test((sc([course_difficulty(c0,l)],[course_rating(c0,h)],P),close_to(P,0.259096503977393)),school,_). test((sc([course_difficulty(c0,m)],[course_rating(c0,h)],P),close_to(P,0.505717717719945)),school,_). test((s([course_difficulty(c0,h)],P),close_to(P,0.25)),school,_). test((s([course_difficulty(c0,l)],P),close_to(P,0.25)),school,_). test((s([course_difficulty(c0,m)],P),close_to(P,0.5)),school,_). test((s([student_ranking(s0,h)],P),close_to(P,0.6646250000000005)),school_simple,_). test((s([student_ranking(s0,l)],P),close_to(P,0.33537499999999987)),school_simple,_). Index: cplint_yap.c =================================================================== RCS file: /cvsroot/yap/cplint/cplint_yap.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- cplint_yap.c 8 Jun 2008 18:11:41 -0000 1.4 +++ cplint_yap.c 9 Jun 2008 17:57:29 -0000 1.5 @@ -155,7 +155,7 @@ /* the BDD build by retFunction is converted to an ADD (algebraic decision diagram) because it is easier to interpret and to print */ add=Cudd_BddToAdd(mgr,function); - Cudd_PrintInfo(mgr,stderr); + //Cudd_PrintInfo(mgr,stderr); if (create_dot) /* if specified by the user, a dot file for the BDD is written to cpl.dot */ Index: lpadsld.pl =================================================================== RCS file: /cvsroot/yap/cplint/lpadsld.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- lpadsld.pl 8 Jun 2008 18:11:41 -0000 1.9 +++ lpadsld.pl 9 Jun 2008 17:57:30 -0000 1.10 @@ -23,6 +23,7 @@ not appearing in the head, the body represents an existential event */ setting(min_error,0.01). setting(depth_bound,4). +setting(prob_threshold,0.00001). /* end of list of parameters */ /* s(GoalsLIst,Prob) compute the probability of a list of goals @@ -102,14 +103,47 @@ si(GoalsList,ProbL,ProbU,CPUTime):- statistics(cputime,[_,_]), setting(depth_bound,D), - solvei(GoalsList,D,ProbL,ProbU), + solve_i([(GoalsList,[])],[],D,ProbL,ProbU), statistics(cputime,[_,CT]), CPUTime is CT/1000. -solvei(GoalsList,D,ProbL0,ProbU0):- - (setof(Deriv,find_deriv(GoalsList,D,Deriv),LDup)-> +solve_i(L0,Succ,D,ProbL0,ProbU0):- + (findall((G1,Deriv),(member((G0,C0),L0),solvei(G0,D,C0,Deriv,G1)),L)-> + % print_mem, + separate_ulbi(L,[],LL0,[],LU,[],Incomplete), + append(Succ,LL0,LL), + compute_prob_deriv(LL,ProbL), + append(Succ,LU,LU1), + compute_prob_deriv(LU1,ProbU), + Err is ProbU-ProbL, + setting(min_error,ME), + (Err<ME-> + ProbU0=ProbU, + ProbL0=ProbL + ; + setting(depth_bound,DB), + D1 is D+DB, + solve_i(Incomplete,LL,D1,ProbL0,ProbU0) + ) + ; + % print_mem, + ProbL0=0.0, + ProbU0=0.0 + ). + +sir(GoalsList,ProbL,ProbU,CPUTime):- + statistics(cputime,[_,_]), + setting(depth_bound,D), + solveir(GoalsList,D,ProbL,ProbU), + statistics(cputime,[_,CT]), + CPUTime is CT/1000. + + + +solveir(GoalsList,D,ProbL0,ProbU0):- + (setof(Deriv,find_derivr(GoalsList,D,Deriv),LDup)-> rem_dup_lists(LDup,[],L), % print_mem, separate_ulb(L,[],LL,[],LU), @@ -123,7 +157,7 @@ ; setting(depth_bound,DB), D1 is D+DB, - solvei(GoalsList,D1,ProbL0,ProbU0) + solveir(GoalsList,D1,ProbL0,ProbU0) ) ; % print_mem, @@ -131,6 +165,33 @@ ProbU0=0.0 ). + +sic(GoalsList,ProbL,ProbU,CPUTime):- + statistics(cputime,[_,_]), + setting(depth_bound,D), + solveic(GoalsList,D,ProbL,ProbU), + statistics(cputime,[_,CT]), + CPUTime is CT/1000. + + + +solveic(GoalsList,D,ProbL0,ProbU0):- + (setof((Deriv,P,Pruned),solvec(GoalsList,D,[],Deriv,1.0,P,Pruned),L)-> + % print_mem, + separate_ulbc(L,[],LL,0,Err), + compute_prob_deriv(LL,ProbL0), + ProbU0 is ProbL0+Err + /*(ProbU>1.0-> + ProbU0=1.0 + ; + ProbU0=ProbU + )*/ + ; + % print_mem, + ProbL0=0.0, + ProbU0=0.0 + ). + compute_prob_deriv(LL,ProbL):- build_formula(LL,FormulaL,[],VarL,0,ConjL), length(LL,NDL), @@ -158,10 +219,11 @@ solve(GoalsList,[],DerivDup), remove_duplicates(DerivDup,Deriv). -find_deriv(GoalsList,DB,Deriv):- - solve(GoalsList,DB,[],DerivDup), +find_derivr(GoalsList,DB,Deriv):- + solver(GoalsList,DB,[],DerivDup), remove_duplicates(DerivDup,Deriv). + /* duplicate can appear in the C set because two different unistantiated clauses may become the same clause when instantiated */ @@ -200,15 +262,68 @@ sci(Goals,Evidence,ProbL,ProbU,CPUTime):- statistics(cputime,[_,_]), setting(depth_bound,D), - solve_condi(Goals,Evidence,D,ProbL,ProbU), + append(Goals,Evidence,GE), + solve_condi([(GE,[])],[(Evidence,[])],[],[],D,ProbL,ProbU), statistics(cputime,[_,CT]), CPUTime is CT/1000. -solve_condi(Goals,Evidence,D,ProbL0,ProbU0):- - (call_residue(setof(DerivE,find_deriv(Evidence,D,DerivE),LDupE),_R0)-> +solve_condi(LGoals,LEvidence,SuccGE,SuccE,D,ProbL0,ProbU0):- + findall((GE1,DerivE), + (member((GE,CE),LEvidence),solvei(GE,D,CE,DerivE,GE1)), + LE), + findall((GE1,DerivE), + (member((GE,CE),LGoals),solvei(GE,D,CE,DerivE,GE1)), + LGE), + separate_ulbi(LE,[],LLE0,[],LUE0,[],IncE), + append(SuccE,LUE0,LUE), + compute_prob_deriv(LUE,ProbUE), + (ProbUE\==0.0-> + separate_ulbi(LGE,[],LLGE0,[],LUGE0,[],IncGE), + append(SuccGE,LLGE0,LLGE), + compute_prob_deriv(LLGE,ProbLGE), + ProbL is ProbLGE/ProbUE, + append(SuccE,LLE0,LLE), + compute_prob_deriv(LLE,ProbLE), + (ProbLE\==0.0-> + append(SuccGE,LUGE0,LUGE), + compute_prob_deriv(LUGE,ProbUGE), + ProbU1 is ProbUGE/ProbLE + ; + ProbU1=1.0 + ), + (ProbU1>1.0-> + ProbU=1.0 + ; + ProbU=ProbU1 + ), + Err is ProbU-ProbL, + setting(min_error,ME), + (Err<ME-> + ProbU0=ProbU, + ProbL0=ProbL + ; + setting(depth_bound,DB), + D1 is D+DB, + solve_condi(IncGE,IncE,LLGE,LLE,D1,ProbL0,ProbU0) + ) + ; + ProbL0=undefined, + ProbU0=undefined + ). + + +scir(Goals,Evidence,ProbL,ProbU,CPUTime):- + statistics(cputime,[_,_]), + setting(depth_bound,D), + solve_condir(Goals,Evidence,D,ProbL,ProbU), + statistics(cputime,[_,CT]), + CPUTime is CT/1000. + +solve_condir(Goals,Evidence,D,ProbL0,ProbU0):- + (call_residue(setof(DerivE,find_derivr(Evidence,D,DerivE),LDupE),_R0)-> rem_dup_lists(LDupE,[],LE), append(Evidence,Goals,EG), - (call_residue(setof(DerivGE,find_deriv(EG,D,DerivGE),LDupGE),_R1)-> + (call_residue(setof(DerivGE,find_derivr(EG,D,DerivGE),LDupGE),_R1)-> rem_dup_lists(LDupGE,[],LGE), separate_ulb(LGE,[],LLGE,[],LUGE), compute_prob_deriv(LLGE,ProbLGE), @@ -235,7 +350,54 @@ ; setting(depth_bound,DB), D1 is D+DB, - solve_condi(Goals,Evidence,D1,ProbL0,ProbU0) + solve_condir(Goals,Evidence,D1,ProbL0,ProbU0) + ) + ; + ProbL0=0.0, + ProbU0=0.0 + ) + ; + ProbL0=undefined, + ProbU0=undefined + ). + +scic(Goals,Evidence,ProbL,ProbU,CPUTime):- + statistics(cputime,[_,_]), + setting(depth_bound,D), + solve_condic(Goals,Evidence,D,ProbL,ProbU), + statistics(cputime,[_,CT]), + CPUTime is CT/1000. + +solve_condic(Goals,Evidence,D,ProbL0,ProbU0):- + (call_residue(setof((DerivE,P,Pruned),solvec(Evidence,D,[],DerivE,1.0,P,Pruned),LE),_R0)-> + append(Evidence,Goals,EG), + (call_residue(setof((DerivGE,P,Pruned),solvec(EG,D,[],DerivGE,1.0,P,Pruned),LGE),_R1)-> + separate_ulbc(LGE,[],LLGE,0.0,ErrGE), + compute_prob_deriv(LLGE,ProbLGE), + separate_ulbc(LE,[],LLE,0.0,ErrE), + compute_prob_deriv(LLE,ProbLE), + ProbUGE0 is ProbLGE+ErrGE, + (ProbUGE0>1.0-> + ProbUGE=1.0 + ; + ProbUGE=ProbUGE0 + ), + ProbUE0 is ProbLE+ErrE, + (ProbUE0>1.0-> + ProbUE=1.0 + ; + ProbUE=ProbUE0 + ), + ProbL0 is ProbLGE/ProbUE, + (ProbLE=0.0-> + ProbU1=1.0 + ; + ProbU1 is ProbUGE/ProbLE + ), + (ProbU1>1.0-> + ProbU0=1.0 + ; + ProbU0=ProbU1 ) ; ProbL0=0.0, @@ -401,13 +563,48 @@ solve_pres(R,S,N,B,T,CIn,COut). -solve([],_DB,C,C):-!. +solvei([],_DB,C,C,[]):-!. -solve(_G,0,C,[(_,pruned,_)|C]):-!. +solvei(G,0,C,C,G):-!. -solve([\+ H |T],DB,CIn,COut):-!, +solvei([\+ H |T],DB,CIn,COut,G):-!, list2and(HL,H), - (setof(D,find_deriv(HL,DB,D),LDup)-> + (findall((GH,D),solvei(HL,DB,CIn,D,GH),L)-> + separate_ulbi(L,[],LB,[],UB,[],I), + (I\=[]-> + C1=CIn, + G=[\+ H|G1] + ; + choose_clauses(CIn,LB,C1), + G=G1 + ), + solvei(T,DB,C1,COut,G1) + ; + solvei(T,DB,CIn,COut,G1) + ). +solvei([H|T],DB,CIn,COut,G):- + builtin(H),!, + call(H), + solvei(T,DB,CIn,COut,G). + +solvei([H|T],DB,CIn,COut,G):- + def_rule(H,B), + append(B,T,NG), + DB1 is DB-1, + solvei(NG,DB1,CIn,COut,G). + +solvei([H|T],DB,CIn,COut,G):- + find_rule(H,(R,S,N),B,CIn), + DB1 is DB-1, + solve_presi(R,S,N,B,T,DB1,CIn,COut,G). + +solver([],_DB,C,C):-!. + +solver(_G,0,C,[(_,pruned,_)|C]):-!. + +solver([\+ H |T],DB,CIn,COut):-!, + list2and(HL,H), + (setof(D,find_derivr(HL,DB,D),LDup)-> rem_dup_lists(LDup,[],L), separate_ulb(L,[],LB,[],UB), (\+ LB=UB-> @@ -417,25 +614,68 @@ ; choose_clauses(CIn,L,C1) ), - solve(T,DB,C1,COut) + solver(T,DB,C1,COut) ; - solve(T,DB,CIn,COut) + solver(T,DB,CIn,COut) ). -solve([H|T],DB,CIn,COut):- +solver([H|T],DB,CIn,COut):- builtin(H),!, call(H), - solve(T,DB,CIn,COut). + solver(T,DB,CIn,COut). -solve([H|T],DB,CIn,COut):- +solver([H|T],DB,CIn,COut):- def_rule(H,B), append(B,T,NG), DB1 is DB-1, - solve(NG,DB1,CIn,COut). + solver(NG,DB1,CIn,COut). -solve([H|T],DB,CIn,COut):- +solver([H|T],DB,CIn,COut):- find_rule(H,(R,S,N),B,CIn), DB1 is DB-1, - solve_pres(R,S,N,B,T,DB1,CIn,COut). + solve_presr(R,S,N,B,T,DB1,CIn,COut). + + +solvec([],_DB,C,C,P,P,false):-!. + +solvec(_G,0,C,C,P,P,true):-!. + +solvec(_G,_DB,C,C,P,P,true):- + setting(prob_threshold,T), + P=<T,!. + +solvec([\+ H |T],DB,CIn,COut,P0,P1,Pruned):-!, + list2and(HL,H), + (setof((D,P,Pr),solvec(HL,DB,[],D,1,P,Pr),L)-> + separate_ulbc(L,[],LB,0.0,PP), + (PP=\=0.0-> + + choose_clausesc(CIn,LB,C1,P0,P2), + Pruned=true, + solvec(T,DB,C1,COut,P2,P1,_) + + ; + choose_clausesc(CIn,LB,C1,P0,P2), + solvec(T,DB,C1,COut,P2,P1,Pruned) + ) + ; + solve(T,DB,CIn,COut,P0,P1,Pruned) + ). + +solvec([H|T],DB,CIn,COut,P0,P1,Pruned):- + builtin(H),!, + call(H), + solvec(T,DB,CIn,COut,P0,P1,Pruned). + +solvec([H|T],DB,CIn,COut,P0,P1,Pruned):- + def_rule(H,B), + append(B,T,NG), + DB1 is DB-1, + solvec(NG,DB1,CIn,COut,P0,P1,Pruned). + +solvec([H|T],DB,CIn,COut,P0,P1,Pruned):- + find_rulec(H,(R,S,N),B,CIn,P), + DB1 is DB-1, + solve_presc(R,S,N,B,T,DB1,CIn,COut,P,P0,P1,Pruned). @@ -449,15 +689,39 @@ append(B,T,NG), solve(NG,C1,COut). -solve_pres(R,S,N,B,T,DB,CIn,COut):- +solve_presi(R,S,N,B,T,DB,CIn,COut,G):- + member_eq((N,R,S),CIn),!, + append(B,T,NG), + solvei(NG,DB,CIn,COut,G). + +solve_presi(R,S,N,B,T,DB,CIn,COut,G):- + append(CIn,[(N,R,S)],C1), + append(B,T,NG), + solvei(NG,DB,C1,COut,G). + + +solve_presr(R,S,N,B,T,DB,CIn,COut):- + member_eq((N,R,S),CIn),!, + append(B,T,NG), + solver(NG,DB,CIn,COut). + +solve_presr(R,S,N,B,T,DB,CIn,COut):- + append(CIn,[(N,R,S)],C1), + append(B,T,NG), + solver(NG,DB,C1,COut). + + +solve_presc(R,S,N,B,T,DB,CIn,COut,_,P0,P1,Pruned):- member_eq((N,R,S),CIn),!, append(B,T,NG), - solve(NG,DB,CIn,COut). + solvec(NG,DB,CIn,COut,P0,P1,Pruned). -solve_pres(R,S,N,B,T,DB,CIn,COut):- +solve_presc(R,S,N,B,T,DB,CIn,COut,P,P0,P1,Pruned):- append(CIn,[(N,R,S)],C1), append(B,T,NG), - solve(NG,DB,C1,COut). + P2 is P0*P, + solvec(NG,DB,C1,COut,P2,P1,Pruned). + build_initial_graph(N,G):- listN(0,N,Vert), @@ -524,6 +788,12 @@ rule(R,S,_,uniform(H:1/_Num,_P,Number),Body), not_already_present_with_a_different_head(Number,R,S,C). +find_rulec(H,(R,S,N),Body,C,P):- + rule(R,S,_,Head,Body), + member_headc(H,Head,0,N,P), + not_already_present_with_a_different_head(N,R,S,C). + + not_already_present_with_a_different_head(_N,_R,_S,[]). @@ -552,6 +822,13 @@ N1 is NIn+1, member_head(H,T,N1,NOut). +member_headc(H,[(H:P)|_T],N,N,P). + +member_headc(H,[(_H:_P)|T],NIn,NOut,P):- + N1 is NIn+1, + member_headc(H,T,N1,NOut,P). + + /* choose_clauses(CIn,LC,COut) takes as input the current C set and the set of C sets for a negative goal and returns a new C set that excludes all the derivations for the negative goals */ @@ -571,6 +848,26 @@ impose_dif_cons(R,S,CIn), choose_clauses([(N1,R,S)|CIn],T,COut). +choose_clausesc(C,[],C,P,P). + +choose_clausesc(CIn,[D|T],COut,P0,P1):- + member((N,R,S),D), + already_present_with_a_different_head(N,R,S,CIn),!, + choose_a_headc(N,R,S,CIn,C1,P0,P2), + choose_clausesc(C1,T,COut,P2,P1). + + +choose_clausesc(CIn,[D|T],COut,P0,P1):- + member((N,R,S),D), + new_head(N,R,S,N1), + \+ already_present(N1,R,S,CIn), + impose_dif_cons(R,S,CIn), + rule(R,S,_Numbers,Head,_Body), + nth0(N1, Head, (_H:P), _Rest), + P2 is P0*P, + choose_clausesc([(N1,R,S)|CIn],T,COut,P2,P1). + + choose_clauses_DB(C,[],C). choose_clauses_DB(CIn,[D|T],COut):- @@ -621,6 +918,26 @@ /* case 1 of Select: a more general rule is present in C with a different head, instantiate it */ +choose_a_headc(N,R,S,[(NH,R,SH)|T],[(NH,R,SH)|T],P,P):- + S=SH, + dif(N,NH). + +/* case 2 of Select: a more general rule is present in C with +a different head, ensure that they do not generate the same +ground clause */ +choose_a_headc(N,R,S,[(NH,R,SH)|T],[(NH,R,S),(NH,R,SH)|T],P0,P1):- + \+ \+ S=SH, S\==SH, + dif(N,NH), + dif(S,SH), + rule(R,S,_Numbers,Head,_Body), + nth0(NH, Head, (_H:P), _Rest), + P1 is P0*P. + +choose_a_headc(N,R,S,[H|T],[H|T1],P0,P1):- + choose_a_headc(N,R,S,T,T1,P0,P1). + +/* case 1 of Select: a more general rule is present in C with +a different head, instantiate it */ choose_a_head(N,R,S,[(NH,R,SH)|T],[(NH,R,SH)|T]):- S=SH, dif(N,NH). @@ -636,6 +953,7 @@ choose_a_head(N,R,S,[H|T],[H|T1]):- choose_a_head(N,R,S,T,T1). + /* select a head different from N for rule R with substitution S, return it in N1 */ new_head(N,R,S,N1):- @@ -684,6 +1002,20 @@ member_subset(E,[_H|T]):- member_subset(E,T). +separate_ulbi([],L,L,U,U,I,I):-!. +/* +separate_ulb([H|T],L0,L1,U0,[H|U1]):- + member(pruned,H),!, + separate_ulb(T,L0,L1,U0,U1). +*/ +separate_ulbi([([],H)|T],L0,[H|L1],U0,[H|U1],I0,I1):- + !, + separate_ulbi(T,L0,L1,U0,U1,I0,I1). + +separate_ulbi([(G,H)|T],L0,L1,U0,[H1|U1],I0,[(G,H)|I1]):- + get_ground(H,H1), + separate_ulbi(T,L0,L1,U0,U1,I0,I1). + separate_ulb([],L,L,U,U):-!. /* @@ -699,6 +1031,17 @@ get_ground(H,H1), separate_ulb(T,L0,L1,U0,U1). + +separate_ulbc([],L,L,P,P):-!. + +separate_ulbc([(H,P,true)|T],L0,L1,P0,P1):-!, + P2 is P0+P, + separate_ulbc(T,L0,L1,P2,P1). + +separate_ulbc([(H,_P,false)|T],L0,[H|L1],P0,P1):- + separate_ulbc(T,L0,L1,P0,P1). + + get_ground([],[]):-!. get_ground([H|T],[H|T1]):- Index: testlpadsldit.pl =================================================================== RCS file: /cvsroot/yap/cplint/testlpadsldit.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- testlpadsldit.pl 8 Jun 2008 18:11:41 -0000 1.1 +++ testlpadsldit.pl 9 Jun 2008 17:57:30 -0000 1.2 @@ -70,10 +70,12 @@ files([ -exapprox,exrange, +exapprox, +exrange, threesideddice, -mendel, -coin2,ex,trigger,throws,light]). +%mendel, +coin2,ex,trigger,throws,light +]). test((s([death],P),close_to(P,0.305555555555556)),trigger,_). |
|
From: Fabrizio R. <rz...@us...> - 2008-06-08 18:11:42
|
Update of /cvsroot/yap/cplint In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv1840 Modified Files: cplint_yap.c lpadsld.pl testlpadsld_gbtrue.pl Added Files: testlpadsldit.pl Log Message: Added iterative deepening Printing of Cudd information --- NEW FILE: testlpadsldit.pl --- /* LPAD and CP-Logic reasoning suite Copyright (c) 2007, Fabrizio Riguzzi Test file for lpadsld.pl, case where the body is grounded Use :-t. to execute the test */ :-source. :-use_module(library(lpadsld)). epsilon(0.000001). close_to(V,T):- epsilon(E), TLow is T-E, THigh is T+E, TLow<V, V<THigh. t:- format("~nTesting iterative deepening lpadsld.yap~n~n",[]), files(F), statistics(runtime,[_,_]), set(ground_body,true), set(depth_bound,1), set(min_error,0.05), format("~nGround body~n~n",[]), test_filesi(F,ground_body(true)), statistics(runtime,[_,T]), T1 is T /1000, format("Test successful, time ~f secs.~n",[T1]). t:- format("Test unsuccessful.~n",[]). test_filesi([],_GB). test_filesi([H|T],GB):- library_directory(LD), atom_concat(LD,'/cplint/examples/',ExDir), atom_concat(ExDir,H,NH), p(NH),!, findall(A,test(A,H,GB),L), test_alli(H,L), test_filesi(T,GB). test_alli(_F,[]). test_alli(F,[H|T]):- copy_term(H,NH), NH=(s(Q,_P),close_to('P',P)),!, format("~a ~p.~n",[F,NH]), si(Q,PL,PU,_Time),!, format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), P>=PL-1e-7,P=<PU+1e-7, test_alli(F,T). test_alli(F,[H|T]):- copy_term(H,NH), NH=(sc(Q,E,_P),close_to('P',P)), format("~a ~p.~n",[F,NH]), sci(Q,E,PL,PU,_Time),!, format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), P>=PL-1e-10,P=<PU+1e-10, test_alli(F,T). files([ exapprox,exrange, threesideddice, mendel, coin2,ex,trigger,throws,light]). test((s([death],P),close_to(P,0.305555555555556)),trigger,_). test((s([throws(mary),throws(john),break],P),close_to(P,0.46)),throws,_). test((s([throws(mary),throws(john),\+break],P),close_to(P,0.04)),throws,_). test((s([\+ throws(mary),throws(john),break],P),close_to(P,0.3)),throws,_). test((s([\+ throws(mary),throws(john),\+ break],P),close_to(P,0.2)),throws,_). test((s([push,replace],P),close_to(P,0.5)),light,_). test((s([push,light],P),close_to(P,0.5)),light,_). test((s([push,light,replace],P),close_to(P,0)),light,_). test((s([light,replace],P),close_to(P,0)),light,_). test((s([light],P),close_to(P,0.5)),light,_). test((s([replace],P),close_to(P,0.5)),light,_). test((s([\+ cites_cited(c1,p1)],P),close_to(P,0.7)),paper_ref_not,_). test((s([cites_citing(c1,p1)],P),close_to(P,0.14)),paper_ref_not,_). test((s([cites_cited(c1,p1)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p2)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p4)],P),close_to(P,0.181333333)),paper_ref,_). test((s([cites_cited(c1,p3)],P),close_to(P,0.228)),paper_ref,_). test((s([cites_cited(c1,p5)],P),close_to(P,0.228)),paper_ref,_). test((s([female(f)],P),close_to(P,0.6)),female,_). test((s([male(f)],P),close_to(P,0.4)),female,_). test((s([a],P),close_to(P,0.1719)),exapprox,ground_body(true)). test((s([a],P),close_to(P,0.099)),exapprox,ground_body(false)). test((s([a(1)],P),close_to(P,0.2775)),exrange,_). test((s([a(2)],P),close_to(P,0.36)),exrange,_). test((s([on(0,1)],P),close_to(P,0.333333333333333)),threesideddice,_). test((s([on(1,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((s([on(2,1)],P),close_to(P,0.148148147703704)),threesideddice,_). test((s([on(3,1)],P),close_to(P,0.0987654320987654)),threesideddice,_). test((s([on(4,1)],P),close_to(P,0.0658436213991769)),threesideddice,_). test((sc([on(2,1)],[on(0,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((sc([on(2,1)],[on(1,1)],P),close_to(P,0.333333333333333)),threesideddice,_). test((sc([on(4,1)],[on(1,1)],P),close_to(P, 0.148148148148148)),threesideddice,_). test((sc([on(5,1)],[on(2,1)],P),close_to(P, 0.148148148148148)),threesideddice,_). test((s([cg(s,1,p)],P),close_to(P,0.75)),mendel,_). test((s([cg(s,1,w)],P),close_to(P,0.25)),mendel,_). test((s([cg(s,2,p)],P),close_to(P,0.25)),mendel,_). test((s([cg(s,2,w)],P),close_to(P,0.75)),mendel,_). test((s([cg(f,2,w)],P),close_to(P,0.5)),mendel,_). test((s([cg(s,2,w)],P),close_to(P,0.75)),mendel,_). test((s([a],P),close_to(P,0.226)),ex,_). test((s([heads(coin1)],P),close_to(P,0.51)),coin2,_). test((s([heads(coin2)],P),close_to(P,0.51)),coin2,_). test((s([tails(coin1)],P),close_to(P,0.49)),coin2,_). test((s([tails(coin2)],P),close_to(P,0.49)),coin2,_). test((s([student_rank(jane_doe,h)],P),close_to(P,0.465)),student,_). test((s([student_rank(jane_doe,l)],P),close_to(P,0.535)),student,_). test((s([course_rat(phil101,h)],P),close_to(P,0.330656)),student,_). test((s([course_rat(phil101,l)],P),close_to(P,0.669344)),student,_). test((s([professor_ability(p0,h)],P),close_to(P,0.5)),school,_). test((s([professor_ability(p0,m)],P),close_to(P,0.4)),school,_). test((s([professor_ability(p0,l)],P),close_to(P,0.1)),school,_). test((s([professor_popularity(p0,h)],P),close_to(P,0.531)),school,_). test((s([professor_popularity(p0,l)],P),close_to(P,0.175)),school,_). test((s([professor_popularity(p0,m)],P),close_to(P,0.294)),school,_). test((sc([professor_ability(p0,h)],[professor_popularity(p0,h)],P),close_to(P,0.847457627118644)),school,_). test((sc([professor_ability(p0,l)],[professor_popularity(p0,h)],P),close_to(P,0.00188323917137476)),school,_). test((sc([professor_ability(p0,m)],[professor_popularity(p0,h)],P),close_to(P,0.150659133709981)),school,_). test((sc([professor_popularity(p0,h)],[professor_ability(p0,h)],P),close_to(P,0.9)),school,_). test((sc([professor_popularity(p0,l)],[professor_ability(p0,h)],P),close_to(P,0.01)),school,_). test((sc([professor_popularity(p0,m)],[professor_ability(p0,h)],P),close_to(P,0.09)),school,_). test(( s([registration_grade(r0,1)],P),close_to(P,0.06675)),school,_). test(( s([registration_grade(r0,2)],P),close_to(P,0.16575)),school,_). test(( s([registration_grade(r0,3)],P),close_to(P, 0.356)),school,_). test(( s([registration_grade(r0,4)],P),close_to(P,0.4115)),school,_). test((sc([registration_grade(r0,1)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.15)),school,_). test((sc([registration_grade(r0,2)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.285)),school,_). test((sc([registration_grade(r0,3)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.424)),school,_). test((sc([registration_grade(r0,4)],[registration_course(r0,C), course_difficulty(C,h)],P),close_to(P,0.141)),school,_). test((sc([registration_grade(r0,1)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.05)),school,_). test((sc([registration_grade(r0,2)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.15)),school,_). test((sc([registration_grade(r0,3)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.6)),school,_). test((sc([registration_grade(r0,4)], [registration_course(r0,C), course_difficulty(C,h), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.2)),school,_). test((sc([registration_grade(r0,1)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.01)),school,_). test((sc([registration_grade(r0,2)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.02)),school,_). test((sc([registration_grade(r0,3)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.12)),school,_). test((sc([registration_grade(r0,4)],[registration_course(r0,C), course_difficulty(C,l), registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.85)),school,_). test((s([registration_satisfaction(r0,1)],P),close_to(P,0.15197525)),school,_). test((s([registration_satisfaction(r0,2)],P),close_to(P,0.1533102)),school,_). test((s([registration_satisfaction(r0,3)],P),close_to(P,0.6947145)),school,_). test((sc([registration_satisfaction(r0,1)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.0959225)),school,_). test((sc([registration_satisfaction(r0,2)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.124515)),school,_). test((sc([registration_satisfaction(r0,3)],[ registration_student(r0,S), student_intelligence(S,h)],P),close_to(P,0.7795625)),school,_). test((sc([registration_satisfaction(r0,1)],[registration_grade(r0,4)],P),close_to(P,0.04)),school,_). test((sc([registration_satisfaction(r0,2)],[registration_grade(r0,4)],P),close_to(P,0.06)),school,_). test((sc([registration_satisfaction(r0,3)],[registration_grade(r0,4)],P),close_to(P,0.9)),school,_). test((sc([registration_satisfaction(r0,1)],[registration_grade(r0,1)],P),close_to(P,0.528)),school,_). test((sc([registration_satisfaction(r0,2)],[registration_grade(r0,1)],P),close_to(P,0.167)),school,_). test((sc([registration_satisfaction(r0,3)],[registration_grade(r0,1)],P),close_to(P,0.305)),school,_). test((sc([ registration_grade(r0,1)],[registration_satisfaction(r0,3)],P),close_to(P,0.0293052037923492)),school,_). test((sc([ registration_grade(r0,2)],[registration_satisfaction(r0,3)],P),close_to(P, 0.114760451955444)),school,_). test((sc([ registration_grade(r0,3)],[registration_satisfaction(r0,3)],P),close_to(P,0.322837654892765)),school,_). test((sc([ registration_grade(r0,4)],[registration_satisfaction(r0,3)],P),close_to(P,0.533096689359442)),school,_). test((s([course_rating(c0,h)],P),close_to(P,0.5392099)),school,_). test((s([course_rating(c0,l)],P),close_to(P, 0.2)),school,_). test((s([course_rating(c0,m)],P),close_to(P,0.2607901)),school,_). test((sc([course_difficulty(c0,h)],[course_rating(c0,h)],P),close_to(P,0.235185778302661)),school,_). test((sc([course_difficulty(c0,l)],[course_rating(c0,h)],P),close_to(P,0.259096503977393)),school,_). test((sc([course_difficulty(c0,m)],[course_rating(c0,h)],P),close_to(P,0.505717717719945)),school,_). test((s([course_difficulty(c0,h)],P),close_to(P,0.25)),school,_). test((s([course_difficulty(c0,l)],P),close_to(P,0.25)),school,_). test((s([course_difficulty(c0,m)],P),close_to(P,0.5)),school,_). test((s([student_ranking(s0,h)],P),close_to(P,0.6646250000000005)),school_simple,_). test((s([student_ranking(s0,l)],P),close_to(P,0.33537499999999987)),school_simple,_). Index: cplint_yap.c =================================================================== RCS file: /cvsroot/yap/cplint/cplint_yap.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- cplint_yap.c 8 Jun 2008 08:38:36 -0000 1.3 +++ cplint_yap.c 8 Jun 2008 18:11:41 -0000 1.4 @@ -134,11 +134,11 @@ bVar2mVar=array_alloc(int,0); create_dot=YAP_IntOfTerm(arg4); createVars(variables,arg1,mgr,bVar2mVar,create_dot,inames); - Cudd_PrintInfo(mgr,stderr); + //Cudd_PrintInfo(mgr,stderr); /* automatic variable reordering, default method CUDD_REORDER_SIFT used */ - printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); - printf("order %d\n",order); + //printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); + //printf("order %d\n",order); Cudd_AutodynEnable(mgr,CUDD_REORDER_SAME); /* Cudd_AutodynEnable(mgr, CUDD_REORDER_RANDOM_PIVOT); Index: lpadsld.pl =================================================================== RCS file: /cvsroot/yap/cplint/lpadsld.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- lpadsld.pl 8 Jun 2008 08:38:36 -0000 1.8 +++ lpadsld.pl 8 Jun 2008 18:11:41 -0000 1.9 @@ -21,7 +21,8 @@ if true, both the head and the body of each clause will be grounded, otherwise only the head is grounded. In the case in which the body contains variables not appearing in the head, the body represents an existential event */ - +setting(min_error,0.01). +setting(depth_bound,4). /* end of list of parameters */ /* s(GoalsLIst,Prob) compute the probability of a list of goals @@ -98,6 +99,51 @@ format(user_error,"~nMemory after inference~n",[]), print_mem. +si(GoalsList,ProbL,ProbU,CPUTime):- + statistics(cputime,[_,_]), + setting(depth_bound,D), + solvei(GoalsList,D,ProbL,ProbU), + statistics(cputime,[_,CT]), + CPUTime is CT/1000. + + + +solvei(GoalsList,D,ProbL0,ProbU0):- + (setof(Deriv,find_deriv(GoalsList,D,Deriv),LDup)-> + rem_dup_lists(LDup,[],L), + % print_mem, + separate_ulb(L,[],LL,[],LU), + compute_prob_deriv(LL,ProbL), + compute_prob_deriv(LU,ProbU), + Err is ProbU-ProbL, + setting(min_error,ME), + (Err<ME-> + ProbU0=ProbU, + ProbL0=ProbL + ; + setting(depth_bound,DB), + D1 is D+DB, + solvei(GoalsList,D1,ProbL0,ProbU0) + ) + ; + % print_mem, + ProbL0=0.0, + ProbU0=0.0 + ). + +compute_prob_deriv(LL,ProbL):- + build_formula(LL,FormulaL,[],VarL,0,ConjL), + length(LL,NDL), + length(VarL,NVL), + %format(user_error,"Disjunctions :~d~nConjunctions: ~d~nVariables ~d~n",[NDL,ConjL,NVL]), + var2numbers(VarL,0,NewVarL), + (setting(save_dot,true)-> + % format("Variables: ~p~n",[VarL]), + compute_prob(NewVarL,FormulaL,ProbL,1) + ; + compute_prob(NewVarL,FormulaL,ProbL,0) + ). + print_mem:- statistics(global_stack,[GS,GSF]), statistics(local_stack,[LS,LSF]), @@ -111,6 +157,11 @@ find_deriv(GoalsList,Deriv):- solve(GoalsList,[],DerivDup), remove_duplicates(DerivDup,Deriv). + +find_deriv(GoalsList,DB,Deriv):- + solve(GoalsList,DB,[],DerivDup), + remove_duplicates(DerivDup,Deriv). + /* duplicate can appear in the C set because two different unistantiated clauses may become the same clause when instantiated */ @@ -146,6 +197,55 @@ format(user_error,"~nMemory after inference~n",[]), print_mem. +sci(Goals,Evidence,ProbL,ProbU,CPUTime):- + statistics(cputime,[_,_]), + setting(depth_bound,D), + solve_condi(Goals,Evidence,D,ProbL,ProbU), + statistics(cputime,[_,CT]), + CPUTime is CT/1000. + +solve_condi(Goals,Evidence,D,ProbL0,ProbU0):- + (call_residue(setof(DerivE,find_deriv(Evidence,D,DerivE),LDupE),_R0)-> + rem_dup_lists(LDupE,[],LE), + append(Evidence,Goals,EG), + (call_residue(setof(DerivGE,find_deriv(EG,D,DerivGE),LDupGE),_R1)-> + rem_dup_lists(LDupGE,[],LGE), + separate_ulb(LGE,[],LLGE,[],LUGE), + compute_prob_deriv(LLGE,ProbLGE), + compute_prob_deriv(LUGE,ProbUGE), + separate_ulb(LE,[],LLE,[],LUE), + compute_prob_deriv(LLE,ProbLE), + compute_prob_deriv(LUE,ProbUE), + ProbL is ProbLGE/ProbUE, + (ProbLE=0.0-> + ProbU1=1.0 + ; + ProbU1 is ProbUGE/ProbLE + ), + (ProbU1>1.0-> + ProbU=1.0 + ; + ProbU=ProbU1 + ), + Err is ProbU-ProbL, + setting(min_error,ME), + (Err<ME-> + ProbU0=ProbU, + ProbL0=ProbL + ; + setting(depth_bound,DB), + D1 is D+DB, + solve_condi(Goals,Evidence,D1,ProbL0,ProbU0) + ) + ; + ProbL0=0.0, + ProbU0=0.0 + ) + ; + ProbL0=undefined, + ProbU0=undefined + ). + /* sc(Goals,Evidence,Prob,Time1,Time2) compute the conditional probability of the list of goals Goals given the list of goals Evidence Goals and Evidence can have variables, sc returns in backtracking all the solutions with their @@ -216,6 +316,11 @@ solve(GoalsList,D,DerivDup), remove_duplicates(DerivDup,Deriv). +find_deriv_GE(LD,GoalsList,DB,Deriv):- + member(D,LD), + solve(GoalsList,DB,D,DerivDup), + remove_duplicates(DerivDup,Deriv). + /* solve(GoalsList,CIn,COut) takes a list of goals and an input C set and returns an output C set The C set is a list of triple (N,R,S) where @@ -295,6 +400,45 @@ find_rule(H,(R,S,N),B,CIn), solve_pres(R,S,N,B,T,CIn,COut). + +solve([],_DB,C,C):-!. + +solve(_G,0,C,[(_,pruned,_)|C]):-!. + +solve([\+ H |T],DB,CIn,COut):-!, + list2and(HL,H), + (setof(D,find_deriv(HL,DB,D),LDup)-> + rem_dup_lists(LDup,[],L), + separate_ulb(L,[],LB,[],UB), + (\+ LB=UB-> + + choose_clauses(CIn,LB,C0), + C1=[(_,pruned,_)|C0] + ; + choose_clauses(CIn,L,C1) + ), + solve(T,DB,C1,COut) + ; + solve(T,DB,CIn,COut) + ). +solve([H|T],DB,CIn,COut):- + builtin(H),!, + call(H), + solve(T,DB,CIn,COut). + +solve([H|T],DB,CIn,COut):- + def_rule(H,B), + append(B,T,NG), + DB1 is DB-1, + solve(NG,DB1,CIn,COut). + +solve([H|T],DB,CIn,COut):- + find_rule(H,(R,S,N),B,CIn), + DB1 is DB-1, + solve_pres(R,S,N,B,T,DB1,CIn,COut). + + + solve_pres(R,S,N,B,T,CIn,COut):- member_eq((N,R,S),CIn),!, append(B,T,NG), @@ -305,6 +449,16 @@ append(B,T,NG), solve(NG,C1,COut). +solve_pres(R,S,N,B,T,DB,CIn,COut):- + member_eq((N,R,S),CIn),!, + append(B,T,NG), + solve(NG,DB,CIn,COut). + +solve_pres(R,S,N,B,T,DB,CIn,COut):- + append(CIn,[(N,R,S)],C1), + append(B,T,NG), + solve(NG,DB,C1,COut). + build_initial_graph(N,G):- listN(0,N,Vert), add_vertices([],Vert,G). @@ -372,6 +526,7 @@ not_already_present_with_a_different_head(_N,_R,_S,[]). + not_already_present_with_a_different_head(N,R,S,[(N1,R,S1)|T]):- not_different(N,N1,S,S1),!, not_already_present_with_a_different_head(N,R,S,T). @@ -380,6 +535,7 @@ R\==R1, not_already_present_with_a_different_head(N,R,S,T). + not_different(_N,_N1,S,S1):- S\=S1,!. @@ -415,6 +571,24 @@ impose_dif_cons(R,S,CIn), choose_clauses([(N1,R,S)|CIn],T,COut). +choose_clauses_DB(C,[],C). + +choose_clauses_DB(CIn,[D|T],COut):- + member((N,R,S),D), + ground((N,R,S)), + already_present_with_a_different_head(N,R,S,CIn),!, + choose_a_head(N,R,S,CIn,C1), + choose_clauses_DB(C1,T,COut). + +choose_clauses_DB(CIn,[D|T],COut):- + member((N,R,S),D), + ground((N,R,S)),!, + new_head(N,R,S,N1), + \+ already_present(N1,R,S,CIn), + impose_dif_cons(R,S,CIn), + choose_clauses_DB([(N1,R,S)|CIn],T,COut). + + impose_dif_cons(_R,_S,[]):-!. impose_dif_cons(R,S,[(_NH,R,SH)|T]):-!, @@ -511,6 +685,29 @@ member_subset(E,T). +separate_ulb([],L,L,U,U):-!. +/* +separate_ulb([H|T],L0,L1,U0,[H|U1]):- + member(pruned,H),!, + separate_ulb(T,L0,L1,U0,U1). +*/ +separate_ulb([H|T],L0,[H|L1],U0,[H|U1]):- + ground(H),!, + separate_ulb(T,L0,L1,U0,U1). + +separate_ulb([H|T],L0,L1,U0,[H1|U1]):- + get_ground(H,H1), + separate_ulb(T,L0,L1,U0,U1). + +get_ground([],[]):-!. + +get_ground([H|T],[H|T1]):- + ground(H),!, + get_ground(T,T1). + +get_ground([H|T],T1):- + get_ground(T,T1). + /* predicates for building the formula to be converted into a BDD */ @@ -536,8 +733,12 @@ build_term(D,F,VarIn,Var1), build_formula(TD,TF,Var1,VarOut). + build_term([],[],Var,Var). +build_term([(_,pruned,_)|TC],TF,VarIn,VarOut):-!, + build_term(TC,TF,VarIn,VarOut). + build_term([(N,R,S)|TC],[[NVar,N]|TF],VarIn,VarOut):- (nth0_eq(0,NVar,VarIn,(R,S))-> Var1=VarIn Index: testlpadsld_gbtrue.pl =================================================================== RCS file: /cvsroot/yap/cplint/testlpadsld_gbtrue.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- testlpadsld_gbtrue.pl 4 Dec 2007 18:30:34 -0000 1.3 +++ testlpadsld_gbtrue.pl 8 Jun 2008 18:11:41 -0000 1.4 @@ -21,6 +21,18 @@ TLow<V, V<THigh. +ti:- + format("~nTesting iterative deepening lpadsld.yap~n~n",[]), + files(F), + statistics(runtime,[_,_]), + set(ground_body,true), + format("~nGround body~n~n",[]), + test_filesi(F,ground_body(true)), + statistics(runtime,[_,T]), + T1 is T /1000, + format("Test successful, time ~f secs.~n",[T1]). +ti:- + format("Test unsuccessful.~n",[]). t:- format("~nTesting lpadsld.yap~n~n",[]), @@ -46,6 +58,16 @@ findall(A,test(A,H,GB),L), test_all(H,L), test_files(T,GB). +test_filesi([],_GB). + +test_filesi([H|T],GB):- + library_directory(LD), + atom_concat(LD,'/cplint/examples/',ExDir), + atom_concat(ExDir,H,NH), + p(NH),!, + findall(A,test(A,H,GB),L), + test_alli(H,L), + test_filesi(T,GB). test_all(_F,[]). @@ -56,6 +78,16 @@ call(H),!, test_all(F,T). +test_alli(_F,[]). + +test_alli(F,[H|T]):- + copy_term(H,NH), + NH=(s(Q,P),close_to('P',_Prob)), + format("~a ~p.~n",[F,NH]), + si(Q,PL,PU,T),!, + format("Lower bound ~f, Upper bound ~f~n",[PL,PU]), + test_all(F,T). + files([paper_ref_not,paper_ref,female,exapprox,exrange,threesideddice, mendel,student,school_simple,school,coin2,ex,trigger,throws,light]). |
|
From: Paulo M. <pm...@us...> - 2008-06-08 16:55:17
|
Update of /cvsroot/yap/pl In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5704/pl Modified Files: threads.yap Log Message: Corrected a bug in setting a thread exit status in case the thread goal results in an exception; exit status should be exception(Exception) and not exception(error(Exception,_)). Index: threads.yap =================================================================== RCS file: /cvsroot/yap/pl/threads.yap,v retrieving revision 1.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- threads.yap 8 Jun 2008 16:45:52 -0000 1.74 +++ threads.yap 8 Jun 2008 16:55:23 -0000 1.75 @@ -62,7 +62,7 @@ % format(user_error,'closing thread ~w~n',[v([Id0|Status])]). '$close_thread'(Exception, Detached, Id0) :- ( recorded('$thread_exit_status', [Id0|_], R), erase(R), fail - ; recorda('$thread_exit_status', [Id0|exception(Exception))], _) + ; recorda('$thread_exit_status', [Id0|exception(Exception)], _) ), '$run_at_thread_exit'(Id0), ( Detached == true -> @@ -83,7 +83,7 @@ -> true ; - recorda('$thread_exit_status', [Id|exception(resource_error(memory)))],_) + recorda('$thread_exit_status', [Id|exception(resource_error(memory))],_) ). thread_create(Goal, Id) :- @@ -100,7 +100,7 @@ -> true ; - recorda('$thread_exit_status', [Id|exception(resource_error(memory)))],_) + recorda('$thread_exit_status', [Id|exception(resource_error(memory))],_) ). thread_create(Goal, Id, Options) :- @@ -120,7 +120,7 @@ -> true ; - recorda('$thread_exit_status', [Id|exception(resource_error(memory)))],_) + recorda('$thread_exit_status', [Id|exception(resource_error(memory))],_) ). '$erase_thread_info'(Id) :- |
|
From: Paulo M. <pm...@us...> - 2008-06-08 16:45:47
|
Update of /cvsroot/yap/pl In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv1619/pl Modified Files: threads.yap Log Message: Corrected a bug in setting a thread exit status in case the thread goal results in an exception; exit status should be exception(Exception) and not exception(error(Exception,_)). Index: threads.yap =================================================================== RCS file: /cvsroot/yap/pl/threads.yap,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- threads.yap 10 May 2008 23:24:13 -0000 1.73 +++ threads.yap 8 Jun 2008 16:45:52 -0000 1.74 @@ -62,7 +62,7 @@ % format(user_error,'closing thread ~w~n',[v([Id0|Status])]). '$close_thread'(Exception, Detached, Id0) :- ( recorded('$thread_exit_status', [Id0|_], R), erase(R), fail - ; recorda('$thread_exit_status', [Id0|exception(error(Exception,_))], _) + ; recorda('$thread_exit_status', [Id0|exception(Exception))], _) ), '$run_at_thread_exit'(Id0), ( Detached == true -> @@ -83,7 +83,7 @@ -> true ; - recorda('$thread_exit_status', [Id|exception(error(resource_error(memory),thread_create(Goal)))],_) + recorda('$thread_exit_status', [Id|exception(resource_error(memory)))],_) ). thread_create(Goal, Id) :- @@ -100,7 +100,7 @@ -> true ; - recorda('$thread_exit_status', [Id|exception(error(resource_error(memory),thread_create(Goal,Id)))],_) + recorda('$thread_exit_status', [Id|exception(resource_error(memory)))],_) ). thread_create(Goal, Id, Options) :- @@ -120,7 +120,7 @@ -> true ; - recorda('$thread_exit_status', [Id|exception(error(resource_error(memory),thread_create(Goal,Id,Options)))],_) + recorda('$thread_exit_status', [Id|exception(resource_error(memory)))],_) ). '$erase_thread_info'(Id) :- |
|
From: Paulo M. <pm...@us...> - 2008-06-08 09:55:28
|
Update of /cvsroot/yap In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17678 Modified Files: distribute Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. |
|
From: Paulo M. <pm...@us...> - 2008-06-08 09:55:27
|
Update of /cvsroot/yap/LGPL In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17678/LGPL Modified Files: Makefile.in Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. Index: Makefile.in =================================================================== RCS file: /cvsroot/yap/LGPL/Makefile.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Makefile.in 4 Jun 2008 15:42:45 -0000 1.4 +++ Makefile.in 8 Jun 2008 09:55:34 -0000 1.5 @@ -38,6 +38,4 @@ mkdir -p $(DESTDIR)$(SHAREDIR)/Yap for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done for p in $(SWI_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/swi; done - mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/logtalk - for p in $(LOGTALK_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/logtalk; done |
|
From: Paulo M. <pm...@us...> - 2008-06-08 09:55:27
|
Update of /cvsroot/yap/library In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17678/library Modified Files: Makefile.in Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. Index: Makefile.in =================================================================== RCS file: /cvsroot/yap/library/Makefile.in,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- Makefile.in 8 Jun 2008 09:48:36 -0000 1.40 +++ Makefile.in 8 Jun 2008 09:55:34 -0000 1.41 @@ -79,15 +79,9 @@ $(srcdir)/MYDDAS/myddas_util_predicates.ypp \ $(srcdir)/MYDDAS/myddas_prolog2sql_optimizer.ypp -LOGTALK_PROGRAMS= \ - $(srcdir)/logtalk/logtalk.pl \ - $(srcdir)/logtalk/yap.config - install: $(PROGRAMS) install_myddas mkdir -p $(DESTDIR)$(SHAREDIR)/Yap for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done - mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/logtalk - for p in $(LOGTALK_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/logtalk; done install_myddas: $(MYDDAS_PROGRAMS) count=`echo "$(YAP_EXTRAS)" | grep MYDDAS | wc -l`; \ |
|
From: Paulo M. <pm...@us...> - 2008-06-08 09:55:27
|
Update of /cvsroot/yap/GPL In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17678/GPL Modified Files: Makefile.in Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. Index: Makefile.in =================================================================== RCS file: /cvsroot/yap/GPL/Makefile.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile.in 12 Feb 2008 17:03:52 -0000 1.1 +++ Makefile.in 8 Jun 2008 09:55:34 -0000 1.2 @@ -35,6 +35,4 @@ install: $(PROGRAMS) mkdir -p $(DESTDIR)$(SHAREDIR)/Yap for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done - mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/logtalk - for p in $(LOGTALK_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/logtalk; done |
|
From: Paulo M. <pm...@us...> - 2008-06-08 09:48:36
|
Update of /cvsroot/yap/library In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14514/library Modified Files: Makefile.in Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. Index: Makefile.in =================================================================== RCS file: /cvsroot/yap/library/Makefile.in,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- Makefile.in 15 May 2008 13:41:46 -0000 1.39 +++ Makefile.in 8 Jun 2008 09:48:36 -0000 1.40 @@ -41,7 +41,6 @@ $(srcdir)/lineutils.yap \ $(srcdir)/listing.yap \ $(srcdir)/lists.yap \ - $(srcdir)/logtalk.yap \ $(srcdir)/nb.yap \ $(srcdir)/ordsets.yap \ $(srcdir)/matlab.yap \ |
|
From: Fabrizio R. <rz...@us...> - 2008-06-08 08:38:40
|
Update of /cvsroot/yap/cplint In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17262 Modified Files: cplint.h cplint_yap.c lpadclpbn.pl lpadsld.pl lpadvel.pl Log Message: added memory profiling calls removed limit to 1000 variables imposed by createVars beause of the use of tha array of names of variables Index: cplint.h =================================================================== RCS file: /cvsroot/yap/cplint/cplint.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- cplint.h 5 Dec 2007 10:47:19 -0000 1.3 +++ cplint.h 8 Jun 2008 08:38:36 -0000 1.4 @@ -29,7 +29,7 @@ } variable; -void createVars(array_t * vars, YAP_Term t,DdManager * mgr, array_t * bVar2mVar, char inames[1000][20]); +void createVars(array_t * vars, YAP_Term t,DdManager * mgr, array_t * bVar2mVar,int create_dot, char inames[1000][20]); void createExpression(array_t * expression, YAP_Term t); void init_my_predicates(void); int compare(char *a, char *b); Index: cplint_yap.c =================================================================== RCS file: /cvsroot/yap/cplint/cplint_yap.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- cplint_yap.c 8 Nov 2007 11:32:14 -0000 1.2 +++ cplint_yap.c 8 Jun 2008 08:38:36 -0000 1.3 @@ -24,7 +24,7 @@ void reverse(char s[]); static int compute_prob(void); -void createVars(array_t * vars, YAP_Term t,DdManager * mgr, array_t * bVar2mVar, char inames[1000][20]) +void createVars(array_t * vars, YAP_Term t,DdManager * mgr, array_t * bVar2mVar,int create_dot, char inames[1000][20]) /* adds the boolean variables to the BDD and returns an array_t containing them (array_t is defined in the util library of glu) returns also the names of the variables to be used to save the ADD in dot format @@ -52,12 +52,15 @@ v.booleanVars=array_alloc(DdNode *,0); for (i=0;i<nVal;i++) { - strcpy(inames[b+i],"X"); - sprintf(numberVar,"%d",varIndex); - strcat(inames[b+i],numberVar); - strcat(inames[b+i],"_"); - sprintf(numberBit,"%d",i); - strcat(inames[b+i],numberBit); + if (create_dot) + { + strcpy(inames[b+i],"X"); + sprintf(numberVar,"%d",varIndex); + strcat(inames[b+i],numberVar); + strcat(inames[b+i],"_"); + sprintf(numberBit,"%d",i); + strcat(inames[b+i],numberBit); + } p=YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm)); array_insert(double,v.probabilities,i,p); probTerm=YAP_TailOfTerm(probTerm); @@ -112,7 +115,7 @@ array_t * variables,* expression, * bVar2mVar; DdNode * function, * add; DdManager * mgr; - int nBVar,i,j,intBits; + int nBVar,i,j,intBits,create_dot; FILE * file; DdNode * array[1]; char * onames[1]; @@ -120,20 +123,29 @@ char * names[1000]; GHashTable * nodes; /* hash table that associates nodes with their probability if already computed, it is defined in glib */ - + Cudd_ReorderingType order; arg1=YAP_ARG1; arg2=YAP_ARG2; arg3=YAP_ARG3; arg4=YAP_ARG4; mgr=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0); - variables=array_alloc(variable,0); bVar2mVar=array_alloc(int,0); - createVars(variables,arg1,mgr,bVar2mVar,inames); + create_dot=YAP_IntOfTerm(arg4); + createVars(variables,arg1,mgr,bVar2mVar,create_dot,inames); + Cudd_PrintInfo(mgr,stderr); /* automatic variable reordering, default method CUDD_REORDER_SIFT used */ - Cudd_AutodynEnable(mgr,CUDD_REORDER_SAME); + printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); + printf("order %d\n",order); + + Cudd_AutodynEnable(mgr,CUDD_REORDER_SAME); +/* Cudd_AutodynEnable(mgr, CUDD_REORDER_RANDOM_PIVOT); + printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); + printf("order %d\n",order); + printf("%d",CUDD_REORDER_RANDOM_PIVOT); +*/ expression=array_alloc(array_t *,0); @@ -143,8 +155,9 @@ /* the BDD build by retFunction is converted to an ADD (algebraic decision diagram) because it is easier to interpret and to print */ add=Cudd_BddToAdd(mgr,function); + Cudd_PrintInfo(mgr,stderr); - if (YAP_IntOfTerm(arg4)) + if (create_dot) /* if specified by the user, a dot file for the BDD is written to cpl.dot */ { nBVar=array_n(bVar2mVar); Index: lpadclpbn.pl =================================================================== RCS file: /cvsroot/yap/cplint/lpadclpbn.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- lpadclpbn.pl 2 May 2008 14:21:00 -0000 1.7 +++ lpadclpbn.pl 8 Jun 2008 08:38:36 -0000 1.8 @@ -115,6 +115,7 @@ CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, + print_mem, build_ground_lpad(L2,0,CL), convert_to_clpbn(CL,GL,LV,P), statistics(cputime,[_,CT2]), @@ -122,6 +123,7 @@ statistics(walltime,[_,WT2]), WallTime2 is WT2/1000 ; + print_mem, P=0.0, statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, @@ -130,7 +132,9 @@ CPUTime2 =0.0, statistics(walltime,[_,WT2]), WallTime2 =0.0 - ),!. + ),!, + format(user_error,"Memory after inference~n",[]), + print_mem. /* sc(GoalsList,EvidenceList,Prob) compute the probability of a list of goals GoalsList given EvidenceList. Both lists can have variables, sc returns in @@ -151,6 +155,7 @@ CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, + print_mem, build_ground_lpad(LD1,0,CL), convert_to_clpbn(CL,GL,LV,P,GLC), statistics(cputime,[_,CT2]), @@ -159,6 +164,8 @@ WallTime2 is WT2/1000 ; P=0.0, + print_mem, + format(user_error,"Porb 0~n",[]), statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), @@ -168,13 +175,18 @@ ) ; P=undef, + print_mem, statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, CPUTime2 =0.0, - WallTime2 =0.0 - ). + WallTime2 =0.0, + print_mem, + format(user_error,"Undef~n",[]) + ), + format(user_error,"Memory after inference~n",[]), + print_mem. remove_head([],[]). @@ -435,6 +447,15 @@ find_atoms_head([H:P|T],[H|TA],[P|TP]):- find_atoms_head(T,TA,TP). +print_mem:- + statistics(global_stack,[GS,GSF]), + statistics(local_stack,[LS,LSF]), + statistics(heap,[HP,HPF]), + statistics(trail,[TU,TF]), + format(user_error,"~nGloabal stack used ~d execution stack free: ~d~n",[GS,GSF]), + format(user_error,"Local stack used ~d execution stack free: ~d~n",[LS,LSF]), + format(user_error,"Heap used ~d heap free: ~d~n",[HP,HPF]), + format(user_error,"Trail used ~d Trail free: ~d~n",[TU,TF]). find_deriv(GoalsList,Deriv):- solve(GoalsList,[],DerivDup), Index: lpadsld.pl =================================================================== RCS file: /cvsroot/yap/cplint/lpadsld.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- lpadsld.pl 2 May 2008 06:22:23 -0000 1.7 +++ lpadsld.pl 8 Jun 2008 08:38:36 -0000 1.8 @@ -68,7 +68,11 @@ CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, - build_formula(L,Formula,[],Var), + print_mem, + build_formula(L,Formula,[],Var,0,Conj), + length(L,ND), + length(Var,NV), + format(user_error,"Disjunctions :~d~nConjunctions: ~d~nVariables ~d~n",[ND,Conj,NV]), var2numbers(Var,0,NewVar), (setting(save_dot,true)-> format("Variables: ~p~n",[Var]), @@ -81,6 +85,7 @@ statistics(walltime,[_,WT2]), WallTime2 is WT2/1000 ; + print_mem, Prob=0.0, statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, @@ -89,9 +94,19 @@ CPUTime2 =0.0, statistics(walltime,[_,WT2]), WallTime2 =0.0 - ),!. - - + ),!, + format(user_error,"~nMemory after inference~n",[]), + print_mem. + +print_mem:- + statistics(global_stack,[GS,GSF]), + statistics(local_stack,[LS,LSF]), + statistics(heap,[HP,HPF]), + statistics(trail,[TU,TF]), + format(user_error,"~nGloabal stack used ~d execution stack free: ~d~n",[GS,GSF]), + format(user_error,"Local stack used ~d execution stack free: ~d~n",[LS,LSF]), + format(user_error,"Heap used ~d heap free: ~d~n",[HP,HPF]), + format(user_error,"Trail used ~d Trail free: ~d~n",[TU,TF]). find_deriv(GoalsList,Deriv):- solve(GoalsList,[],DerivDup), @@ -111,6 +126,7 @@ (setof(DerivE,find_deriv(Evidence,DerivE),LDupE)-> rem_dup_lists(LDupE,[],LE), (setof(DerivGE,find_deriv_GE(LE,Goals,DerivGE),LDupGE)-> + print_mem, rem_dup_lists(LDupGE,[],LGE), build_formula(LE,FormulaE,[],VarE), var2numbers(VarE,0,NewVarE), @@ -120,11 +136,15 @@ call_compute_prob(NewVarGE,FormulaGE,ProbGE), Prob is ProbGE/ProbE ; + print_mem, Prob=0.0 ) ; + print_mem, Prob=undefined - ). + ), + format(user_error,"~nMemory after inference~n",[]), + print_mem. /* sc(Goals,Evidence,Prob,Time1,Time2) compute the conditional probability of the list of goals Goals given the list of goals Evidence @@ -502,6 +522,14 @@ Factorj is of the form (Var,Value) where Var is the index of the multivalued variable Var and Value is the index of the value */ +build_formula([],[],Var,Var,C,C). + +build_formula([D|TD],[F|TF],VarIn,VarOut,C0,C1):- + length(D,NC), + C2 is C0+NC, + build_term(D,F,VarIn,Var1), + build_formula(TD,TF,Var1,VarOut,C2,C1). + build_formula([],[],Var,Var). build_formula([D|TD],[F|TF],VarIn,VarOut):- Index: lpadvel.pl =================================================================== RCS file: /cvsroot/yap/cplint/lpadvel.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- lpadvel.pl 30 Apr 2008 18:06:46 -0000 1.9 +++ lpadvel.pl 8 Jun 2008 08:38:36 -0000 1.10 @@ -107,20 +107,36 @@ CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, + print_mem, convert_to_bn(CL,GL,[],P), statistics(cputime,[_,CT2]), CPUTime2 is CT2/1000, statistics(walltime,[_,WT2]), WallTime2 is WT2/1000 + ; statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, + print_mem, CPUTime2=0.0, WallTime2=0.0, P=0.0 - ). + ), + format(user_error,"~nMemory after inference~n",[]), + print_mem. + +print_mem:- + statistics(global_stack,[GS,GSF]), + statistics(local_stack,[LS,LSF]), + statistics(heap,[HP,HPF]), + statistics(trail,[TU,TF]), + format(user_error,"~nGloabal stack used ~d execution stack free: ~d~n",[GS,GSF]), + format(user_error,"Local stack used ~d execution stack free: ~d~n",[LS,LSF]), + format(user_error,"Heap used ~d heap free: ~d~n",[HP,HPF]), + format(user_error,"Trail used ~d Trail free: ~d~n",[TU,TF]). + /* sc(GoalsList,EvidenceList,Prob) compute the probability of a list of goals GoalsList given EvidenceList. Both lists can have variables, sc returns in @@ -136,6 +152,7 @@ CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, + print_mem, (Undef=yes-> P=undef, CPUTime2=0.0, @@ -148,6 +165,7 @@ WallTime2 is WT2/1000 ) ; + print_mem, statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), @@ -155,7 +173,9 @@ CPUTime2=0.0, WallTime2=0.0, P=0.0 - ). + ), + format(user_error,"~nMemory after inference~n",[]), + print_mem. remove_head([],[]). |
|
From: Vitor S. C. <vs...@us...> - 2008-06-08 08:05:09
|
Update of /cvsroot/yap/library In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv6832/library Modified Files: rbtrees.yap Log Message: put chr back to life Index: rbtrees.yap =================================================================== RCS file: /cvsroot/yap/library/rbtrees.yap,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- rbtrees.yap 5 Jun 2008 22:12:22 -0000 1.13 +++ rbtrees.yap 8 Jun 2008 08:05:11 -0000 1.14 @@ -923,7 +923,7 @@ is_rbtree(X,_) :- var(X), !, fail. is_rbtree(T,Goal) :- - catch(rbtree1(T), msg(S,Args), format(S,Args)). + catch(rbtree1(T), msg(S,Args), (once(Goal),format(S,Args))). % % This code checks if a tree is ordered and a rbtree |
|
From: Vitor S. C. <vs...@us...> - 2008-06-08 08:05:07
|
Update of /cvsroot/yap/C In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv6832/C Modified Files: heapgc.c tracer.c Log Message: put chr back to life Index: heapgc.c =================================================================== RCS file: /cvsroot/yap/C/heapgc.c,v retrieving revision 1.210 retrieving revision 1.211 diff -u -r1.210 -r1.211 --- heapgc.c 4 Jun 2008 13:58:36 -0000 1.210 +++ heapgc.c 8 Jun 2008 08:05:11 -0000 1.211 @@ -3456,15 +3456,15 @@ cont_top0 = (cont *)db_vec; #endif cont_top = (cont *)db_vec; +#ifdef COROUTINING + mark_delays(max); +#endif /* These two must be marked first so that our trail optimisation won't lose values */ mark_regs(old_TR); /* active registers & trail */ /* active environments */ mark_environments(current_env, EnvSize(curp), EnvBMap((CELL *)curp)); mark_choicepoints(B, old_TR, is_gc_very_verbose()); /* choicepoints, and environs */ -#ifdef COROUTINING - mark_delays(max); -#endif #ifdef EASY_SHUNTING set_conditionals(sTR); #endif Index: tracer.c =================================================================== RCS file: /cvsroot/yap/C/tracer.c,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- tracer.c 5 Jun 2008 16:24:08 -0000 1.160 +++ tracer.c 8 Jun 2008 08:05:11 -0000 1.161 @@ -164,8 +164,6 @@ LOCK(Yap_heap_regs->low_level_trace_lock); sc = Yap_heap_regs; vsc_count++; - if (vsc_count < 67689000LL) - return; #ifdef THREADS Yap_heap_regs->thread_handle[worker_id].thread_inst_count++; #endif |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:12:09
|
Update of /cvsroot/yap/docs In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/docs Modified Files: yap.tex Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. Index: yap.tex =================================================================== RCS file: /cvsroot/yap/docs/yap.tex,v retrieving revision 1.252 retrieving revision 1.253 diff -u -r1.252 -r1.253 --- yap.tex 4 Jun 2008 13:58:37 -0000 1.252 +++ yap.tex 7 Jun 2008 10:11:43 -0000 1.253 @@ -414,10 +414,8 @@ @url{http://logtalk.org/} -The package is distributed under the Artistic License 2.0. -Minimal instructions about loading this package are included in this document. -The documentation on this package (including full installation and customization -instructions) is included in the @code{Logtalk} directory. +Logtalk is no longer distributed with YAP. Please use the Logtalk standalone +installer for a smooth integration with YAP. @item The Pillow WEB library developed at Universidad Politecnica de Madrid by the CLIP group. This package is distributed under the FSF's @@ -12153,16 +12151,11 @@ @chapter Logtalk @cindex Logtalk - -The Logtalk object-oriented extension is available once included -with the @code{use_module(library(logtalk))} command. Note that, -although we load Logtalk using the @code{use_module/1} built-in -predicate, the system is not packaged as a module not does it use -modules in its implementation. - -Logtalk documentation is included in the Logtalk directory. Be sure to read the Logtalk/INSTALL.txt and Logtalk/CUSTOMIZE.txt files for additional instructions on how to customize your Logtalk installation to match your working environment (the @code{use_module/1} call described above only provides minimal support). - -For the latest Logtalk news, please see the URL @url{http://logtalk.org/}. +The Logtalk object-oriented extension is available after running its +standalone installer by using the @code{yaplgt} command in POSIX +systems or by using the @code{Logtalk - YAP} shortcut in the Logtalk +program group in the Start Menu on Windows systems. For more information +please see the URL @url{http://logtalk.org/}. @node Threads, Parallelism, Logtalk, Extensions @chapter Threads |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:43
|
Update of /cvsroot/yap/Logtalk/library/experimental/b In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/library/experimental/b Removed Files: system.lgt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- system.lgt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:43
|
Update of /cvsroot/yap/Logtalk/examples In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/examples Removed Files: NOTES.txt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- NOTES.txt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:43
|
Update of /cvsroot/yap/Logtalk/library/experimental/qp In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/library/experimental/qp Removed Files: system.lgt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- system.lgt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:41
|
Update of /cvsroot/yap/Logtalk/library/experimental/als In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/library/experimental/als Removed Files: system.lgt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- system.lgt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:41
|
Update of /cvsroot/yap/Logtalk/wenv/vim In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/wenv/vim Removed Files: NOTES.txt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- NOTES.txt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:40
|
Update of /cvsroot/yap/Logtalk/wenv/vim/indent In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/wenv/vim/indent Removed Files: logtalk.vim Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- logtalk.vim DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:40
|
Update of /cvsroot/yap/Logtalk/wenv/subethaedit2/Logtalk.mode/Contents In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/wenv/subethaedit2/Logtalk.mode/Contents Removed Files: Info.plist Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- Info.plist DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:40
|
Update of /cvsroot/yap/Logtalk/wenv/nano In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/wenv/nano Removed Files: logtalk.nanorc NOTES.txt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- logtalk.nanorc DELETED --- --- NOTES.txt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:40
|
Update of /cvsroot/yap/Logtalk/examples/lo In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/examples/lo Removed Files: NOTES.txt Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- NOTES.txt DELETED --- |
|
From: Paulo M. <pm...@us...> - 2008-06-07 10:11:40
|
Update of /cvsroot/yap/Logtalk/manuals/migration In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32303/Logtalk/manuals/migration Removed Files: index.html Log Message: Logtalk is no longer distributed with YAP. Please use the Logtalk standalone installer for a smooth integration with YAP. --- index.html DELETED --- |