smallStuff

This commit is contained in:
Vitor Santos Costa 2019-03-03 02:01:39 +00:00
parent 5ff09fbf26
commit 908cfe3b77
11 changed files with 188 additions and 167 deletions

View File

@ -616,7 +616,6 @@ yap_error_descriptor_t *Yap_popErrorContext(bool mdnew, bool pass) {
memmove(ep, e, sizeof(*e)); memmove(ep, e, sizeof(*e));
ep->top_error = epp; ep->top_error = epp;
} }
free(e);
return LOCAL_ActiveError; return LOCAL_ActiveError;
} }
/** /**

View File

@ -115,6 +115,10 @@ static inline bool CallPredicate(PredEntry *pen, choiceptr cut_pt,
inline static bool CallMetaCall(Term t, Term mod USES_REGS) { inline static bool CallMetaCall(Term t, Term mod USES_REGS) {
// we have a creep requesr waiting // we have a creep requesr waiting
if (IsVarTerm(t))
Yap_ThrowError(INSTANTIATION_ERROR, t, "meta-call");
if (IsIntTerm(t) || (IsApplTerm(t) && IsExtensionFunctor(FunctorOfTerm(t))))
Yap_ThrowError(TYPE_ERROR_CALLABLE, Yap_TermToIndicator(t, mod), "meta-call");
ARG1 = t; ARG1 = t;
ARG2 = cp_as_integer(B PASS_REGS); /* p_current_choice_point */ ARG2 = cp_as_integer(B PASS_REGS); /* p_current_choice_point */
ARG3 = t; ARG3 = t;
@ -141,6 +145,10 @@ inline static bool CallMetaCall(Term t, Term mod USES_REGS) {
Term Yap_ExecuteCallMetaCall(Term g, Term mod) { Term Yap_ExecuteCallMetaCall(Term g, Term mod) {
CACHE_REGS CACHE_REGS
Term ts[4]; Term ts[4];
if (IsVarTerm(g))
Yap_ThrowError(INSTANTIATION_ERROR, g, "meta-call");
if (IsIntTerm(g) || (IsApplTerm(g) && IsExtensionFunctor(FunctorOfTerm(g))))
Yap_ThrowError(TYPE_ERROR_CALLABLE, Yap_TermToIndicator(g, mod), "meta-call");
ts[0] = g; ts[0] = g;
ts[1] = cp_as_integer(B PASS_REGS); /* p_current_choice_point */ ts[1] = cp_as_integer(B PASS_REGS); /* p_current_choice_point */
ts[2] = g; ts[2] = g;
@ -210,7 +218,7 @@ Term Yap_TermToIndicator(Term t, Term mod) {
ti[1] = MkIntTerm(0); ti[1] = MkIntTerm(0);
} }
t = Yap_MkApplTerm(FunctorSlash, 2, ti); t = Yap_MkApplTerm(FunctorSlash, 2, ti);
if (mod != CurrentModule) { if (mod != PROLOG_MODULE && mod != USER_MODULE && mod != TermProlog) {
ti[0] = mod; ti[0] = mod;
ti[1] = t; ti[1] = t;
return Yap_MkApplTerm(FunctorModule, 2, ti); return Yap_MkApplTerm(FunctorModule, 2, ti);
@ -231,7 +239,7 @@ Term Yap_PredicateToIndicator(PredEntry *pe) {
} }
Term t = Yap_MkApplTerm(FunctorSlash, 2, ti); Term t = Yap_MkApplTerm(FunctorSlash, 2, ti);
Term mod = pe->ModuleOfPred; Term mod = pe->ModuleOfPred;
if (mod != TermUser && mod!= PROLOG_MODULE) { if (mod != PROLOG_MODULE && mod != USER_MODULE && mod != TermProlog) {
ti[0] = mod; ti[0] = mod;
ti[1] = t; ti[1] = t;
return Yap_MkApplTerm(FunctorModule, 2, ti); return Yap_MkApplTerm(FunctorModule, 2, ti);

View File

@ -1115,7 +1115,6 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
/* protect slots for portray */ /* protect slots for portray */
writeTerm(tp, priority, 1, false, &wglb, &rwt); writeTerm(tp, priority, 1, false, &wglb, &rwt);
tp = Yap_CyclesInTerm(t PASS_REGS);
if (flags & New_Line_f) { if (flags & New_Line_f) {
if (flags & Fullstop_f) { if (flags & Fullstop_f) {
wrputc('.', wglb.stream); wrputc('.', wglb.stream);

View File

@ -2,7 +2,7 @@
* @file tries.yap * @file tries.yap
* @author Ricardo Rocha * @author Ricardo Rocha
* *
* @brief * @brief YAP tries interface
* *
* *
*/ */
@ -63,6 +63,8 @@
@ingroup library @ingroup library
@{ @{
@brief Engine Independent trie library
The next routines provide a set of utilities to create and manipulate The next routines provide a set of utilities to create and manipulate
prefix trees of Prolog terms. Tries were originally proposed to prefix trees of Prolog terms. Tries were originally proposed to
implement tabling in Logic Programming, but can be used for other implement tabling in Logic Programming, but can be used for other
@ -76,130 +78,6 @@ for efficiency. They are available through the
*/ */
/** @pred trie_check_entry(+ _Trie_,+ _Term_,- _Ref_)
Succeeds if a variant of term _Term_ is in trie _Trie_. An handle
_Ref_ gives a reference to the term.
*/
/** @pred trie_close(+ _Id_)
Close trie with identifier _Id_.
*/
/** @pred trie_close_all
Close all available tries.
*/
/** @pred trie_get_entry(+ _Ref_,- _Term_)
Unify _Term_ with the entry for handle _Ref_.
*/
/** @pred trie_load(+ _Trie_,+ _FileName_)
Load trie _Trie_ from the contents of file _FileName_.
*/
/** @pred trie_max_stats(- _Memory_,- _Tries_,- _Entries_,- _Nodes_)
Give maximal statistics on tries, including the amount of memory,
_Memory_, the number of tries, _Tries_, the number of entries,
_Entries_, and the total number of nodes, _Nodes_.
*/
/** @pred trie_mode(? _Mode_)
Unify _Mode_ with trie operation mode. Allowed values are either
`std` (default) or `rev`.
*/
/** @pred trie_open(- _Id_)
Open a new trie with identifier _Id_.
*/
/** @pred trie_print(+ _Trie_)
Print trie _Trie_ on standard output.
*/
/** @pred trie_put_entry(+ _Trie_,+ _Term_,- _Ref_)
Add term _Term_ to trie _Trie_. The handle _Ref_ gives
a reference to the term.
*/
/** @pred trie_remove_entry(+ _Ref_)
Remove entry for handle _Ref_.
*/
/** @pred trie_remove_subtree(+ _Ref_)
Remove subtree rooted at handle _Ref_.
*/
/** @pred trie_save(+ _Trie_,+ _FileName_)
Dump trie _Trie_ into file _FileName_.
*/
/** @pred trie_stats(- _Memory_,- _Tries_,- _Entries_,- _Nodes_)
Give generic statistics on tries, including the amount of memory,
_Memory_, the number of tries, _Tries_, the number of entries,
_Entries_, and the total number of nodes, _Nodes_.
*/
/** @pred trie_usage(+ _Trie_,- _Entries_,- _Nodes_,- _VirtualNodes_)
Give statistics on trie _Trie_, the number of entries,
_Entries_, and the total number of nodes, _Nodes_, and the
number of _VirtualNodes_.
*/
:- load_foreign_files([tries], [], init_tries). :- load_foreign_files([tries], [], init_tries).

View File

@ -4,8 +4,17 @@
Comments: Tries module for Yap Prolog Comments: Tries module for Yap Prolog
version: $ID$ version: $ID$
****************************************/ ****************************************/
/**
@file tries.c
@brief yap-C wrapper for tries.
*/
/**
@addtogroup tries
@{
*/
/* -------------------------- */ /* -------------------------- */
/* Includes */ /* Includes */
@ -164,6 +173,15 @@ static YAP_Bool p_close_all_tries(void) {
/* put_trie_entry(+Mode,+Trie,+Entry,-Ref) */ /* put_trie_entry(+Mode,+Trie,+Entry,-Ref) */
/** @pred trie_put_entry(+Mode,+ _Trie_,+ _Term_,- _Ref_)
Add term _Term_ to trie _Trie_. The handle _Ref_ gives
a reference to the term.
*/
#define arg_mode YAP_ARG1 #define arg_mode YAP_ARG1
#define arg_trie YAP_ARG2 #define arg_trie YAP_ARG2
#define arg_entry YAP_ARG3 #define arg_entry YAP_ARG3
@ -198,6 +216,13 @@ static YAP_Bool p_put_trie_entry(void) {
/* get_trie_entry(+Mode,+Ref,-Entry) */ /* get_trie_entry(+Mode,+Ref,-Entry) */
/** @pred trie_get_entry(+ _Ref_,- _Term_)
Unify _Term_ with the entry for handle _Ref_.
*/
#define arg_mode YAP_ARG1 #define arg_mode YAP_ARG1
#define arg_ref YAP_ARG2 #define arg_ref YAP_ARG2
#define arg_entry YAP_ARG3 #define arg_entry YAP_ARG3
@ -228,7 +253,6 @@ static YAP_Bool p_get_trie_entry(void) {
#undef arg_ref #undef arg_ref
#undef arg_entry #undef arg_entry
/* remove_trie_entry(+Ref) */ /* remove_trie_entry(+Ref) */
static YAP_Bool p_remove_trie_entry(void) { static YAP_Bool p_remove_trie_entry(void) {
return p_trie_remove_entry(); return p_trie_remove_entry();
@ -263,6 +287,14 @@ static YAP_Bool p_trie_open(void) {
/* trie_close(+Trie) */ /* trie_close(+Trie) */
/** @pred trie_close(+ _Id_)
Close trie with identifier _Id_.
*/
#define arg_trie YAP_ARG1 #define arg_trie YAP_ARG1
static YAP_Bool p_trie_close(void) { static YAP_Bool p_trie_close(void) {
/* check arg */ /* check arg */
@ -277,6 +309,14 @@ static YAP_Bool p_trie_close(void) {
/* trie_close_all() */ /* trie_close_all() */
/** @pred trie_close_all
Close all available tries.
*/
static YAP_Bool p_trie_close_all(void) { static YAP_Bool p_trie_close_all(void) {
trie_close_all(); trie_close_all();
return TRUE; return TRUE;
@ -284,6 +324,15 @@ static YAP_Bool p_trie_close_all(void) {
/* trie_mode(?Mode) */ /* trie_mode(?Mode) */
/** @pred trie_mode(? _Mode_)
Unify _Mode_ with trie operation mode. Allowed values are either
`std` (default) or `rev`.
*/
#define arg_mode YAP_ARG1 #define arg_mode YAP_ARG1
static YAP_Bool p_trie_mode(void) { static YAP_Bool p_trie_mode(void) {
YAP_Term mode_term; YAP_Term mode_term;
@ -337,6 +386,15 @@ static YAP_Bool p_trie_put_entry(void) {
/* trie_check_entry(+Trie,+Entry,-Ref) */ /* trie_check_entry(+Trie,+Entry,-Ref) */
/** @pred trie_check_entry(+ _Trie_,+ _Term_,- _Ref_)
Succeeds if a variant of term _Term_ is in trie _Trie_. An handle
_Ref_ gives a reference to the term.
*/
#define arg_trie YAP_ARG1 #define arg_trie YAP_ARG1
#define arg_entry YAP_ARG2 #define arg_entry YAP_ARG2
#define arg_ref YAP_ARG3 #define arg_ref YAP_ARG3
@ -458,6 +516,14 @@ static YAP_Bool p_trie_traverse_cont(void) {
/* trie_remove_entry(+Ref) */ /* trie_remove_entry(+Ref) */
/** @pred trie_remove_entry(+ _Ref_)
Remove entry for handle _Ref_.
*/
#define arg_ref YAP_ARG1 #define arg_ref YAP_ARG1
static YAP_Bool p_trie_remove_entry(void) { static YAP_Bool p_trie_remove_entry(void) {
/* check arg */ /* check arg */
@ -472,6 +538,14 @@ static YAP_Bool p_trie_remove_entry(void) {
/* trie_remove_subtree(+Ref) */ /* trie_remove_subtree(+Ref) */
/** @pred trie_remove_subtree(+ _Ref_)
Remove subtree rooted at handle _Ref_.
*/
#define arg_ref YAP_ARG1 #define arg_ref YAP_ARG1
static YAP_Bool p_trie_remove_subtree(void) { static YAP_Bool p_trie_remove_subtree(void) {
/* check arg */ /* check arg */
@ -564,8 +638,13 @@ static YAP_Bool p_trie_count_intersect(void) {
#undef arg_trie2 #undef arg_trie2
#undef arg_entries #undef arg_entries
/** @pred trie_save(+ _Trie_,+ _FileName_)
/* trie_save(+Trie,+FileName) */
Dump trie _Trie_ into file _FileName_.
*/
#define arg_trie YAP_ARG1 #define arg_trie YAP_ARG1
#define arg_file YAP_ARG2 #define arg_file YAP_ARG2
static YAP_Bool p_trie_save(void) { static YAP_Bool p_trie_save(void) {
@ -594,6 +673,13 @@ static YAP_Bool p_trie_save(void) {
/* trie_load(-Trie,+FileName) */ /* trie_load(-Trie,+FileName) */
/** @pred trie_load(- _Trie_,+ _FileName_)
Load trie _Trie_ from the contents of file _FileName_.
*/
#define arg_trie YAP_ARG1 #define arg_trie YAP_ARG1
#define arg_file YAP_ARG2 #define arg_file YAP_ARG2
static YAP_Bool p_trie_load(void) { static YAP_Bool p_trie_load(void) {
@ -622,6 +708,15 @@ static YAP_Bool p_trie_load(void) {
#undef arg_trie #undef arg_trie
#undef arg_file #undef arg_file
/** @pred trie_stats(- _Memory_,- _Tries_,- _Entries_,- _Nodes_)
Give generic statistics on tries, including the amount of memory,
_Memory_, the number of tries, _Tries_, the number of entries,
_Entries_, and the total number of nodes, _Nodes_.
*/
/* trie_stats(-Memory,-Tries,-Entries,-Nodes) */ /* trie_stats(-Memory,-Tries,-Entries,-Nodes) */
#define arg_memory YAP_ARG1 #define arg_memory YAP_ARG1
@ -650,6 +745,15 @@ static YAP_Bool p_trie_stats(void) {
/* trie_max_stats(-Memory,-Tries,-Entries,-Nodes) */ /* trie_max_stats(-Memory,-Tries,-Entries,-Nodes) */
/** @pred trie_max_stats(- _Memory_,- _Tries_,- _Entries_,- _Nodes_)
Give maximal statistics on tries, including the amount of memory,
_Memory_, the number of tries, _Tries_, the number of entries,
_Entries_, and the total number of nodes, _Nodes_.
*/
#define arg_memory YAP_ARG1 #define arg_memory YAP_ARG1
#define arg_tries YAP_ARG2 #define arg_tries YAP_ARG2
#define arg_entries YAP_ARG3 #define arg_entries YAP_ARG3
@ -675,6 +779,15 @@ static YAP_Bool p_trie_max_stats(void) {
#undef arg_nodes #undef arg_nodes
/** @pred trie_usage(+ _Trie_,- _Entries_,- _Nodes_,- _VirtualNodes_)
Give statistics on trie _Trie_, the number of entries,
_Entries_, and the total number of nodes, _Nodes_, and the
number of _VirtualNodes_.
*/
/* trie_usage(+Trie,-Entries,-Nodes,-VirtualNodes) */ /* trie_usage(+Trie,-Entries,-Nodes,-VirtualNodes) */
#define arg_trie YAP_ARG1 #define arg_trie YAP_ARG1
#define arg_entries YAP_ARG2 #define arg_entries YAP_ARG2
@ -704,6 +817,15 @@ static YAP_Bool p_trie_usage(void) {
/* trie_print(+Trie) */ /* trie_print(+Trie) */
/** @pred trie_print(+ _Trie_)
Print trie _Trie_ on standard output.
*/
#define arg_trie YAP_ARG1 #define arg_trie YAP_ARG1
static YAP_Bool p_trie_print(void) { static YAP_Bool p_trie_print(void) {
/* check arg */ /* check arg */
@ -979,3 +1101,5 @@ int WINAPI win_tries(HANDLE hinst, DWORD reason, LPVOID reserved)
return 1; return 1;
} }
#endif #endif
/// @}

View File

@ -1144,7 +1144,8 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
LOCAL_Error_TYPE = YAP_NO_ERROR; LOCAL_Error_TYPE = YAP_NO_ERROR;
return YAP_PARSING_FINISHED; return YAP_PARSING_FINISHED;
} }
Term t = syntax_error(fe->toklast, inp_stream, fe->cmod, re->cpos, fe->reading_clause, fe->msg);
syntax_error(fe->toklast, inp_stream, fe->cmod, re->cpos, fe->reading_clause, fe->msg);
if (ParserErrorStyle == TermException) if (ParserErrorStyle == TermException)
{ {
if (LOCAL_RestartEnv && !LOCAL_delay) if (LOCAL_RestartEnv && !LOCAL_delay)
@ -1162,7 +1163,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
LOCAL_Error_TYPE = YAP_NO_ERROR; LOCAL_Error_TYPE = YAP_NO_ERROR;
if (ParserErrorStyle == TermDec10) if (ParserErrorStyle == TermDec10)
{ {
return YAP_SCANNING; return YAP_START_PARSING;
} }
return YAP_PARSING_FINISHED; return YAP_PARSING_FINISHED;
} }
@ -1184,6 +1185,8 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
return YAP_PARSING_FINISHED; return YAP_PARSING_FINISHED;
} }
static int count;
/** /**
* @brief generic routine to read terms from a stream * @brief generic routine to read terms from a stream
* *
@ -1201,25 +1204,26 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
*/ */
Term Yap_read_term(int sno, Term opts, bool clause) Term Yap_read_term(int sno, Term opts, bool clause)
{ {
FEnv fe;
REnv re;
#if EMACS #if EMACS
int emacs_cares = FALSE; int emacs_cares = FALSE;
#endif #endif
yap_error_descriptor_t *new = malloc(sizeof *new);
bool err = Yap_pushErrorContext(true, new);
int lvl = push_text_stack(); int lvl = push_text_stack();
yap_error_descriptor_t *new = malloc(sizeof *new);
FEnv *fe = Malloc(sizeof *fe);
REnv *re = Malloc(sizeof *re);
bool err = Yap_pushErrorContext(true, new);
parser_state_t state = YAP_START_PARSING; parser_state_t state = YAP_START_PARSING;
yhandle_t yopts = Yap_InitHandle(opts);
while (true) while (true)
{ {
switch (state) switch (state)
{ {
case YAP_START_PARSING: case YAP_START_PARSING:
state = initParser(opts, &fe, &re, sno, clause); opts = Yap_GetFromHandle(yopts);
state = initParser(opts, fe, re, sno, clause);
if (state == YAP_PARSING_FINISHED) if (state == YAP_PARSING_FINISHED)
{ {
Yap_PopHandle(yopts);
pop_text_stack(lvl); pop_text_stack(lvl);
Yap_popErrorContext(err, true); Yap_popErrorContext(err, true);
return 0; return 0;
@ -1227,32 +1231,32 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
break; break;
case YAP_SCANNING: case YAP_SCANNING:
state = scan(&re, &fe, sno); state = scan(re, fe, sno);
break; break;
case YAP_SCANNING_ERROR: case YAP_SCANNING_ERROR:
state = scanError(&re, &fe, sno); state = scanError(re, fe, sno);
break; break;
case YAP_PARSING: case YAP_PARSING:
state = parse(&re, &fe, sno); state = parse(re, fe, sno);
break; break;
case YAP_PARSING_ERROR: case YAP_PARSING_ERROR:
state = parseError(&re, &fe, sno); state = parseError(re, fe, sno);
break; break;
case YAP_PARSING_FINISHED: { case YAP_PARSING_FINISHED: {
CACHE_REGS CACHE_REGS
bool done; bool done;
if (fe.reading_clause) if (fe->reading_clause)
done = complete_clause_processing(&fe, LOCAL_tokptr); done = complete_clause_processing(fe, LOCAL_tokptr);
else else
done = complete_processing(&fe, LOCAL_tokptr); done = complete_processing(fe, LOCAL_tokptr);
if (!done) if (!done)
{ {
state = YAP_PARSING_ERROR; state = YAP_PARSING_ERROR;
fe.t = 0; fe->t = 0;
break; break;
} }
#if EMACS #if EMACS
@ -1260,10 +1264,12 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
#endif /* EMACS */ #endif /* EMACS */
pop_text_stack(lvl); pop_text_stack(lvl);
Yap_popErrorContext(err, true); Yap_popErrorContext(err, true);
return fe.t; Yap_PopHandle(yopts);
return fe->t;
} }
} }
} }
Yap_PopHandle(yopts);
Yap_popErrorContext(err, true); Yap_popErrorContext(err, true);
pop_text_stack(lvl); pop_text_stack(lvl);
return 0; return 0;

View File

@ -4,6 +4,7 @@ set (PROGRAMS
problog_lfi.yap problog_lfi.yap
dtproblog.yap dtproblog.yap
aproblog.yap aproblog.yap
problog_lbfgs.yap
problog_learning.yap problog_learning.yap
problog_learning_lbdd.yap problog_learning_lbdd.yap
) )

View File

@ -517,13 +517,14 @@ every 5th iteration only.
% directory where simplecudd executable is located % directory where simplecudd executable is located
% automatically set during loading -- assumes it is in /usr/local/bin or same place where YAP has % automatically set during loading -- assumes it is in /usr/local/bin or same place where YAP has
% been installed.) % been installed.)
:- getcwd(PD0), :- getcwd(PD0),
atom_concat(PD0, '../../bin', PD), atom_concat(PD0, '../../bin', PD),
set_problog_path(PD). set_problog_path(PD).
:- PD = '/usr/local/bin', :- PD = '/usr/local/bin',
set_problog_path(PD). set_problog_path(PD).
%:- stop_low_level_trace.
%%%%%%%%%%%% %%%%%%%%%%%%
@ -626,6 +627,7 @@ every 5th iteration only.
problog_dir(PD):- problog_path(PD). problog_dir(PD):- problog_path(PD).
%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -218,7 +218,7 @@
:- use_module(gflags). :- use_module(gflags).
:- use_module(os). :- use_module(os).
:- use_module(logger). :- use_module(logger).
:- use_module(library(system), [file_exists/1, delete_file/1]). :- use_module(library(system), [file_exists/1, delete_file/1,file_property/2]).
/** @defgroup ProbLogMiscellaneous ProbLog Miscellaneous Predicates /** @defgroup ProbLogMiscellaneous ProbLog Miscellaneous Predicates

View File

@ -265,7 +265,7 @@
:- initialization( :- initialization(
( predicate_property(trie_disable_hash, imported_from(_M)) -> ( predicate_property(trie_disable_hash, imported_from(_M)) ->
trie_disable_hash trie_disable_hash
; print_message(warning,'The predicate tries:trie_disable_hash/0 does not exist. Please update trie library.') ; true % stop_low_level_trace, print_message(warning,'The predicate trie_disable_hash/0 does not exist. Please update trie library.')
) )
). ).
@ -276,7 +276,7 @@
:- initialization(( :- initialization((
problog_define_flag(use_db_trie, problog_flag_validate_boolean, 'use the builtin trie 2 trie transformation', false), problog_define_flag(use_db_trie, problog_flag_validate_boolean, 'use the builtin trie 2 trie transformation', false),
problog_define_flag(db_trie_opt_lvl, problog_flag_validate_integer, 'optimization level for the trie 2 trie transformation', 0), problog_define_flag(db_trie_opt_lvl, problog_flag_validate_integer, 'optimization level for the trie 2 trie transformation', 0),
problog_define_flag(compare_opt_lvl, problog_flag_validate_boolean, 'comparison mode for optimization level', false), problog_define_flag(compare_opt_lvl, problog_flag_validate_boolean, 'comparison mode for optimizatione level', false),
problog_define_flag(db_min_prefix, problog_flag_validate_integer, 'minimum size of prefix for dbtrie to optimize', 2), problog_define_flag(db_min_prefix, problog_flag_validate_integer, 'minimum size of prefix for dbtrie to optimize', 2),
problog_define_flag(use_naive_trie, problog_flag_validate_boolean, 'use the naive algorithm to generate bdd scripts', false), problog_define_flag(use_naive_trie, problog_flag_validate_boolean, 'use the naive algorithm to generate bdd scripts', false),
problog_define_flag(use_old_trie, problog_flag_validate_boolean, 'use the old trie 2 trie transformation no nested', true), problog_define_flag(use_old_trie, problog_flag_validate_boolean, 'use the old trie 2 trie transformation no nested', true),

View File

@ -581,6 +581,7 @@ bdd_input_file(Filename) :-
concat_path_with_filename(Dir,'input.txt',Filename). concat_path_with_filename(Dir,'input.txt',Filename).
init_one_query(QueryID,Query,_Type) :- init_one_query(QueryID,Query,_Type) :-
writeln(init_one_query(QueryID,Query,_Type)),
% format_learning(3,' ~q example ~q: ~q~n',[Type,QueryID,Query]), % format_learning(3,' ~q example ~q: ~q~n',[Type,QueryID,Query]),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -592,13 +593,15 @@ init_one_query(QueryID,Query,_Type) :-
format_learning(3,' Reuse existing BDD ~q~n~n',[QueryID]) format_learning(3,' Reuse existing BDD ~q~n~n',[QueryID])
; ;
b_setval(problog_required_keep_ground_ids,false), b_setval(problog_required_keep_ground_ids,false),
(QueryID mod 100 =:= 0 -> writeln(QueryID) ; true), (QueryID mod 100 =:= 0 -> writeln(QueryID) ; true),
problog_flag(init_method,(Query,N,Bdd,graph2bdd(X,Y,N,Bdd))),
problog_flag(init_method,(Query,N,Bdd,G)),
Query =.. [_,X,Y] Query =.. [_,X,Y]
-> ->
Bdd = bdd(Dir, Tree, MapList), Bdd = bdd(Dir, Tree, MapList),
( (
graph2bdd(X,Y,N,Bdd) G
-> ->
rb_new(H0), rb_new(H0),
maplist_to_hash(MapList, H0, Hash), maplist_to_hash(MapList, H0, Hash),
@ -609,7 +612,8 @@ init_one_query(QueryID,Query,_Type) :-
), ),
write('.'), write('.'),
recordz(QueryID,bdd(Dir, Grad, MapList),_) recordz(QueryID,bdd(Dir, Grad, MapList),_)
; ).
/* ;
problog_flag(init_method,(Query,NOf,Bdd,problog_kbest_as_bdd(Call,NOf,Bdd))) -> problog_flag(init_method,(Query,NOf,Bdd,problog_kbest_as_bdd(Call,NOf,Bdd))) ->
b_setval(problog_required_keep_ground_ids,false), b_setval(problog_required_keep_ground_ids,false),
rb_new(H0), rb_new(H0),
@ -624,20 +628,20 @@ init_one_query(QueryID,Query,_Type) :-
tree_to_grad(Tree, Hash, [], Grad), tree_to_grad(Tree, Hash, [], Grad),
recordz(QueryID,bdd(Dir, Grad, MapList),_) recordz(QueryID,bdd(Dir, Grad, MapList),_)
; ;
problog_flag(init_method,(Query,NOf,Bdd,Call)) ->
problog_flag(init_method,(Query,NOf,Bdd,_Call)) ,
Query = gene(X,Y),
b_setval(problog_required_keep_ground_ids,false), b_setval(problog_required_keep_ground_ids,false),
rb_new(H0), rb_new(H0),
Bdd = bdd(Dir, Tree, MapList), Bdd = bdd(Dir, Tree, MapList),
% trace, user:graph2bdd(X,Y,1,Bdd),
problog:Call,
maplist_to_hash(MapList, H0, Hash), maplist_to_hash(MapList, H0, Hash),
Tree \= [], Tree \= [],
%put_code(0'.), %put_code(0'.),
tree_to_grad(Tree, Hash, [], Grad), tree_to_grad(Tree, Hash, [], Grad),
recordz(QueryID,bdd(Dir, Grad, MapList),_) recordz(QueryID,bdd(Dir, Grad, MapList),_).
).
*/
%======================================================================== %========================================================================