diff --git a/packages/ProbLog/problog_learning_lbdd.yap b/packages/ProbLog/problog_learning_lbdd.yap index 2f6860d4d..a68b2f199 100644 --- a/packages/ProbLog/problog_learning_lbdd.yap +++ b/packages/ProbLog/problog_learning_lbdd.yap @@ -624,7 +624,7 @@ init_one_query(QueryID,Query,Type) :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % if BDD file does not exist, call ProbLog %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - trace, + writeln(QueryID), ( recorded(QueryID, _, _) -> @@ -635,13 +635,18 @@ init_one_query(QueryID,Query,Type) :- Query =.. [_,X,Y] -> Bdd = bdd(Dir, Tree, MapList), - graph2bdd(X,Y,N,Bdd), + ( + graph2bdd(X,Y,N,Bdd) + -> rb_new(H0), maplist_to_hash(MapList, H0, Hash), Tree \= [], - writeln(QueryID), tree_to_grad(Tree, Hash, [], Grad), - recordz(QueryID,bdd(Dir, Grad, MapList),_) + ; + Bdd = bdd(-1,[],[]), + Grad=[] + ), + recordz(QueryID,bdd(Dir, Grad, MapList),_) ; b_setval(problog_required_keep_ground_ids,false), rb_new(H0), diff --git a/packages/yap-lbfgs/ex1.pl b/packages/yap-lbfgs/ex1.pl index 77258b20d..fae5512c5 100644 --- a/packages/yap-lbfgs/ex1.pl +++ b/packages/yap-lbfgs/ex1.pl @@ -40,7 +40,6 @@ progress(FX,X,G,X_Norm,G_Norm,Step,_N,Iteration,Ls, 0) :- demo :- -start_low_level_trace, format('Optimizing the function f(x0) = sin(x0)~n',[]), optimizer_initialize(1,X,Status), diff --git a/packages/yap-lbfgs/ex2.pl b/packages/yap-lbfgs/ex2.pl index 1a6e0f30d..3a4f39320 100644 --- a/packages/yap-lbfgs/ex2.pl +++ b/packages/yap-lbfgs/ex2.pl @@ -44,7 +44,7 @@ progress(FX,X,_G,X_Norm,G_Norm,Step,_N,Iteration,Ls,0) :- demo :- format('Optimizing the function f(x0,x1) = (x0-2)^2 + (x1-1)^2~n',[]), - optimizer_initialize(2,X), + optimizer_initialize(2,X,Status), StartX0 is random*1000-500, @@ -55,7 +55,7 @@ demo :- X[1] <== StartX1, - optimizer_run(BestF,Status), + optimizer_run(Status,BestF,BestX0, O), BestX0 <== X[0], BestX1 <== X[1], diff --git a/packages/yap-lbfgs/lbfgs.pl b/packages/yap-lbfgs/lbfgs.pl index 14881398f..bec3cc7c7 100644 --- a/packages/yap-lbfgs/lbfgs.pl +++ b/packages/yap-lbfgs/lbfgs.pl @@ -162,18 +162,16 @@ optimizer_initialize(1) */ optimizer_initialize(N,X,t(N,X,XO,Params)) :- - \+ initialized, integer(N), N>0, % check whether there are such call back functions - optimizer_reserve_memory(N,X,XO,Params), + optimizer_reserve_memory(N,X,XO,Params). % install call back predicates in the user module which call % the predicates given by the arguments - assert(initialized). /** @pred optimizer_finalize/0 Clean up the memory.