Problog
This commit is contained in:
parent
9ec1ffb2c7
commit
29f79473e5
@ -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),
|
||||
|
@ -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),
|
||||
|
||||
|
@ -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],
|
||||
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user