Fixing minor portability issues
This commit is contained in:
parent
8cf9568c8b
commit
c37a62b2d8
@ -312,14 +312,16 @@
|
||||
% general yap modules
|
||||
:- use_module(library(system)).
|
||||
|
||||
:- problog_define_flag(optimization, problog_flag_validate_atom, 'optimization algorithm [local/global]', global, dtproblog).
|
||||
:- problog_define_flag(forest_type, problog_flag_validate_atom, 'type of BDD forest [dependent/independent]', dependent, dtproblog).
|
||||
:- initialization((
|
||||
problog_define_flag(optimization, problog_flag_validate_atom, 'optimization algorithm [local/global]', global, dtproblog),
|
||||
problog_define_flag(forest_type, problog_flag_validate_atom, 'type of BDD forest [dependent/independent]', dependent, dtproblog)
|
||||
)).
|
||||
|
||||
init_dtproblog :-
|
||||
problog_control(off,find_decisions),
|
||||
problog_control(off,internal_strategy).
|
||||
problog_control(off,find_decisions),
|
||||
problog_control(off,internal_strategy).
|
||||
|
||||
:- init_dtproblog.
|
||||
:- initialization(init_dtproblog).
|
||||
|
||||
:- op( 550, yfx, :: ).
|
||||
|
||||
@ -359,7 +361,7 @@ get_ground_strategy(_,never).
|
||||
% Internal strategy representation
|
||||
% for NON-GROUND strategies
|
||||
% e.g. 1 :: market(guy) for ? :: market(P)
|
||||
:- dynamic non_ground_strategy/2.
|
||||
:- dynamic(non_ground_strategy/2).
|
||||
|
||||
% Get Strategy
|
||||
strategy(_,_,_) :-
|
||||
|
@ -230,7 +230,7 @@
|
||||
problog_kbest_save/6,
|
||||
problog_max/3,
|
||||
problog_exact/3,
|
||||
problog_exact_save/5,
|
||||
problog_exact_save/5,
|
||||
problog_montecarlo/3,
|
||||
problog_dnf_sampling/3,
|
||||
problog_answers/2,
|
||||
@ -296,7 +296,6 @@
|
||||
above/2]).
|
||||
|
||||
:- style_check(all).
|
||||
|
||||
:- yap_flag(unknown,error).
|
||||
|
||||
:- set_prolog_flag(to_chars_mode,quintus).
|
||||
@ -333,56 +332,56 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% global over all inference methods, internal use only
|
||||
:- dynamic problog_predicate/2.
|
||||
:- dynamic problog_continuous_predicate/3.
|
||||
:- dynamic(problog_predicate/2).
|
||||
:- dynamic(problog_continuous_predicate/3).
|
||||
% global over all inference methods, exported
|
||||
:- dynamic tunable_fact/2.
|
||||
:- dynamic non_ground_fact/1.
|
||||
:- dynamic continuous_fact/1.
|
||||
:- dynamic(tunable_fact/2).
|
||||
:- dynamic(non_ground_fact/1).
|
||||
:- dynamic(continuous_fact/1).
|
||||
%:- dynamic problog_dir/1.
|
||||
% global, manipulated via problog_control/2
|
||||
:- dynamic up/0.
|
||||
:- dynamic limit/0.
|
||||
:- dynamic mc/0.
|
||||
:- dynamic remember/0.
|
||||
:- dynamic exact/0. % Theo tabling
|
||||
:- dynamic find_decisions/0.
|
||||
:- dynamic internal_strategy/0.
|
||||
:- dynamic(up/0).
|
||||
:- dynamic(limit/0).
|
||||
:- dynamic(mc/0).
|
||||
:- dynamic(remember/0).
|
||||
:- dynamic(exact/0). % Theo tabling
|
||||
:- dynamic(find_decisions/0).
|
||||
:- dynamic(internal_strategy/0).
|
||||
% local to problog_delta
|
||||
:- dynamic low/2.
|
||||
:- dynamic up/2.
|
||||
:- dynamic stopDiff/1.
|
||||
:- dynamic(low/2).
|
||||
:- dynamic(up/2).
|
||||
:- dynamic(stopDiff/1).
|
||||
% local to problog_kbest
|
||||
:- dynamic current_kbest/3.
|
||||
:- dynamic(current_kbest/3).
|
||||
% local to problog_max
|
||||
:- dynamic max_probability/1.
|
||||
:- dynamic max_proof/1.
|
||||
:- dynamic(max_probability/1).
|
||||
:- dynamic(max_proof/1).
|
||||
% local to problog_montecarlo
|
||||
:- dynamic mc_prob/1.
|
||||
:- dynamic(mc_prob/1).
|
||||
% local to problog_answers
|
||||
:- dynamic answer/1.
|
||||
:- dynamic(answer/1).
|
||||
% to keep track of the groundings for non-ground facts
|
||||
:- dynamic grounding_is_known/2.
|
||||
:- dynamic(grounding_is_known/2).
|
||||
|
||||
% for decisions
|
||||
:- dynamic decision_fact/2.
|
||||
:- dynamic(decision_fact/2).
|
||||
|
||||
% for fact where the proabability is a variable
|
||||
:- dynamic dynamic_probability_fact/1.
|
||||
:- dynamic dynamic_probability_fact_extract/2.
|
||||
:- dynamic(dynamic_probability_fact/1).
|
||||
:- dynamic(dynamic_probability_fact_extract/2).
|
||||
|
||||
% for storing continuous parts of proofs (Hybrid ProbLog)
|
||||
:- dynamic hybrid_proof/3, hybrid_proof/4.
|
||||
:- dynamic hybrid_proof_disjoint/4.
|
||||
:- dynamic(hybrid_proof/3, hybrid_proof/4).
|
||||
:- dynamic(hybrid_proof_disjoint/4).
|
||||
|
||||
% ProbLog files declare prob. facts as P::G
|
||||
% and this module provides the predicate X::Y to iterate over them
|
||||
:- multifile '::'/2.
|
||||
:- multifile('::'/2).
|
||||
|
||||
|
||||
% directory where problogbdd executable is located
|
||||
% automatically set during loading -- assumes it is in same place as this file (problog.yap)
|
||||
:- getcwd(PD), set_problog_path(PD).
|
||||
:- initialization((getcwd(PD), set_problog_path(PD))).
|
||||
|
||||
|
||||
|
||||
@ -395,22 +394,28 @@
|
||||
% - factor used to decrease threshold for next level, NewMin=Factor*OldMin (saved also in log-space)
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(first_threshold, problog_flag_validate_indomain_0_1_open, 'starting threshold iterative deepening', 0.1, inference).
|
||||
:- problog_define_flag(last_threshold, problog_flag_validate_indomain_0_1_open, 'stopping threshold iterative deepening', 1e-30, inference, flags:last_threshold_handler).
|
||||
:- problog_define_flag(id_stepsize, problog_flag_validate_indomain_0_1_close, 'threshold shrinking factor iterative deepening', 0.5, inference, flags:id_stepsize_handler).
|
||||
:- initialization((
|
||||
problog_define_flag(first_threshold, problog_flag_validate_indomain_0_1_open, 'starting threshold iterative deepening', 0.1, inference),
|
||||
problog_define_flag(last_threshold, problog_flag_validate_indomain_0_1_open, 'stopping threshold iterative deepening', 1e-30, inference, flags:last_threshold_handler),
|
||||
problog_define_flag(id_stepsize, problog_flag_validate_indomain_0_1_close, 'threshold shrinking factor iterative deepening', 0.5, inference, flags:id_stepsize_handler)
|
||||
)).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% prune check stops derivations if they use a superset of facts already known to form a proof
|
||||
% (very) costly test, can be switched on/off here (This is obsolete as it is not included in implementation)
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(prunecheck, problog_flag_validate_switch, 'stop derivations including all facts of known proof', off, inference).
|
||||
:- initialization(
|
||||
problog_define_flag(prunecheck, problog_flag_validate_switch, 'stop derivations including all facts of known proof', off, inference)
|
||||
).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% max number of calls to probabilistic facts per derivation (to ensure termination)
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(maxsteps, problog_flag_validate_posint, 'max. number of prob. steps per derivation', 1000, inference).
|
||||
:- initialization(
|
||||
problog_define_flag(maxsteps, problog_flag_validate_posint, 'max. number of prob. steps per derivation', 1000, inference)
|
||||
).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% BDD timeout in seconds, used as option in BDD tool
|
||||
@ -422,12 +427,13 @@
|
||||
% located in the directory given by problog_flag dir
|
||||
%%%%%%%%%%%%
|
||||
|
||||
%:- problog_define_flag(bdd_path, problog_flag_validate_directory, 'problogbdd directory', '.',bdd).
|
||||
:- problog_define_flag(bdd_time, problog_flag_validate_posint, 'BDD computation timeout in seconds', 60, bdd).
|
||||
:- problog_define_flag(save_bdd, problog_flag_validate_boolean, 'save BDD files for (last) lower bound', false, bdd).
|
||||
:- problog_define_flag(dynamic_reorder, problog_flag_validate_boolean, 'use dynamic re-ordering for BDD', true, bdd).
|
||||
:- problog_define_flag(bdd_static_order, problog_flag_validate_boolean, 'use a static order', false, bdd).
|
||||
|
||||
:- initialization((
|
||||
% problog_define_flag(bdd_path, problog_flag_validate_directory, 'problogbdd directory', '.',bdd),
|
||||
problog_define_flag(bdd_time, problog_flag_validate_posint, 'BDD computation timeout in seconds', 60, bdd),
|
||||
problog_define_flag(save_bdd, problog_flag_validate_boolean, 'save BDD files for (last) lower bound', false, bdd),
|
||||
problog_define_flag(dynamic_reorder, problog_flag_validate_boolean, 'use dynamic re-ordering for BDD', true, bdd),
|
||||
problog_define_flag(bdd_static_order, problog_flag_validate_boolean, 'use a static order', false, bdd)
|
||||
)).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% determine whether ProbLog outputs information (number of proofs, intermediate results, ...)
|
||||
@ -435,27 +441,34 @@
|
||||
% default is false now, as dtproblog will flood the user with verbosity
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(verbose, problog_flag_validate_boolean, 'output intermediate information', false,output).
|
||||
:- initialization(
|
||||
problog_define_flag(verbose, problog_flag_validate_boolean, 'output intermediate information', false,output)
|
||||
).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% determine whether ProbLog outputs proofs when adding to trie
|
||||
% default is false
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(show_proofs, problog_flag_validate_boolean, 'output proofs', false,output).
|
||||
:- initialization(
|
||||
problog_define_flag(show_proofs, problog_flag_validate_boolean, 'output proofs', false,output)
|
||||
).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% Trie dump parameter for saving a file with the trie structure in the directory by problog_flag dir
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(triedump, problog_flag_validate_boolean, 'generate file: trie_file containing the trie structure', false,output).
|
||||
:- initialization(
|
||||
problog_define_flag(triedump, problog_flag_validate_boolean, 'generate file: trie_file containing the trie structure', false,output)
|
||||
).
|
||||
|
||||
%%%%%%%%%%%%
|
||||
% Default inference method
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- problog_define_flag(inference, problog_flag_validate_dummy, 'default inference method', exact, inference).
|
||||
|
||||
:- initialization(
|
||||
problog_define_flag(inference, problog_flag_validate_dummy, 'default inference method', exact, inference)
|
||||
).
|
||||
|
||||
problog_dir(PD):- problog_path(PD).
|
||||
|
||||
@ -522,7 +535,7 @@ reset_control :-
|
||||
% problog_control(off,exact),
|
||||
problog_control(off,remember).
|
||||
|
||||
:- reset_control.
|
||||
:- initialization(reset_control).
|
||||
|
||||
grow_atom_table(N):-
|
||||
generate_atoms(N, 0),
|
||||
@ -898,7 +911,8 @@ prove_problog_fact_negated(ClauseID,GroundID,Prob) :-
|
||||
).
|
||||
|
||||
% generate next global identifier
|
||||
:- nb_setval(probclause_counter,0).
|
||||
:- initialization(nb_setval(probclause_counter,0)).
|
||||
|
||||
probclause_id(ID) :-
|
||||
nb_getval(probclause_counter,ID), !,
|
||||
C1 is ID+1,
|
||||
@ -1406,19 +1420,21 @@ put_module(Goal,Module,Module:Goal).
|
||||
% if remember is on, input files for problogbdd will be saved
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- problog_var_define(sld_time, times, time, messages('SLD resolution', ':', ' ms')).
|
||||
:- problog_var_define(bdd_script_time, times, time, messages('Generating BDD script', ':', ' ms')).
|
||||
:- problog_var_define(bdd_generation_time, times, time, messages('Constructing BDD', ':', ' ms')).
|
||||
:- problog_var_define(trie_statistics, memory, untyped, messages('Trie usage', ':', '')).
|
||||
:- problog_var_define(probability, result, number, messages('Probabilty', ' = ', '')).
|
||||
:- problog_var_define(bdd_script_time(Method), times, time, messages('Generating BDD script '(Method), ':', ' ms')).
|
||||
:- problog_var_define(bdd_generation_time(Method), times, time, messages('Constructing BDD '(Method), ':', ' ms')).
|
||||
:- problog_var_define(probability(Method), result, number, messages('Probabilty '(Method), ' = ', '')).
|
||||
:- problog_var_define(trie_statistics(Method), memory, untyped, messages('Trie usage '(Method), ':', '')).
|
||||
:- problog_var_define(dbtrie_statistics(Method), memory, untyped, messages('Depth Breadth Trie usage '(Method), ':', '')).
|
||||
:- problog_var_define(db_trie_opts_performed(Method), memory, untyped, messages('Optimisations performed '(Method), ':', '')).
|
||||
:- problog_var_define(variable_elimination_time, times, time, messages('Variable Elimination', ':', ' ms')).
|
||||
:- problog_var_define(variable_elimination_stats, memory, untyped, messages('Variable Elimination', ':', '')).
|
||||
:- initialization((
|
||||
problog_var_define(sld_time, times, time, messages('SLD resolution', ':', ' ms')),
|
||||
problog_var_define(bdd_script_time, times, time, messages('Generating BDD script', ':', ' ms')),
|
||||
problog_var_define(bdd_generation_time, times, time, messages('Constructing BDD', ':', ' ms')),
|
||||
problog_var_define(trie_statistics, memory, untyped, messages('Trie usage', ':', '')),
|
||||
problog_var_define(probability, result, number, messages('Probabilty', ' = ', '')),
|
||||
problog_var_define(bdd_script_time(Method), times, time, messages('Generating BDD script '(Method), ':', ' ms')),
|
||||
problog_var_define(bdd_generation_time(Method), times, time, messages('Constructing BDD '(Method), ':', ' ms')),
|
||||
problog_var_define(probability(Method), result, number, messages('Probabilty '(Method), ' = ', '')),
|
||||
problog_var_define(trie_statistics(Method), memory, untyped, messages('Trie usage '(Method), ':', '')),
|
||||
problog_var_define(dbtrie_statistics(Method), memory, untyped, messages('Depth Breadth Trie usage '(Method), ':', '')),
|
||||
problog_var_define(db_trie_opts_performed(Method), memory, untyped, messages('Optimisations performed '(Method), ':', '')),
|
||||
problog_var_define(variable_elimination_time, times, time, messages('Variable Elimination', ':', ' ms')),
|
||||
problog_var_define(variable_elimination_stats, memory, untyped, messages('Variable Elimination', ':', ''))
|
||||
)).
|
||||
|
||||
problog_statistics(Stat, Result):-
|
||||
problog_var_defined(Stat),
|
||||
|
@ -204,14 +204,15 @@
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:-module(flags, [problog_define_flag/4,
|
||||
problog_define_flag/5,
|
||||
problog_define_flag/6,
|
||||
problog_defined_flag/5,
|
||||
problog_defined_flag_group/1,
|
||||
set_problog_flag/2,
|
||||
reset_problog_flags/0,
|
||||
problog_flag/2]).
|
||||
:-module(flags, [
|
||||
problog_define_flag/4,
|
||||
problog_define_flag/5,
|
||||
problog_define_flag/6,
|
||||
problog_defined_flag/5,
|
||||
problog_defined_flag_group/1,
|
||||
set_problog_flag/2,
|
||||
reset_problog_flags/0,
|
||||
problog_flag/2]).
|
||||
|
||||
|
||||
:- use_module(gflags).
|
||||
@ -241,37 +242,39 @@ problog_flag(Flag, Value):-
|
||||
|
||||
reset_problog_flags:- flags_reset.
|
||||
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_dummy, flag_validate_dummy).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_atom, flag_validate_atom).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_atomic, flag_validate_atomic).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_number, flag_validate_number).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_integer, flag_validate_integer).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_directory, flag_validate_directory).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_file, flag_validate_file).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_in_list(L), flag_validate_in_list(L)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval(I, Type), flag_validate_in_interval(I, Type)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_closed([L, U]), flag_validate_in_interval([L, U], number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_open([L, U]), flag_validate_in_interval((L, U), number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_left_open([L, U]), flag_validate_in_interval((L, [U]), number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_right_open([L, U]), flag_validate_in_interval(([L], U), number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_closed([L, U]), flag_validate_in_interval([L, U], integer)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_open([L, U]), flag_validate_in_interval((L, U), integer)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_left_open([L, U]), flag_validate_in_interval((L, [U]), integer)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_right_open([L, U]), flag_validate_in_interval(([L], U), integer)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_closed([L, U]), flag_validate_in_interval([L, U], float)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_open([L, U]), flag_validate_in_interval((L, U), float)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_left_open([L, U]), flag_validate_in_interval((L, [U]), float)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_right_open([L, U]), flag_validate_in_interval(([L], U), float)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_posnumber, flag_validate_in_interval((0, [+inf]), number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_posint, flag_validate_in_interval((0, +inf), integer)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_nonegint, flag_validate_in_interval(([0], +inf), integer)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_boolean, flag_validate_in_list([true, false])).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_switch, flag_validate_in_list([on, off])).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_method, flag_validate_in_list([max, delta, exact, montecarlo, low, kbest])).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_aggregate, flag_validate_in_list([sum, prod, soft_prod])).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_indomain_0_1_open, flag_validate_in_interval((0, 1), number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_indomain_0_1_close, flag_validate_in_interval([0, 1], number)).
|
||||
:- flag_add_validation_syntactic_sugar(problog_flag_validate_0to5, flag_validate_in_interval([0, 5], integer)).
|
||||
:- initialization((
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_dummy, flag_validate_dummy),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_atom, flag_validate_atom),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_atomic, flag_validate_atomic),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_number, flag_validate_number),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_integer, flag_validate_integer),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_directory, flag_validate_directory),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_file, flag_validate_file),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_in_list(L), flag_validate_in_list(L)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval(I, Type), flag_validate_in_interval(I, Type)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_closed([L, U]), flag_validate_in_interval([L, U], number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_open([L, U]), flag_validate_in_interval((L, U), number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_left_open([L, U]), flag_validate_in_interval((L, [U]), number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_in_interval_right_open([L, U]), flag_validate_in_interval(([L], U), number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_closed([L, U]), flag_validate_in_interval([L, U], integer)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_open([L, U]), flag_validate_in_interval((L, U), integer)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_left_open([L, U]), flag_validate_in_interval((L, [U]), integer)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_integer_in_interval_right_open([L, U]), flag_validate_in_interval(([L], U), integer)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_closed([L, U]), flag_validate_in_interval([L, U], float)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_open([L, U]), flag_validate_in_interval((L, U), float)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_left_open([L, U]), flag_validate_in_interval((L, [U]), float)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_float_in_interval_right_open([L, U]), flag_validate_in_interval(([L], U), float)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_posnumber, flag_validate_in_interval((0, [+inf]), number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_posint, flag_validate_in_interval((0, +inf), integer)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_nonegint, flag_validate_in_interval(([0], +inf), integer)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_boolean, flag_validate_in_list([true, false])),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_switch, flag_validate_in_list([on, off])),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_method, flag_validate_in_list([max, delta, exact, montecarlo, low, kbest])),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_aggregate, flag_validate_in_list([sum, prod, soft_prod])),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_indomain_0_1_open, flag_validate_in_interval((0, 1), number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_indomain_0_1_close, flag_validate_in_interval([0, 1], number)),
|
||||
flag_add_validation_syntactic_sugar(problog_flag_validate_0to5, flag_validate_in_interval([0, 5], integer))
|
||||
)).
|
||||
|
||||
last_threshold_handler(message, '').
|
||||
last_threshold_handler(validating, _Value).
|
||||
@ -294,7 +297,7 @@ bdd_file_handler(validate, Value):-
|
||||
catch(file_exists(Path), _, fail), file_property(Path, type(regular)), !.
|
||||
bdd_file_handler(validate, Value):-
|
||||
convert_filename_to_working_path(Value, Path),
|
||||
catch((not(file_exists(Path)), tell(Path)), _, fail),
|
||||
catch((\+ file_exists(Path), tell(Path)), _, fail),
|
||||
told,
|
||||
delete_file(Path).
|
||||
bdd_file_handler(validated, _Value).
|
||||
@ -311,7 +314,7 @@ working_file_handler(validate, Value):-
|
||||
catch(file_exists(Path), _, fail), file_property(Path, type(regular)), !.
|
||||
working_file_handler(validate, Value):-
|
||||
convert_filename_to_working_path(Value, Path),
|
||||
catch((not(file_exists(Path)), tell(Path)), _, fail),
|
||||
catch((\+ file_exists(Path), tell(Path)), _, fail),
|
||||
told,
|
||||
delete_file(Path).
|
||||
working_file_handler(validated, _Value).
|
||||
|
@ -259,10 +259,10 @@ flag_define(Flag, Group, Type, DefaultValue, Handler, Message):-
|
||||
throw(duplicate_flag_definition(flag_define(Flag, Group, Type, DefaultValue, Handler, Message))).
|
||||
|
||||
flag_define(Flag, Group, Type, DefaultValue, Handler, Message):-
|
||||
(catch(call(Type), _, fail)->
|
||||
(catch(Type, _, fail)->
|
||||
fail
|
||||
;
|
||||
\+ (flag_validation_syntactic_sugar(Type, SyntacticSugar), catch(call(SyntacticSugar), _, fail)),
|
||||
\+ (flag_validation_syntactic_sugar(Type, SyntacticSugar), catch(SyntacticSugar, _, fail)),
|
||||
throw(unknown_flag_type(flag_define(Flag, Group, Type, DefaultValue, Handler, Message)))
|
||||
).
|
||||
|
||||
@ -371,13 +371,13 @@ flag_validate(_Flag, Value, Type, M:Handler):-
|
||||
Type =.. LType,
|
||||
append(LType, [Value], LGoal),
|
||||
G =.. LGoal,
|
||||
catch((call(M:GoalValidating), call(G)), _, fail), !.
|
||||
catch((M:GoalValidating, G), _, fail), !.
|
||||
flag_validate(_Flag, Value, Type, _M:Handler):-
|
||||
Handler == true,
|
||||
Type =.. LType,
|
||||
append(LType, [Value], LGoal),
|
||||
G =.. LGoal,
|
||||
catch(call(G), _, fail), !.
|
||||
catch(G, _, fail), !.
|
||||
|
||||
flag_validate(_Flag, Value, SyntacticSugar, M:Handler):-
|
||||
Handler \= true,
|
||||
@ -386,14 +386,14 @@ flag_validate(_Flag, Value, SyntacticSugar, M:Handler):-
|
||||
Type =.. LType,
|
||||
append(LType, [Value], LGoal),
|
||||
G =.. LGoal,
|
||||
catch((call(M:GoalValidating), call(G)), _, fail), !.
|
||||
catch((M:GoalValidating, G), _, fail), !.
|
||||
flag_validate(_Flag, Value, SyntacticSugar, _M:Handler):-
|
||||
Handler == true,
|
||||
flag_validation_syntactic_sugar(SyntacticSugar, Type),
|
||||
Type =.. LType,
|
||||
append(LType, [Value], LGoal),
|
||||
G =.. LGoal,
|
||||
catch(call(G), _, fail), !.
|
||||
catch(G, _, fail), !.
|
||||
flag_validate(Flag, Value, Type, Handler):-
|
||||
(var(Value) ->
|
||||
Value = 'free variable'
|
||||
|
@ -205,9 +205,10 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
:- module(learning,[do_learning/1,
|
||||
do_learning/2,
|
||||
set_learning_flag/2,
|
||||
:- module(learning,[
|
||||
do_learning/1,
|
||||
do_learning/2,
|
||||
set_learning_flag/2,
|
||||
learning_flag/2,
|
||||
learning_flags/0,
|
||||
problog_help/0,
|
||||
@ -215,7 +216,7 @@
|
||||
problog_flag/2,
|
||||
problog_flags/0,
|
||||
auto_alpha/0
|
||||
]).
|
||||
]).
|
||||
|
||||
% switch on all the checks to reduce bug searching time
|
||||
:- style_check(all).
|
||||
@ -235,17 +236,17 @@
|
||||
:- use_module('problog/utils_learning').
|
||||
|
||||
% used to indicate the state of the system
|
||||
:- dynamic values_correct/0.
|
||||
:- dynamic learning_initialized/0.
|
||||
:- dynamic current_iteration/1.
|
||||
:- dynamic example_count/1.
|
||||
:- dynamic query_probability_intern/2.
|
||||
:- dynamic query_gradient_intern/4.
|
||||
:- dynamic last_mse/1.
|
||||
:- dynamic(values_correct/0).
|
||||
:- dynamic(learning_initialized/0).
|
||||
:- dynamic(current_iteration/1).
|
||||
:- dynamic(example_count/1).
|
||||
:- dynamic(query_probability_intern/2).
|
||||
:- dynamic(query_gradient_intern/4).
|
||||
:- dynamic(last_mse/1).
|
||||
|
||||
% used to identify queries which have identical proofs
|
||||
:- dynamic query_is_similar/2.
|
||||
:- dynamic query_md5/3.
|
||||
:- dynamic(query_is_similar/2).
|
||||
:- dynamic(query_md5/3).
|
||||
|
||||
:- multifile(user:example/4).
|
||||
user:example(A,B,C,=) :-
|
||||
|
Reference in New Issue
Block a user