debugger
yap4r
This commit is contained in:
parent
2f1eb61cf9
commit
b24df86cb0
@ -269,16 +269,25 @@ solver_iteration(0).
|
||||
%= store the facts with the learned probabilities to a file
|
||||
%========================================================================
|
||||
|
||||
save_model:-
|
||||
save_model(X):-
|
||||
problog_flag(sigmoid_slope,Slope),
|
||||
current_iteration(Iteration),
|
||||
solver_iteration(LBFGSIteration),
|
||||
Id is Iteration*100+LBFGSIteration,
|
||||
create_factprobs_file_name(Id,Filename),
|
||||
retractall( query_probability_intern(_,_)),
|
||||
forall(
|
||||
user:example(QueryID,_Query,_QueryProb),
|
||||
(recorded(QueryID,BDD,_),
|
||||
BDD = bdd(_,_,MapList),
|
||||
bind_maplist(MapList, Slope, X),
|
||||
query_probabilities( BDD, BDDProb),
|
||||
assert( query_probability_intern(QueryID,BDDProb)))
|
||||
),
|
||||
export_facts(Filename).
|
||||
|
||||
|
||||
|
||||
|
||||
%========================================================================
|
||||
%= find out whether some example IDs are used more than once
|
||||
%= if so, complain and stop
|
||||
@ -423,8 +432,6 @@ do_learning_intern(Iterations,Epsilon) :-
|
||||
%leash(0),trace,
|
||||
gradient_descent,
|
||||
|
||||
once(save_model),
|
||||
update_values,
|
||||
mse_trainingset,
|
||||
(
|
||||
last_mse(Last_MSE)
|
||||
@ -669,7 +676,6 @@ mse_trainingset :-
|
||||
create_training_predictions_file_name(Iteration,File_Name),
|
||||
open(File_Name, write,Handle),
|
||||
format_learning(2,'MSE_Training ',[]),
|
||||
update_values,
|
||||
findall(t(LogCurrentProb,SquaredError),
|
||||
(user:example(QueryID,Query,TrueQueryProb,_Type),
|
||||
query_probability(QueryID,CurrentProb),
|
||||
@ -714,7 +720,6 @@ mse_testset :-
|
||||
create_test_predictions_file_name(Iteration,File_Name),
|
||||
open(File_Name, write,Handle),
|
||||
format_learning(2,'MSE_Test ',[]),
|
||||
update_values,
|
||||
bb_put(llh_test_queries,0.0),
|
||||
findall(SquaredError,
|
||||
(user:test_example(QueryID,Query,TrueQueryProb,Type),
|
||||
@ -902,7 +907,7 @@ user:progress(FX,X,_G,X_Norm,G_Norm,Step,_N, LBFGSIteration,Ls,0) :-
|
||||
logger_set_variable(mse_trainingset, FX),
|
||||
retractall(solver_iterations(_)),
|
||||
assert(solver_iterations(LBFGSIteration)),
|
||||
save_model,
|
||||
save_model(X),
|
||||
X0 <== X[0], sigmoid(X0,Slope,P0),
|
||||
X1 <== X[1], sigmoid(X1,Slope,P1),
|
||||
format('~d. Iteration : (x0,x1)=(~4f,~4f) f(X)=~4f |X|=~4f |X\'|=~4f Step=~4f Ls=~4f~n',[LBFGSIteration,P0,P1,FX,X_Norm,G_Norm,Step,Ls]).
|
||||
|
@ -433,12 +433,14 @@ endforeach()
|
||||
|
||||
add_custom_target(YAP_KERNEL ALL
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${OUTS} YAP4PY
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build sdist bdist
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${OUTS} YAP4PY
|
||||
)
|
||||
|
||||
|
||||
set(REAL_SOURCES real.c)
|
||||
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build sdist bdist
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed --no-deps .
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m yap_kernel.kernelspec
|
||||
ERROR_VARIABLE setupErr
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
# PROJECT ( YAP_REAL C )
|
||||
|
||||
|
||||
|
||||
set(REAL_SOURCES real.c)
|
||||
|
||||
# LIBR_FOUND
|
||||
@ -16,6 +14,20 @@ set_package_properties(R PROPERTIES
|
||||
DESCRIPTION "The R Project for Statistical Computing."
|
||||
|
||||
URL "https://www.r-project.org/")
|
||||
|
||||
|
||||
foreach(f ${FILES})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${f}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${CMAKE_CURRENT_BINARY_DIR}/${f}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${f}
|
||||
)
|
||||
list(APPEND OUTS ${CMAKE_CURRENT_BINARY_DIR}/${f} )
|
||||
endforeach()
|
||||
|
||||
add_custom_target(YAP4R
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${OUTS}
|
||||
)
|
||||
add_library(real ${REAL_SOURCES})
|
||||
target_link_libraries (real ${LIBR_LIBRARIES} libYap)
|
||||
include_directories (
|
||||
@ -36,6 +48,23 @@ include_directories (
|
||||
check_include_files( "Rembedded.h;Rinterface.h" HAVE_R_INTERFACE_H )
|
||||
|
||||
configure_file ("rconfig.h.cmake" "rconfig.h" )
|
||||
configure_file ("yap4r/src/Makevars.in" "yap4r/src/Makevars" )
|
||||
|
||||
|
||||
set(YAP4R_SOURCES
|
||||
yap4r/man/yap4r-package.Rd
|
||||
yap4r/R
|
||||
yap4r/R/RcppExports.R
|
||||
yap4r/NAMESPACE
|
||||
yap4r/DESCRIPTION
|
||||
yap4r/src
|
||||
yap4r/src/Makevars.in
|
||||
yap4r/src/yap4r.cpp
|
||||
yap4r/src/RcppExports.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
install(TARGETS real
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
|
@ -1,2 +1,2 @@
|
||||
PKG_LIBS=-L/home/vsc/.local/lib/Yap/ -lreal
|
||||
PKG_CPPFLAGS=-I../../../../CXX -I../../../../build -I../../../../include -I../../../../H -I../../../../OPTYap -I../../../../os -I../..
|
||||
PKG_LIBS=-L${YAP_LIBDIR} -L${YAP_DLLDIR} -L ../../.. -lreal -lYap
|
||||
PKG_CPPFLAGS=-I${YAP_SOURCE_DIR}/CXX -I${YAP_BINARY_DIR} -I${YAP_SOURCE_DIR}/include -I${YAP_SOURCE_DIR}/H -I${YAP_SOURCE_DIR}/OPTYap -I${YAP_SOURCE_DIR}/os -I../..
|
||||
|
24
pl/debug.yap
24
pl/debug.yap
@ -81,7 +81,7 @@ To start debugging, the user will either call `trace` or spy the
|
||||
relevant procedures, entering debug mode, and start execution of the
|
||||
program. When finding the first spy-point, YAP's debugger will take
|
||||
control and show a message of the form:
|
||||
|
||||
v
|
||||
~~~~~
|
||||
* (1) call: quicksort([1,2,3],_38) ?
|
||||
~~~~~
|
||||
@ -167,7 +167,7 @@ the argument, the command fails all the way to the goal. If goal _GoalId_ has c
|
||||
side effects of the goal cannot be undone. This command is not available
|
||||
at the call port. If <tt>f</tt> receives a goal number as the argument, the
|
||||
command retries goal _GoalId_ instead. If goal _GoalId_ has
|
||||
completed execution, YAP fails until meeting the first active ancestor.
|
||||
vcompleted execution, YAP fails until meeting the first active ancestor.
|
||||
|
||||
+ `a` - abort
|
||||
|
||||
@ -525,10 +525,10 @@ be lost.
|
||||
true
|
||||
),
|
||||
/* get goal list */
|
||||
'__NB_getval__'('$spy_glist',History,true),
|
||||
'__NB_getval__'('$spy_glist',History,History=[]),
|
||||
H = [Info|History],
|
||||
Info = info(L,Module,G,_Retry,_Det,_HasFoundAnswers),
|
||||
'__B_setval__'('$spy_glist',H),
|
||||
b_setval('$spy_glist',H),
|
||||
/* and update it */
|
||||
'$port'(call,G,Module,L,deterministic, Info).
|
||||
|
||||
@ -610,7 +610,10 @@ be lost.
|
||||
'$stop_creeping'(_) ,
|
||||
current_prolog_flag(debug, true),
|
||||
'__NB_getval__'('$debug_status',state(Skip,Border,_,Trace), fail),
|
||||
( Skip == creep -> true; '$id_goal'(GoalNumber), GoalNumber =< Border),
|
||||
( Skip == creep -> true;
|
||||
'$stop_creeping'(_) ,
|
||||
'$id_goal'(GoalNumber),
|
||||
GoalNumber =< Border),
|
||||
!,
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop,Trace)),
|
||||
'$trace_port_'(Port, GoalNumber, G, Module, Info).
|
||||
@ -624,15 +627,18 @@ be lost.
|
||||
'$trace_port_'(answer, GoalNumber, G, Module, Info) :-
|
||||
'$port'(exit,G,Module,GoalNumber,nondeterministic, Info).
|
||||
'$trace_port_'(redo, GoalNumber, G, Module, Info) :-
|
||||
'$port'(redo,G,Module,GoalNumber,nondeterministic, Info), /* inform user_error */
|
||||
'$stop_creeping'(_ ).
|
||||
'$stop_creeping'(_ ),
|
||||
'$port'(redo,G,Module,GoalNumber,nondeterministic, Info). /* inform user_error */
|
||||
'$trace_port_'(fail, GoalNumber, G, Module, Info) :-
|
||||
'$stop_creeping'(_ ),
|
||||
'$port'(fail,G,Module,GoalNumber,deterministic, Info). /* inform user_error */
|
||||
'$trace_port_'(! ,_GoalNumber,_G,_Module,_Imfo) :- /* inform user_error */
|
||||
!.
|
||||
'$trace_port_'(exception(E), GoalNumber, G, Module, Info) :-
|
||||
'$stop_creeping'(_ ),
|
||||
'$TraceError'(E, GoalNumber, G, Module, Info).
|
||||
'$trace_port_'(external_exception(E), GoalNumber, G, Module, Info) :-
|
||||
'$stop_creeping'(_ ),
|
||||
'$TraceError'(E, GoalNumber, G, Module, Info).
|
||||
|
||||
|
||||
@ -754,7 +760,7 @@ be lost.
|
||||
'$action'(C,P,CallNumber,G,Module,H).
|
||||
'$action'('\n',_,_,_,_,_) :- !, % newline creep
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__Nb_setval__'('$debug_status', state(creep, 0, stop, Trace)).
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop, Trace)).
|
||||
'$action'(!,_,_,_,_,_) :- !, % ! 'g execute
|
||||
read(debugger_input, G),
|
||||
% don't allow yourself to be caught by creep.
|
||||
@ -1075,7 +1081,7 @@ be lost.
|
||||
'$debugger_process_meta_arguments'(G, _M, G).
|
||||
|
||||
'$ldebugger_process_meta_args'([], _, [], []).
|
||||
'$ldebugger_process_meta_args'([G|BGs], M, [N|BMs], ['$user_call'(G1,M1)|BG1s]) :-
|
||||
'$ldebugger_process_meta_args'([G|BGs], M, [N|BMs], ['$trace'(M1:G1)|BG1s]) :-
|
||||
number(N),
|
||||
N >= 0,
|
||||
'$yap_strip_module'( M:G, M1, G1 ),
|
||||
|
@ -68,7 +68,7 @@ mode and the existing spy-points, when the debugger is on.
|
||||
'__NB_setval__'('$if_skip_mode',no_skip),
|
||||
'__NB_setval__'('$spy_glist',[]),
|
||||
'__NB_setval__'('$spy_gn',1),
|
||||
'__NB_setval__'('$debug_state', state(creep,0,stop)).
|
||||
'__NB_setval__'('$debug_state', state(zip,0,stop,off)).
|
||||
|
||||
|
||||
% First part : setting and reseting spy points
|
||||
@ -220,8 +220,9 @@ debug :-
|
||||
;
|
||||
set_prolog_flag(debug, false)
|
||||
),
|
||||
'__NB_getval__'('$trace',Trace, fail),
|
||||
'__NB_setval__'('$debug_state',state(creep,0,stop,Trace) ).
|
||||
'__NB_getval__'('$trace',Trace, fail),
|
||||
( Trace == on -> Creep = crep; Creep = zip ),
|
||||
'__NB_setval__'('$debug_state',state(Creep,0,stop,Trace) ).
|
||||
|
||||
nodebug :-
|
||||
'$init_debugger',
|
||||
|
@ -1021,7 +1021,7 @@ log_event( String, Args ) :-
|
||||
DBON = true
|
||||
->
|
||||
(
|
||||
'__NB_getval__'('$debug_status',state(_, _, _,on), fail),
|
||||
'__NB_getval__'('$debug_status',state(_, _, _, _,on), fail),
|
||||
(
|
||||
var(LF)
|
||||
->
|
||||
|
Reference in New Issue
Block a user