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
|
% if BDD file does not exist, call ProbLog
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
trace,
|
writeln(QueryID),
|
||||||
(
|
(
|
||||||
recorded(QueryID, _, _)
|
recorded(QueryID, _, _)
|
||||||
->
|
->
|
||||||
@ -635,12 +635,17 @@ init_one_query(QueryID,Query,Type) :-
|
|||||||
Query =.. [_,X,Y]
|
Query =.. [_,X,Y]
|
||||||
->
|
->
|
||||||
Bdd = bdd(Dir, Tree, MapList),
|
Bdd = bdd(Dir, Tree, MapList),
|
||||||
graph2bdd(X,Y,N,Bdd),
|
(
|
||||||
|
graph2bdd(X,Y,N,Bdd)
|
||||||
|
->
|
||||||
rb_new(H0),
|
rb_new(H0),
|
||||||
maplist_to_hash(MapList, H0, Hash),
|
maplist_to_hash(MapList, H0, Hash),
|
||||||
Tree \= [],
|
Tree \= [],
|
||||||
writeln(QueryID),
|
|
||||||
tree_to_grad(Tree, Hash, [], Grad),
|
tree_to_grad(Tree, Hash, [], Grad),
|
||||||
|
;
|
||||||
|
Bdd = bdd(-1,[],[]),
|
||||||
|
Grad=[]
|
||||||
|
),
|
||||||
recordz(QueryID,bdd(Dir, Grad, MapList),_)
|
recordz(QueryID,bdd(Dir, Grad, MapList),_)
|
||||||
;
|
;
|
||||||
b_setval(problog_required_keep_ground_ids,false),
|
b_setval(problog_required_keep_ground_ids,false),
|
||||||
|
@ -40,7 +40,6 @@ progress(FX,X,G,X_Norm,G_Norm,Step,_N,Iteration,Ls, 0) :-
|
|||||||
|
|
||||||
|
|
||||||
demo :-
|
demo :-
|
||||||
start_low_level_trace,
|
|
||||||
format('Optimizing the function f(x0) = sin(x0)~n',[]),
|
format('Optimizing the function f(x0) = sin(x0)~n',[]),
|
||||||
optimizer_initialize(1,X,Status),
|
optimizer_initialize(1,X,Status),
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ progress(FX,X,_G,X_Norm,G_Norm,Step,_N,Iteration,Ls,0) :-
|
|||||||
|
|
||||||
demo :-
|
demo :-
|
||||||
format('Optimizing the function f(x0,x1) = (x0-2)^2 + (x1-1)^2~n',[]),
|
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,
|
StartX0 is random*1000-500,
|
||||||
@ -55,7 +55,7 @@ demo :-
|
|||||||
X[1] <== StartX1,
|
X[1] <== StartX1,
|
||||||
|
|
||||||
|
|
||||||
optimizer_run(BestF,Status),
|
optimizer_run(Status,BestF,BestX0, O),
|
||||||
BestX0 <== X[0],
|
BestX0 <== X[0],
|
||||||
BestX1 <== X[1],
|
BestX1 <== X[1],
|
||||||
|
|
||||||
|
@ -162,18 +162,16 @@ optimizer_initialize(1)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
optimizer_initialize(N,X,t(N,X,XO,Params)) :-
|
optimizer_initialize(N,X,t(N,X,XO,Params)) :-
|
||||||
\+ initialized,
|
|
||||||
|
|
||||||
integer(N),
|
integer(N),
|
||||||
N>0,
|
N>0,
|
||||||
|
|
||||||
% check whether there are such call back functions
|
% 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
|
% install call back predicates in the user module which call
|
||||||
% the predicates given by the arguments
|
% the predicates given by the arguments
|
||||||
assert(initialized).
|
|
||||||
|
|
||||||
/** @pred optimizer_finalize/0
|
/** @pred optimizer_finalize/0
|
||||||
Clean up the memory.
|
Clean up the memory.
|
||||||
|
Reference in New Issue
Block a user