small fixes
This commit is contained in:
parent
32266a8b98
commit
cb1c73c973
@ -18,6 +18,8 @@ extern "C" {
|
||||
#include "YapBlobs.h"
|
||||
#include "YapInterface.h"
|
||||
#include "iopreds.h"
|
||||
|
||||
#include "YapInit.h"
|
||||
|
||||
X_API char *Yap_TermToBuffer(Term t, int flags);
|
||||
|
||||
|
@ -152,10 +152,6 @@ typedef enum {
|
||||
YAP_TAG_ARRAY = 0x4000
|
||||
} YAP_tag_t;
|
||||
|
||||
#define YAP_BOOT_FROM_SAVED_CODE 1
|
||||
#define YAP_BOOT_FROM_SAVED_STACKS 2
|
||||
#define YAP_BOOT_ERROR -1
|
||||
|
||||
#define YAP_WRITE_QUOTED 1
|
||||
#define YAP_WRITE_IGNORE_OPS 2
|
||||
#define YAP_WRITE_HANDLE_VARS 4
|
||||
@ -167,130 +163,7 @@ typedef enum {
|
||||
#define YAP_WRITE_ATTVAR_PORTRAY 0x400
|
||||
#define YAP_WRITE_BLOB_PORTRAY 0x800
|
||||
|
||||
#define YAP_CONSULT_MODE 0
|
||||
#define YAP_RECONSULT_MODE 1
|
||||
#define YAP_BOOT_MODE 2
|
||||
|
||||
X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||
int Argc, char *Argv[]);
|
||||
|
||||
typedef struct yap_boot_params {
|
||||
//> boot type as suggested by the user
|
||||
YAP_file_type_t boot_file_type;
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
// const char *directory_structure;
|
||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||
const char *ROOTDIR;
|
||||
//> if NON-NULL, location of yaap, sets Yap_BINDIR
|
||||
const char *BINDIR;
|
||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||
const char *LIBDIR;
|
||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||
const char *SHAREDIR;
|
||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||
const char *INCLUDEDIR;
|
||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||
const char *DLLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||
const char *PLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_COMMONSDIR
|
||||
const char *COMMONSDIR;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at run-time
|
||||
const char *BOOTFILE;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at compile-time
|
||||
const char *BOOTSTRAP;
|
||||
//> if NON-NULL, path where we can find the saved state
|
||||
const char *INPUT_STARTUP;
|
||||
//> bootstrapping mode: YAP is not properly installed
|
||||
bool install;
|
||||
//> jupyter mode: YAP is in space
|
||||
bool jupyter;
|
||||
//> generats a saved space at this path
|
||||
const char *OUTPUT_STARTUP;
|
||||
//> if NON-0, minimal size for Heap or Code Area
|
||||
size_t HeapSize;
|
||||
//> if NON-0, maximal size for Heap or Code Area
|
||||
size_t MaxHeapSize;
|
||||
//> if NON-0, minimal size for Local+Global Stack
|
||||
size_t StackSize;
|
||||
//> if NON-0, maximal size for Local+Global Stack
|
||||
size_t MaxStackSize;
|
||||
//*> deprecated
|
||||
size_t MaxGlobalSize;
|
||||
//> if NON-0, minimal size for Trail
|
||||
size_t TrailSize;
|
||||
//> if NON-0, maximal size for Trail
|
||||
size_t MaxTrailSize;
|
||||
//> if NON-0, minimal size for AttributeVarStack
|
||||
size_t AttsSize;
|
||||
//> if NON-0, maximal size for AttributeVarStack
|
||||
size_t MaxAttsSize;
|
||||
//> if NON-NULL, name for a Prolog file to use when initializing
|
||||
const char *YapPrologInitGoal;
|
||||
//> if NON-NULL, name for a Prolog file to consult before entering top-level
|
||||
const char *PrologRCFile;
|
||||
//> if NON-NULL, a goal to run before top-level
|
||||
const char *PrologGoal;
|
||||
//> if NON-NULL, a goal to run as top-level
|
||||
const char *PrologTopLevelGoal;
|
||||
//> if NON-NULL, a path to extend file-search-path
|
||||
const char *PrologAddPath;
|
||||
//> if previous NON-NULL and TRUE, halt after consulting that file
|
||||
bool HaltAfterBoot;
|
||||
//> ignore .yaprc, .prolog.ini, etc. files.
|
||||
bool FastBoot;
|
||||
//> the next field only interest YAPTAB
|
||||
//> if NON-0, maximum size for Table Space
|
||||
size_t MaxTableSpaceSize;
|
||||
/* the next three fields only interest YAPOR, but we keep them so that
|
||||
users don't need to recompile DLL in order to use YAPOR */
|
||||
//> if NON-0, number of workers we want to have (default=1)
|
||||
unsigned long int NumberWorkers;
|
||||
//> if NON-0, manage the inner scheduler loop (default = 10)
|
||||
unsigned long int SchedulerLoop;
|
||||
//> if NON-0, say how long to keep nodes (default = 3)
|
||||
unsigned long int DelayedReleaseLoad;
|
||||
//> end of YAPOR fields
|
||||
/* whether Prolog should handle interrupts. Note that
|
||||
interrupts will always be disabled in embedded mode. */
|
||||
bool PrologCannotHandleInterrupts;
|
||||
//> flag for JIT mode
|
||||
int ExecutionMode;
|
||||
//> number of arguments that Prolog will see
|
||||
int Argc;
|
||||
//> array of arguments as seen by Prolog
|
||||
char **Argv;
|
||||
//> embedded in some other system: no signals, readline, etc
|
||||
bool Embedded;
|
||||
//> QuietMode
|
||||
int QuietMode;
|
||||
//> 0, maintain default, > 0 use fd-1, < 0 close
|
||||
int inp, out, err;
|
||||
#if __ANDROID__
|
||||
//> android asset support
|
||||
AAssetManager *assetManager;
|
||||
#endif
|
||||
/* support nf's ypp preprocessor code */
|
||||
#define YAP_MAX_YPP_DEFS 100
|
||||
char *def_var[YAP_MAX_YPP_DEFS];
|
||||
char *def_value[YAP_MAX_YPP_DEFS];
|
||||
int def_c;
|
||||
/* End preprocessor code */
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
//> If any myddas option was given
|
||||
short myddas;
|
||||
//> MYDDAS Fields
|
||||
char *myddas_user;
|
||||
char *myddas_pass;
|
||||
char *myddas_db;
|
||||
char *myddas_host;
|
||||
#endif
|
||||
/* errornumber */
|
||||
int ErrorNo;
|
||||
//> errorstring
|
||||
char *ErrorCause;
|
||||
} YAP_init_args;
|
||||
#include "YapInit.h"
|
||||
|
||||
/* this should be opaque to the user */
|
||||
typedef struct {
|
||||
|
@ -833,7 +833,7 @@ gradient_descent :-
|
||||
forall(tunable_fact(FactID,GroundTruth),
|
||||
(XZ is 0.5, X[FactID] <== XZ,set_fact_probability(FactID,XZ))),
|
||||
problog_flag(sigmoid_slope,Slope),
|
||||
%%% lbfgs_set_parameter(min_step, 2e-40, Solver),
|
||||
lbfgs_set_parameter(min_step, Solver, 0.0),
|
||||
lbfgs_run(Solver,BestF),
|
||||
format('~2nOptimization done~nWe found a minimum ~4f.~n',[BestF]),
|
||||
forall(tunable_fact(FactID,GroundTruth), set_tunable(FactID,X)),
|
||||
|
@ -811,7 +811,7 @@ static YAP_Bool p_cudd_print_with_names(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||
const char *s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3));
|
||||
char **namesp;
|
||||
char ** namesp;
|
||||
YAP_Term names = YAP_ARG4;
|
||||
FILE *f;
|
||||
YAP_Int len;
|
||||
@ -850,14 +850,14 @@ static YAP_Bool p_cudd_print_with_names(void) {
|
||||
names = YAP_TailOfTerm(names);
|
||||
namesp[i++] = f;
|
||||
}
|
||||
Cudd_DumpDot(manager, 1, &n0, namesp, NULL, f);
|
||||
Cudd_DumpDot(manager, 1, &n0, (const char * const*)namesp, NULL, f);
|
||||
if (f != stdout && f != stderr)
|
||||
fclose(f);
|
||||
while (i > 0) {
|
||||
i--;
|
||||
free((void *)namesp[i]);
|
||||
}
|
||||
free(namesp);
|
||||
free((void *)namesp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int simpleNamedBDDtoDot(DdManager *manager, const namedvars varmap, DdNode *bdd, char *filename) {
|
||||
int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) {
|
||||
DdNode *f[1];
|
||||
int ret;
|
||||
FILE *fd;
|
||||
|
@ -1293,7 +1293,8 @@ gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar,
|
||||
char *TargetPattern, int type) {
|
||||
DdNode *h, *l;
|
||||
hisnode *Found;
|
||||
const char *curnode = NULL, *dynvalue;
|
||||
const char *curnode = NULL;
|
||||
char *dynvalue;
|
||||
gradientpair lowvalue, highvalue, tvalue;
|
||||
double this_probability;
|
||||
double *gradient;
|
||||
|
@ -298,7 +298,7 @@ table is used to store nodeB for which the probability has alread been computed
|
||||
so that it is not recomputed
|
||||
*/
|
||||
{
|
||||
int index, mVarIndex, comp, pos;
|
||||
int index, mVarIndex, comp;
|
||||
variable v;
|
||||
double res;
|
||||
double p, pt, pf, BChild0, BChild1;
|
||||
@ -333,7 +333,7 @@ so that it is not recomputed
|
||||
BChild1 = pt * p;
|
||||
mVarIndex = bVar2mVar_ex[ex][index];
|
||||
v = vars_ex[ex][mVarIndex];
|
||||
pos = index - v.firstBoolVar;
|
||||
index - v.firstBoolVar;
|
||||
res = BChild0 + BChild1;
|
||||
add_node(table, nodekey, res);
|
||||
return res;
|
||||
@ -345,7 +345,6 @@ static YAP_Bool add_var(void) {
|
||||
YAP_Term arg1, arg2, arg3, arg4, out, probTerm, probTerm_temp;
|
||||
variable *v;
|
||||
int i;
|
||||
DdNode *node;
|
||||
double p, p0;
|
||||
|
||||
arg1 = YAP_ARG1;
|
||||
@ -367,7 +366,7 @@ static YAP_Bool add_var(void) {
|
||||
probTerm = arg2;
|
||||
p0 = 1;
|
||||
for (i = 0; i < v->nVal - 1; i++) {
|
||||
node = Cudd_bddIthVar(mgr_ex[ex], boolVars_ex[ex] + i);
|
||||
//node = Cudd_bddIthVar(mgr_ex[ex], boolVars_ex[ex] + i);
|
||||
p = YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm));
|
||||
bVar2mVar_ex[ex][boolVars_ex[ex] + i] = nVars_ex[ex] - 1;
|
||||
probs_ex[ex][boolVars_ex[ex] + i] = p / p0;
|
||||
|
@ -350,6 +350,12 @@ static YAP_Bool lbfgs_release(void) {
|
||||
/* return FALSE; */
|
||||
}
|
||||
|
||||
static lbfgs_parameter_t * get_params(YAP_Term t) {
|
||||
YAP_Int ar = YAP_ArityOfFunctor(YAP_FunctorOfTerm(t));
|
||||
YAP_Term arg = YAP_ArgOfTerm(ar, t);
|
||||
return (lbfgs_parameter_t *)YAP_IntOfTerm(arg);
|
||||
}
|
||||
|
||||
/** @pred lbfgs_set_parameter(+Name,+Value,+Parameters)
|
||||
Set the parameter Name to Value. Only possible while the lbfgs
|
||||
is not running.
|
||||
@ -357,7 +363,7 @@ is not running.
|
||||
static YAP_Bool lbfgs_set_parameter(void) {
|
||||
YAP_Term t1 = YAP_ARG1;
|
||||
YAP_Term t2 = YAP_ARG2;
|
||||
lbfgs_parameter_t *param = (lbfgs_parameter_t *)YAP_IntOfTerm(YAP_ARG3);
|
||||
lbfgs_parameter_t *param = get_params(YAP_ARG3);
|
||||
/* if (lbfgs_status != LBFGS_STATUS_NONE && lbfgs_status !=
|
||||
* LBFGS_STATUS_INITIALIZED){ */
|
||||
/* printf("ERROR: Lbfgs is running right now. Please wait till it is
|
||||
@ -510,6 +516,7 @@ static YAP_Bool lbfgs_set_parameter(void) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** @pred lbfgs_get_parameter(+Name,-Value)</h3>
|
||||
Get the current Value for Name
|
||||
*/
|
||||
@ -517,7 +524,7 @@ Get the current Value for Name
|
||||
static YAP_Bool lbfgs_get_parameter(void) {
|
||||
YAP_Term t1 = YAP_ARG1;
|
||||
YAP_Term t2 = YAP_ARG2;
|
||||
lbfgs_parameter_t *param = (lbfgs_parameter_t *)YAP_IntOfTerm(YAP_ARG3);
|
||||
lbfgs_parameter_t *param = get_params(YAP_ARG3);
|
||||
|
||||
if (!YAP_IsAtomTerm(t1)) {
|
||||
return FALSE;
|
||||
|
@ -74,7 +74,6 @@
|
||||
|
||||
:- use_system_module( '$_preds', ['$current_predicate'/4]).
|
||||
|
||||
|
||||
:- '$system_meta_predicates'([
|
||||
compile(:),
|
||||
consult(:),
|
||||
@ -235,7 +234,7 @@ load_files(Files0,Opts) :-
|
||||
'__NB_getval__'('$qcompile', Current, Current = never).
|
||||
'$lf_option'(silent, 8, _).
|
||||
'$lf_option'(skip_unix_header, 9, Skip) :-
|
||||
stream_property(Stream,[alias(loop_stream),tty(TTy),reposition(Rep)]),
|
||||
stream_property(loop_stream,[tty(TTy),reposition(Rep)]),
|
||||
( Rep == true
|
||||
->
|
||||
(TTy = true -> Skip = false ; Skip = true)
|
||||
@ -302,6 +301,7 @@ load_files(Files0,Opts) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user_input, M, [consult(reconsult),stream(S)|Opts], Call).
|
||||
'$load_files'(-user_input, M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user_input, M, [consult(reconsult),stream(S)|Opts], Call).
|
||||
'$load_files'(Files, M, Opts, Call) :-
|
||||
'$load_files__'(Files, M, Opts, Call).
|
||||
|
@ -76,7 +76,7 @@ dbload(F, M0, G) :-
|
||||
dbload(F, _, G) :-
|
||||
'$do_error'(type_error(atom,F),G).
|
||||
|
||||
do_dbload(F0, M0, G) :-
|
||||
do_dbload(F0, M0, _G) :-
|
||||
'$full_filename'(F0, F),
|
||||
assert(dbprocess(F, M0)),
|
||||
open(F, read, R),
|
||||
|
@ -251,11 +251,11 @@ compose_message(Throw, _Level) -->
|
||||
|
||||
location(error(syntax_error(_),info(between(_,LN,_), FileName, _ChrPos, _Err)), _ , _) -->
|
||||
!,
|
||||
[ '~a:~d:~d ' - [FileName,LN,0] ] .
|
||||
[ '~a:~d:~d: ' - [FileName,LN,0] ] .
|
||||
location(style_check(A,LN,FileName,B ), Level , LC) -->
|
||||
!,
|
||||
display_consulting( FileName, Level,style_check(A,LN,FileName,B ), LC ),
|
||||
[ '~a:~d:0 ~a ' - [FileName,LN,Level] ] .
|
||||
[ '~a:~d:0: ~a: ' - [FileName,LN,Level] ] .
|
||||
location( error(_,Info), Level, LC ) -->
|
||||
{ '$error_descriptor'(Info, Desc) },
|
||||
{
|
||||
@ -300,7 +300,7 @@ main_message( error(syntax_error(Msg),info(between(L0,LM,LF),_Stream, _Pos, Term
|
||||
[' ~a: failed_processing syntax error term ~q' - [Level,Term]],
|
||||
[nl]
|
||||
).
|
||||
main_message( error(syntax_error(_Msg), Info), Level, LC ) -->
|
||||
main_message( error(syntax_error(Msg), _Info), Level, _LC ) -->
|
||||
!,
|
||||
[' ~a: syntax error ~s' - [Level,Msg]],
|
||||
[nl].
|
||||
@ -335,9 +335,9 @@ main_error_message(evaluation_error(What, Who)) -->
|
||||
main_error_message(existence_error(Type , Who)) -->
|
||||
[nl],
|
||||
[ '~*|** ~q ~q could not be found **' - [ 10,Type, Who], nl ].
|
||||
main_error_message(permission_error(Op, Type, Id)) -->
|
||||
main_error_message(permission_error(Op, Type, Id)) -->
|
||||
[ '~*|** value ~q is not allowed in ~a ~q **' - [ 10, Op, Type,Id], nl ].
|
||||
main_error_message(instantiation_error) -->
|
||||
main_error_message(instantiation_error) -->
|
||||
[ '~*|** unbound variable **' - [10], nl ].
|
||||
main_error_message(representation_error(Type)) -->
|
||||
[ '~*|** YAP cannot represent ~w **' - [10, Type], nl ].
|
||||
|
@ -295,7 +295,7 @@ retractall(V) :-
|
||||
'$log_update_clause'(T,M,_,R),
|
||||
'$erase_lu_mf_clause'(Na,Ar,M,R),
|
||||
fail.
|
||||
'$retractall_lu_mf'(_T,_M,_Na,Ar).
|
||||
'$retractall_lu_mf'(_T,_M,_Na,_Ar).
|
||||
|
||||
'$erase_lu_mf_clause'(Na,Ar,M,R) :-
|
||||
recorded('$mf','$mf_clause'(_,Na,Ar,M,R),MR),
|
||||
|
@ -442,7 +442,7 @@ Make predicate _Pred_ invisible to `current_predicate/2`,
|
||||
`listing`, and friends.
|
||||
**/
|
||||
hide_predicate(P0) :-
|
||||
strip_module(P0, M, P),
|
||||
strip_module(P0, _M, P),
|
||||
nonvar(P),
|
||||
P = N/A,
|
||||
!,
|
||||
@ -539,7 +539,7 @@ predicate_property(Pred,Prop) :-
|
||||
functor(P,N,A),
|
||||
once(recorded('$module','$module'(_TFN,M,_S,Publics,_L),_)),
|
||||
lists:memberchk(N/A,Publics).
|
||||
'$predicate_property'(P,M,M0,imported_from(M)) :-
|
||||
'$predicate_property'(_P,M,M0,imported_from(M)) :-
|
||||
M \= M0.
|
||||
'$predicate_property'(P,Mod,_,number_of_clauses(NCl)) :-
|
||||
'$number_of_clauses'(P,Mod,NCl).
|
||||
@ -598,7 +598,7 @@ current_predicate(A,T0) :-
|
||||
'$yap_strip_module'(T0, M, T),
|
||||
( var(Mod)
|
||||
->
|
||||
'$all_current_modules'(M)
|
||||
'$all_current_modules'(Mod)
|
||||
;
|
||||
true
|
||||
),
|
||||
@ -821,4 +821,3 @@ clause_property(ClauseRef, predicate(PredicateIndicator)) :-
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
||||
|
Reference in New Issue
Block a user