diff --git a/packages/ProbLog/Makefile.in b/packages/ProbLog/Makefile.in index b92930408..93ec8d65d 100644 --- a/packages/ProbLog/Makefile.in +++ b/packages/ProbLog/Makefile.in @@ -26,7 +26,7 @@ YAP_EXTRAS=@YAP_EXTRAS@ PROGRAMS= \ $(srcdir)/problog.yap \ - $(srcdir)/problog_learning.yap + $(srcdir)/learning.yap PROBLOG_PROGRAMS= \ $(srcdir)/problog/flags.yap \ @@ -34,19 +34,20 @@ PROBLOG_PROGRAMS= \ $(srcdir)/problog/tptree.yap LEARNING_PROGRAMS = \ - $(srcdir)/problog_learning/flags_learning.yap \ - $(srcdir)/problog_learning/logger.yap + $(srcdir)/learning/flags_learning.yap \ + $(srcdir)/learning/logger.yap EXAMPLES = \ - $(srcdir)/problog_examples/graph.pl \ - $(srcdir)/problog_examples/learn_graph.pl + $(srcdir)/examples/graph.pl \ + $(srcdir)/examples/learn_graph.pl install: $(PROGRAMS) $(LEARNING_PROGRAMS) $(EXAMPLE_PROGRAMS) mkdir -p $(DESTDIR)$(SHAREDIR)/Yap mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/problog mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/problog_examples mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/problog_learning - for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done + $(INSTALL_DATA) $(srcdir)/problog.yap $(DESTDIR)$(SHAREDIR)/Yap; done + $(INSTALL_DATA) $(srcdir)/learning.yap $(DESTDIR)$(SHAREDIR)/Yap/problog_learning.yap; done for p in $(PROBLOG_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/problog; done for p in $(LEARNING_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/problog_learning; done for p in $(EXAMPLES); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/problog_examples; done diff --git a/packages/ProbLog/README b/packages/ProbLog/README index 65bd4f5b2..0b1a06a03 100644 --- a/packages/ProbLog/README +++ b/packages/ProbLog/README @@ -4,15 +4,4 @@ To clean the directory call make clean The make file will recursively call the make file of SimpleCudd and Cudd. -And it will finally copy the binary executable ProblogBDD to the main directory. - -Please, consult - - http://dtai.cs.kuleuven.be/problog - -and the examples directory - -problog_examples - -for more information - +And it will finally copy the binary executable ProblogBDD to the main directory. \ No newline at end of file diff --git a/packages/ProbLog/problog_examples/graph.pl b/packages/ProbLog/examples/graph.pl similarity index 100% rename from packages/ProbLog/problog_examples/graph.pl rename to packages/ProbLog/examples/graph.pl diff --git a/packages/ProbLog/problog_examples/learn_graph.pl b/packages/ProbLog/examples/learn_graph.pl similarity index 100% rename from packages/ProbLog/problog_examples/learn_graph.pl rename to packages/ProbLog/examples/learn_graph.pl diff --git a/packages/ProbLog/problog_learning.yap b/packages/ProbLog/learning.yap similarity index 62% rename from packages/ProbLog/problog_learning.yap rename to packages/ProbLog/learning.yap index b8260482a..0ae8c806c 100644 --- a/packages/ProbLog/problog_learning.yap +++ b/packages/ProbLog/learning.yap @@ -8,11 +8,12 @@ % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog % -% ProbLog was developed at Katholieke Universiteit Leuven -% -% Copyright 2009 -% Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann -% +% Copyright 2009 Katholieke Universiteit Leuven +% +% Authors: Luc De Raedt, Bernd Gutmann, Angelika Kimmig, +% Vitor Santos Costa +% +% % Main authors of this file: % Bernd Gutmann % @@ -208,13 +209,11 @@ :- module(learning,[do_learning/1, do_learning/2, set_learning_flag/2, - learning_flag/2, - learning_flags/0, + save_model/1, problog_help/0, set_problog_flag/2, problog_flag/2, - problog_flags/0, - auto_alpha/0 + problog_flags/0 ]). % switch on all the checks to reduce bug searching time @@ -233,9 +232,8 @@ shell/2]). % load our own modules -:- use_module('problog_learning/logger'). -:- use_module('problog_learning/flags_learning'). -:- use_module(problog). +:- use_module(library('problog_learning/logger')). +:- use_module(library(problog)). % used to indicate the state of the system :- dynamic values_correct/0. @@ -248,23 +246,157 @@ % used to identify queries which have identical proofs :- dynamic query_is_similar/2. -:- dynamic query_md5/3. +:- dynamic query_md5/2. + +% used by set_learning_flag +:- dynamic init_method/5. +:- dynamic rebuild_bdds/1. +:- dynamic rebuild_bdds_it/1. +:- dynamic reuse_initialized_bdds/1. +:- dynamic learning_rate/1. +:- dynamic probability_initializer/3. +:- dynamic check_duplicate_bdds/1. +:- dynamic output_directory/1. +:- dynamic query_directory/1. +:- dynamic log_frequency/1. +:- dynamic alpha/1. +:- dynamic sigmoid_slope/1. +:- dynamic line_search/1. +:- dynamic line_search_tolerance/1. +:- dynamic line_search_tau/1. +:- dynamic line_search_never_stop/1. +:- dynamic line_search_interval/2. -%======================================================================== -%= -%= +%========================================================================== +%= You can set some flags and parameters %= -%======================================================================== +%= init_method/5 specifies which ProbLog inference mechanism is used +%= to answer queries +%= +%= +%= if rebuild_bdds(true) is set, the bdds are rebuild after +%= each N iterations for rebuild_bdds_it(N) +%= +%= if reuse_initialized_bdds(true) is set, the bdds which are on the +%= harddrive from the previous run of LeProbLog are reused. +%= do not use this, when you changed the init method in the meantime +%= +%========================================================================== +set_learning_flag(init_method,(Query,Probability,BDDFile,ProbFile,Call)) :- + retractall(init_method(_,_,_,_,_)), + assert(init_method(Query,Probability,BDDFile,ProbFile,Call)). -my_format(Level,String,Arguments) :- - learning_flag(verbosity_level,V_Level), +set_learning_flag(rebuild_bdds,Flag) :- + (Flag=true;Flag=false), + !, + retractall(rebuild_bdds(_)), + assert(rebuild_bdds(Flag)). + +set_learning_flag(rebuild_bdds_it,Flag) :- + integer(Flag), + retractall(rebuild_bdds_it(_)), + assert(rebuild_bdds_it(Flag)). + + +set_learning_flag(reuse_initialized_bdds,Flag) :- + (Flag=true;Flag=false), + !, + retractall(reuse_initialized_bdds(_)), + assert(reuse_initialized_bdds(Flag)). + +set_learning_flag(learning_rate,V) :- + (V=examples -> true;(number(V),V>=0)), + !, + retractall(learning_rate(_)), + assert(learning_rate(V)). + +set_learning_flag(probability_initializer,(FactID,Probability,Query)) :- + var(FactID), + var(Probability), + callable(Query), + retractall(probability_initializer(_,_,_)), + assert(probability_initializer(FactID,Probability,Query)). + +set_learning_flag(check_duplicate_bdds,Flag) :- + (Flag=true;Flag=false), + !, + retractall(check_duplicate_bdds(_)), + assert(check_duplicate_bdds(Flag)). + +set_learning_flag(output_directory,Directory) :- ( - V_Level >= Level + file_exists(Directory) -> - (format(String,Arguments),flush_output(user)); - true - ). + file_property(Directory,type(directory)); + make_directory(Directory) + ), + + working_directory(PWD,PWD), + atomic_concat([PWD,'/',Directory,'/'],Path), + atomic_concat([Directory,'/log.dat'],Logfile), + + retractall(output_directory(_)), + assert(output_directory(Path)), + logger_set_filename(Logfile), + set_problog_flag(dir,Directory). + +set_learning_flag(query_directory,Directory) :- + ( + file_exists(Directory) + -> + file_property(Directory,type(directory)); + make_directory(Directory) + ), + + working_directory(PWD,PWD), + atomic_concat([PWD,'/',Directory,'/'],Path), + retractall(query_directory(_)), + assert(query_directory(Path)). + +set_learning_flag(log_frequency,Frequency) :- + integer(Frequency), + Frequency>=0, + retractall(log_frequency(_)), + assert(log_frequency(Frequency)). + +set_learning_flag(alpha,Alpha) :- + number(Alpha), + retractall(alpha(_)), + assert(alpha(Alpha)). +set_learning_flag(sigmoid_slope,Slope) :- + number(Slope), + Slope>0, + retractall(sigmoid_slope(_)), + assert(sigmoid_slope(Slope)). + + +set_learning_flag(line_search,Flag) :- + (Flag=true;Flag=false), + !, + retractall(line_search(_)), + assert(line_search(Flag)). +set_learning_flag(line_search_tolerance,Number) :- + number(Number), + Number>0, + retractall(line_search_tolerance(_)), + assert(line_search_tolerance(Number)). +set_learning_flag(line_search_interval,(L,R)) :- + number(L), + number(R), + L0, + retractall(line_search_tau(_)), + assert(line_search_tau(Number)). +set_learning_flag(line_search_never_stop,Flag) :- + (Flag=true;Flag=false), + !, + retractall(line_search_nerver_stop(_)), + assert(line_search_never_stop(Flag)). %======================================================================== @@ -272,23 +404,37 @@ my_format(Level,String,Arguments) :- %= if F is a variable, a filename based on the current iteration is used %= %======================================================================== - -save_model:- - current_iteration(Iteration), - learning_flag(output_directory,Directory), - atomic_concat([Directory,'factprobs_',Iteration,'.pl'],F), +save_model(F) :- + ( + var(F) + -> + ( + current_iteration(Iteration), + output_directory(Directory), + atomic_concat([Directory,'factprobs_',Iteration,'.pl'],F) + );true + ), export_facts(F). - %======================================================================== -%= store the current succes probabilities for training and test examples -%= +%= store the probabilities for all training and test examples +%= if F is a variable, a filename based on the current iteration is used +%= %======================================================================== +save_predictions(F) :- + update_values, -save_predictions:- current_iteration(Iteration), - learning_flag(output_directory,Directory), - atomic_concat([Directory,'predictions_',Iteration,'.pl'],F), + + ( + var(F) + -> + ( + current_iteration(Iteration), + output_directory(Directory), + atomic_concat([Directory,'predictions_',Iteration,'.pl'],F) + );true + ), open(F,'append',Handle), format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",[]), @@ -296,28 +442,6 @@ save_predictions:- format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",[]), !, - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % start save prediction test examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( % go over all test examples - current_predicate(user:test_example/3), - user:test_example(Query_ID,Query,TrueQueryProb), - query_probability(Query_ID,LearnedQueryProb), - - format(Handle,'ex(~q,test,~q,~q,~10f,~10f).\n', - [Iteration,Query_ID,Query,TrueQueryProb,LearnedQueryProb]), - - fail; % go to next test example - true - ), - !, - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % stop save prediction test examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % start save prediction training examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ( % go over all training examples current_predicate(user:example/3), user:example(Query_ID,Query,TrueQueryProb), @@ -329,11 +453,18 @@ save_predictions:- fail; % go to next training example true ), - !, - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % stop save prediction training examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ( % go over all test examples + current_predicate(user:test_example/3), + user:test_example(Query_ID,Query,TrueQueryProb), + query_probability(Query_ID,LearnedQueryProb), + format(Handle,'ex(~q,test,~q,~q,~10f,~10f).\n', + [Iteration,Query_ID,Query,TrueQueryProb,LearnedQueryProb]), + + fail; % go to next test example + true + ), format(Handle,'~3n',[]), close(Handle). @@ -346,87 +477,67 @@ save_predictions:- %======================================================================== check_examples :- - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Check example IDs - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ( - (current_predicate(user:example/3),user:example(ID,_,_), \+ atomic(ID)) + ( + (current_predicate(user:example/3),user:example(ID,_,_), \+ atomic(ID)) ; + (current_predicate(user:test_example/3),user:test_example(ID,_,_), \+ atomic(ID)) + ) -> - ( - format(user_error,'The example id of training example ~q ',[ID]), - format(user_error,'is not atomic (e.g foo42, 23, bar, ...).~n',[]), - throw(error(examples)) - ); true + ( + format(user_error,'The example id of example ~q is not atomic (e.g foo42, 23, bar, ...).~n',[ID]), + throw(error(examples)) + ); true ), ( - (current_predicate(user:test_example/3),user:test_example(ID,_,_), \+ atomic(ID)) + ( + (current_predicate(user:example/3),user:example(ID,_,P), (\+ number(P); P>1 ; P<0)); + (current_predicate(user:test_example/3),user:test_example(ID,_,P), (\+ number(P) ; P>1 ; P<0)) + ) -> - ( - format(user_error,'The example id of test example ~q ',[ID]), - format(user_error,'is not atomic (e.g foo42, 23, bar, ...).~n',[]), - throw(error(examples)) - ); true + ( + format(user_error,'The example ~q does not have a valid probaility value (~q).~n',[ID,P]), + throw(error(examples)) + ); true ), + + + ( + ( + ( + current_predicate(user:example/3), + user:example(ID,QueryA,_), + user:example(ID,QueryB,_), + QueryA \= QueryB + ) ; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Check example probabilities - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( - (current_predicate(user:example/3),user:example(ID,_,P), (\+ number(P); P>1 ; P<0)) + ( + current_predicate(user:test_example/3), + user:test_example(ID,QueryA,_), + user:test_example(ID,QueryB,_), + QueryA \= QueryB + ); + + ( + current_predicate(user:example/3), + current_predicate(user:test_example/3), + user:example(ID,QueryA,_), + user:test_example(ID,QueryB,_), + QueryA \= QueryB + ) + ) -> - ( - format(user_error,'The training example ~q does not have a valid probaility value (~q).~n',[ID,P]), - throw(error(examples)) - ); true - ), - - ( - (current_predicate(user:test_example/3),user:test_example(ID,_,P), (\+ number(P); P>1 ; P<0)) - -> - ( - format(user_error,'The test example ~q does not have a valid probaility value (~q).~n',[ID,P]), - throw(error(examples)) - ); true - ), - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Check that no example ID is repeated, - % and if it is repeated make sure the query is the same - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( - ( - ( - current_predicate(user:example/3), - user:example(ID,QueryA,_), - user:example(ID,QueryB,_), - QueryA \= QueryB - ) ; - - ( - current_predicate(user:test_example/3), - user:test_example(ID,QueryA,_), - user:test_example(ID,QueryB,_), - QueryA \= QueryB - ); - - ( - current_predicate(user:example/3), - current_predicate(user:test_example/3), - user:example(ID,QueryA,_), - user:test_example(ID,QueryB,_), - QueryA \= QueryB - ) - ) - -> - ( - format(user_error,'The example id ~q is used several times.~n',[ID]), - throw(error(examples)) - ); true + ( + format(user_error,'The example id ~q is used several times.~n',[ID]), + throw(error(examples)) + ); true ). + + + + %======================================================================== %= initialize everything and perform Iterations times gradient descent %= can be called several times @@ -435,99 +546,121 @@ check_examples :- %======================================================================== do_learning(Iterations) :- - do_learning(Iterations,-1). + integer(Iterations), + + ( + current_predicate(user:example/3) + -> + true; + format(user_error,'~n~nWarning: No training examples specified !!!~n~n',[]) + ), + + do_learning_intern(Iterations,-1). do_learning(Iterations,Epsilon) :- - current_predicate(user:example/3), - !, integer(Iterations), - number(Epsilon), + float(Epsilon), + Iterations>0, + Epsilon>0.0, + + ( + current_predicate(user:example/3) + -> + true; + format(user_error,'~n~nWarning: No training examples specified !!!~n~n',[]) + ), + do_learning_intern(Iterations,Epsilon). -do_learning(_,_) :- - format(user_error,'~n~nWarning: No training examples specified !!!~n~n',[]). + + + + + -do_learning_intern(0,_) :- - !. do_learning_intern(Iterations,Epsilon) :- - Iterations>0, - - init_learning, - current_iteration(CurrentIteration), - !, - retractall(current_iteration(_)), - !, - NextIteration is CurrentIteration+1, - assert(current_iteration(NextIteration)), - EndIteration is CurrentIteration+Iterations-1, - - my_format(1,'~nIteration ~d of ~d~n',[CurrentIteration,EndIteration]), - logger_set_variable(iteration,CurrentIteration), - - logger_start_timer(duration), - - mse_testset, - once(ground_truth_difference), - gradient_descent, - - learning_flag(log_frequency,Log_Frequency), - ( - ( Log_Frequency>0, 0 =:= CurrentIteration mod Log_Frequency) + Iterations=0 -> - ( - once(save_predictions), - once(save_model) - ); - true - ), + true; + ( + Iterations>0, - update_values, - - ( - last_mse(Last_MSE) - -> - ( - retractall(last_mse(_)), - logger_get_variable(mse_trainingset,Current_MSE), - assert(last_mse(Current_MSE)), - !, - MSE_Diff is abs(Last_MSE-Current_MSE) - ); ( - logger_get_variable(mse_trainingset,Current_MSE), - assert(last_mse(Current_MSE)), - MSE_Diff is Epsilon+1 - ) - ), + % nothing will happen, if we're already initialized + init_learning, + current_iteration(OldIteration), + !, + retractall(current_iteration(_)), + !, + CurrentIteration is OldIteration+1, + assert(current_iteration(CurrentIteration)), + EndIteration is OldIteration+Iterations, + + format('~n Iteration ~d of ~d~n',[CurrentIteration,EndIteration]), + logger_set_variable(iteration,CurrentIteration), - ( - (learning_flag(rebuild_bdds,BDDFreq),BDDFreq>0,0 =:= CurrentIteration mod BDDFreq) - -> - ( - retractall(values_correct), - once(delete_all_queries), - once(init_queries) - ); true - ), + logger_start_timer(duration), + gradient_descent, + + ( + (rebuild_bdds(true),rebuild_bdds_it(BDDFreq),0 =:= CurrentIteration mod BDDFreq) + -> + ( + once(delete_all_queries), + once(init_queries) + ); true + ), - !, - logger_stop_timer(duration), - + mse_trainingset, + mse_testset, + + ( + last_mse(Last_MSE) + -> + ( + retractall(last_mse(_)), + logger_get_variable(mse_trainingset,Current_MSE), + assert(last_mse(Current_MSE)), + !, + MSE_Diff is abs(Last_MSE-Current_MSE) + ); ( + logger_get_variable(mse_trainingset,Current_MSE), + assert(last_mse(Current_MSE)), + MSE_Diff is Epsilon+1 + ) + ), - logger_write_data, + !, + logger_stop_timer(duration), + once(ground_truth_difference), + + logger_write_data, + log_frequency(Log_Frequency), + + ( + ( Log_Frequency=0; 0 =:= CurrentIteration mod Log_Frequency) + -> + ( + save_predictions(_X), + save_model(_Y) + ); + true + ), + RemainingIterations is Iterations-1, - RemainingIterations is Iterations-1, - - ( - MSE_Diff>Epsilon - -> - do_learning_intern(RemainingIterations,Epsilon); - true + ( + MSE_Diff>Epsilon + -> + do_learning_intern(RemainingIterations,Epsilon); + true + ) + ) ). + %======================================================================== @@ -535,109 +668,104 @@ do_learning_intern(Iterations,Epsilon) :- %= %= %======================================================================== + init_learning :- - learning_initialized, - !. -init_learning :- - check_examples, - - logger_write_header, - - my_format(1,'Initializing everything~n',[]), - empty_output_directory, - - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % Delete the BDDs from the previous run if they should - % not be reused - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ( - ( - learning_flag(reuse_initialized_bdds,true), - learning_flag(rebuild_bdds,0) - ) - -> - true; - delete_all_queries - ), + learning_initialized + -> + true; + ( + + check_examples, - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % start count test examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - bb_put(test_examples,0), - ( % go over all test examples - current_predicate(user:test_example/3), - user:test_example(_,_,_), - bb_get(test_examples, OldCounter), - NewCounter is OldCounter+1, - bb_put(test_examples,NewCounter), + format('Delete previous logs (if existing) from output directory~2n',[]), + empty_output_directory, - fail; % go to next text example - true - ), - bb_delete(test_examples,TestExampleCount), - my_format(3,'~q test examples~n',[TestExampleCount]), - !, - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % stop count test examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % start count training examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - bb_put(training_examples,0), - ( % go over all training examples - current_predicate(user:example/3), - user:example(_,_,_), - bb_get(training_examples, OldCounter), - NewCounter is OldCounter+1, - bb_put(training_examples,NewCounter), - - fail; %go to next training example - true - ), - bb_delete(training_examples,TrainingExampleCount), - assert(example_count(TrainingExampleCount)), - my_format(3,'~q training examples~n',[TrainingExampleCount]), - !, - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % stop count training examples - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + format('Initializing everything~n',[]), - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % set learning rate and alpha - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( - learning_flag(learning_rate,examples) - -> - set_learning_flag(learning_rate,TrainingExampleCount); - true - ), + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Delete the BDDs from the previous run if they should + % not be reused + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( - learning_flag(alpha,auto) - -> - auto_alpha; - true - ), - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % build BDD script for every example - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - once(initialize_fact_probabilities), - once(init_queries), + ( + (reuse_initialized_bdds(false);rebuild_bdds(true)) + -> + delete_all_queries; + true + ), - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % done - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - assert(current_iteration(0)), - assert(learning_initialized), - my_format(1,'~n',[]). + logger_write_header, + logger_start_timer(duration), + logger_set_variable(iteration,0), + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % start count examples + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + bb_put(training_examples,0), + ( % go over all training examples + current_predicate(user:example/3), + user:example(_,_,_), + bb_get(training_examples, OldCounter), + NewCounter is OldCounter+1, + bb_put(training_examples,NewCounter), + fail; + true + ), + + bb_put(test_examples,0), + ( % go over all test examples + current_predicate(user:test_example/3), + user:test_example(_,_,_), + bb_get(test_examples, OldCounter), + NewCounter is OldCounter+1, + bb_put(test_examples,NewCounter), + fail; + true + ), + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % stop count examples + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !, + + bb_delete(training_examples,TrainingExampleCount), + bb_delete(test_examples,TestExampleCount), + + assert(example_count(TrainingExampleCount)), + + ( + learning_rate(examples) + -> + set_learning_flag(learning_rate,TrainingExampleCount); + true + ), + learning_rate(Learning_Rate), + format('~q training examples found.~n~q test examples found.~nlearning rate=~f~n~n', + [TrainingExampleCount,TestExampleCount,Learning_Rate]), + format('Generate BDDs for all queries in the training and test set~n',[]), + initialize_fact_probabilities, + init_queries, + + format('All Queries have been generated~n',[]), + mse_trainingset, + mse_testset, + + !, + logger_stop_timer(duration), + + ground_truth_difference, + + logger_write_data, + assert(current_iteration(0)), + assert(learning_initialized), + save_model(_),save_predictions(_) + + ) + ). %======================================================================== %= @@ -648,20 +776,14 @@ init_learning :- delete_all_queries :- - remove_queries, + query_directory(Directory), + atomic_concat(['rm -f ',Directory,'query_*'],Command), + (shell(Command) -> true; true), retractall(query_is_similar(_,_)), - retractall(query_md5(_,_,_)). - -remove_queries :- - learning_flag(query_directory,Directory), - user:example(ID,_,_), - atomic_concat([Directory,'query_',ID],File), - delete_file(File), - fail. -remove_queries. + retractall(query_md5(_,_)). empty_output_directory :- - learning_flag(output_directory,Directory), + output_directory(Directory), atomic_concat(['rm -f ',Directory,'log.dat ', Directory,'factprobs_*.pl ', Directory,'predictions_*.pl'],Command), @@ -675,88 +797,77 @@ empty_output_directory :- init_queries :- - my_format(2,'Build BDDs for examples~n',[]), - ( % go over all test examples - current_predicate(user:test_example/3), - user:test_example(ID,Query,Prob), - my_format(3,' test example ~q: ~q~n',[ID,Query]), - flush_output(user), - init_one_query(ID,Query,test), - fail; % go to next test example - true - ), ( % go over all training examples current_predicate(user:example/3), user:example(ID,Query,Prob), - statistics(runtime,[_,T]), - my_format(3,' training example ~q: ~q after ~q msec~n',[ID,Query,T]), -% my_format(3,' training example ~q: ~q~n',[ID,Query]), + format('~n~n training example ~q: ~q~n',[ID,Query]), flush_output(user), - init_one_query(ID,Query,training), + init_one_query(ID,Query), fail; %go to next training example + true + ), + + ( % go over all test examples + current_predicate(user:test_example/3), + user:test_example(ID,Query,Prob), + format('~n~n test example ~q: ~q~n',[ID,Query]), + flush_output(user), + init_one_query(ID,Query), + fail; % go to next test example + true ). - - -init_one_query(QueryID,Query,Type) :- - learning_flag(output_directory,Output_Directory), - learning_flag(query_directory,Query_Directory), +init_one_query(QueryID,Query) :- + output_directory(Output_Directory), + query_directory(Query_Directory), atomic_concat([Query_Directory,'query_',QueryID],Filename), atomic_concat([Output_Directory,'input.txt'],Filename2), atomic_concat([Output_Directory,'tmp_md5'],Filename3), + ( + file_exists(Filename) + -> + format('Reuse existing BDD ~q~n~n',[Filename]); + ( + init_method(Query,_Prob,Filename,Filename2,InitCall), + once(call(InitCall)), + delete_file(Filename2) + ) + ), - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % if BDD file does not exist, call ProbLog - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( - file_exists(Filename) - -> - my_format(3,' Reuse existing BDD ~q~n~n',[Filename]); - ( - learning_flag(init_method,(Query,_Prob,Filename,Filename2,InitCall)), - once(call(InitCall)), - delete_file(Filename2) - ) - ), - + ( + check_duplicate_bdds(true) + -> + ( + % calculate the md5sum of the bdd script file + atomic_concat(['cat ',Filename,' | md5sum | sed "s/ .*$/\')./" | sed "s/^/md5(\'/"> ',Filename3],MD5Command), - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % check wether this BDD is similar to a previous one of the same type - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ( - learning_flag(check_duplicate_bdds,true) - -> - ( - % calculate the md5sum of the bdd script file - atomic_concat(['cat ',Filename,' | md5sum | sed "s/ .*$/\')./" | sed "s/^/md5(\'/"> ',Filename3],MD5Command), + (shell(MD5Command,0) -> true; throw(error("Something wrong with calculating the MD5 value"))), - (shell(MD5Command,0) -> true; throw(error("Something wrong with calculating the MD5 value"))), + open(Filename3, read, Handle), + read(Handle,md5(Query_MD5)), + close(Handle), - open(Filename3, read, Handle), - read(Handle,md5(Query_MD5)), - close(Handle), + delete_file(Filename3), + + % Does another query exists which already has this MD5? + ( + query_md5(OtherQueryID,Query_MD5) + -> + % yippie! we can save a lot of work + ( + assert(query_is_similar(QueryID,OtherQueryID)), + format('~q is similar to ~q~2n', [QueryID,OtherQueryID]) + ); assert(query_md5(QueryID,Query_MD5)) + ) + ); - delete_file(Filename3), - - % Does another query exists which already has this MD5? - ( - query_md5(OtherQueryID,Query_MD5,Type) - -> - % yippie! we can save a lot of work - ( - assert(query_is_similar(QueryID,OtherQueryID)), - my_format(3, '~q is similar to ~q~2n', [QueryID,OtherQueryID]) - ); assert(query_md5(QueryID,Query_MD5,Type)) - ) - ); - - true - ). + true + ). %======================================================================== @@ -767,19 +878,24 @@ init_one_query(QueryID,Query,Type) :- initialize_fact_probabilities :- ( % go over all tunable facts - tunable_fact(FactID,_), - learning_flag(probability_initializer,(FactID,Probability,Query)), - once(call(Query)), - set_fact_probability(FactID,Probability), - - fail; % go to next tunable fact - true + tunable_fact(FactID,_), + + probability_initializer(FactID,Probability,Query), + once(call(Query)), + set_fact_probability(FactID,Probability), + + + fail; % go to next tunable fact + + true ). random_probability(_FactID,Probability) :- % use probs around 0.5 to not confuse k-best search random(Random), Probability is 0.5+(Random-0.5)/100. + + @@ -790,30 +906,28 @@ random_probability(_FactID,Probability) :- %======================================================================== update_values :- + update_values(all). + + +update_values(_) :- values_correct, !. -update_values :- + +update_values(What_To_Update) :- \+ values_correct, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % delete old values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% once(retractall(query_probability_intern(_,_))), - once(retractall(query_gradient_intern(_,_,_))), + once(retractall(query_gradient_intern(_,_,_))), + + output_directory(Directory), + atomic_concat(Directory,'input.txt',Input_Filename), %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % start write current probabilities to file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - learning_flag(output_directory,Directory), - atomic_concat(Directory,'input.txt',Input_Filename), - - ( - file_exists(Input_Filename) - -> - delete_file(Input_Filename); - true - ), - open(Input_Filename,'write',Handle), ( % go over all probabilistic fact @@ -831,137 +945,162 @@ update_values :- ), close(Handle), - !, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % stop write current probabilities to file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !, + + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % start update values for all test examples + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ( What_To_Update = all + -> + ( % go over all training examples + current_predicate(user:test_example/3), + user:test_example(QueryID,_Query,_QueryProb), + once(call_bdd_tool(QueryID,'+',all)), + fail; % go to next training example + true + ); true + ), + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % stop update values for all test examples + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !, + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % start update values for all training examples + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ( % go over all training examples + current_predicate(user:example/3), + user:example(QueryID,_Query,_QueryProb), + once(call_bdd_tool(QueryID,'.',What_To_Update)), + fail; % go to next training example + true + ), + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % stop update values for all training examples + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !, + + + nl, + + delete_file(Input_Filename), assert(values_correct). +%======================================================================== +%= +%= +%= +%======================================================================== -%======================================================================== -%= -%= -%= -%======================================================================== -update_query_cleanup(QueryID) :- + +call_bdd_tool(QueryID,Symbol,What_To_Update) :- + output_directory(Output_Directory), + query_directory(Query_Directory), ( - (query_is_similar(QueryID,_) ; query_is_similar(_,QueryID)) + query_is_similar(QueryID,_) -> - % either this query is similar to another or vice versa, - % therefore we don't delete anything - true; - once(retractall(query_gradient_intern(QueryID,_,_))) - ). + % we don't have to evaluate the BDD + write('#'); + ( + sigmoid_slope(Slope), + problog_dir(PD), + (What_To_Update=all -> Method='g' ; Method='l'), + atomic_concat([PD, + '/ProblogBDD -i "', + Output_Directory, + 'input.txt', + '" -l "', + Query_Directory, + 'query_', + QueryID, + '" -m ',Method,' -id ', + QueryID, + ' -sl ',Slope, + ' > "', + Output_Directory, + 'values.pl"'],Command), + shell(Command,Error), - - -update_query(QueryID,Symbol,What_To_Update) :- - learning_flag(output_directory,Output_Directory), - learning_flag(query_directory,Query_Directory), - ( - query_is_similar(QueryID,_) - -> - % we don't have to evaluate the BDD - my_format(4,'#',[]); - ( - learning_flag(sigmoid_slope,Slope), - problog_dir(PD), - ((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'), - atomic_concat([PD, - '/ProblogBDD -i "', - Output_Directory, - 'input.txt', - '" -l "', - Query_Directory, - 'query_', - QueryID, - '" -m ',Method,' -id ', - QueryID, - ' -sl ',Slope, - ' > "', - Output_Directory, - 'values.pl"'],Command), - shell(Command,Error), - - - ( - Error = 2 - -> - throw(error('SimpleCUDD has been interrupted.')); - true - ), - ( - Error \= 0 - -> - throw(bdd_error(QueryID,Error)); - true - ), - atomic_concat([Output_Directory,'values.pl'],Values_Filename), - ( - file_exists(Values_Filename) - -> - ( - ( - once(my_load(Values_Filename,QueryID)) - -> - true; + atomic_concat([' cat "', + Output_Directory, + 'values.pl" >> ~/all_results'],Command2), + shell(Command2), + ( + Error = 2 + -> + throw(error('SimpleCUDD has been interrupted.')); + true + ), + ( + Error \= 0 + -> + throw(bdd_error(QueryID,Error)); + true + ), + atomic_concat([Output_Directory,'values.pl'],Values_Filename), ( - format(user_error,'ERROR: Tried to read the file ~q but my_load/1 fails.~n~q.~2n',[Values_Filename,update_query(QueryID,Symbol,What_To_Update)]), - throw(error(my_load_fails)) - ) - ); - ( - format(user_error,'ERROR: Tried to read the file ~q but it does not exist.~n~q.~2n',[Values_Filename,update_query(QueryID,Symbol,What_To_Update)]), - throw(error(output_file_does_not_exist)) + file_exists(Values_Filename) + -> + ( + ( + once(my_load(Values_Filename)) + -> + true; + ( + format(user_error,'ERROR: Tried to read the file ~q but my_load/1 fails.~n~q.~2n',[Values_Filename,call_bdd_tool(QueryID,Symbol,What_To_Update)]), + throw(error(my_load_fails)) + ) + ); + ( + format(user_error,'ERROR: Tried to read the file ~q but it does not exist.~n~q.~2n',[Values_Filename,call_bdd_tool(QueryID,Symbol,What_To_Update)]), + throw(error(output_file_does_not_exist)) + ) + ) + ), + + delete_file(Values_Filename), + write(Symbol) ) - ) - ), - - delete_file(Values_Filename), - my_format(4,'~w',[Symbol]) - ) ), flush_output(user). %======================================================================== -%= This predicate reads probability and gradient values from the file -%= the gradient ID is a mere check to uncover hidden bugs -%= +Filename +QueryID -QueryProbability +%= +%= +%= %======================================================================== -my_load(File,QueryID) :- - open(File,'read',Handle), - read(Handle,Atom), - once(my_load_intern(Atom,Handle,QueryID)), - !, - close(Handle). -my_load(File,QueryID) :- - format(user_error,'Error at ~q.~2n',[my_load(File,QueryID)]), - throw(error(my_load(File,QueryID))). - -my_load_intern(end_of_file,_,_) :- +my_load(File) :- + see(File), + read(X), + my_load_intern(X), + seen. +my_load_intern(end_of_file) :- !. -my_load_intern(query_probability(QueryID,Prob),Handle,QueryID) :- +my_load_intern(query_probability(QueryID,Prob)) :- !, assert(query_probability_intern(QueryID,Prob)), - read(Handle,X), - my_load_intern(X,Handle,QueryID). -my_load_intern(query_gradient(QueryID,XFactID,Value),Handle,QueryID) :- + read(X2), + my_load_intern(X2). +my_load_intern(query_gradient(QueryID,XFactID,Value)) :- !, atomic_concat(x,StringFactID,XFactID), atom_number(StringFactID,FactID), assert(query_gradient_intern(QueryID,FactID,Value)), - read(Handle,X), - my_load_intern(X,Handle,QueryID). -my_load_intern(X,Handle,QueryID) :- + read(X2), + my_load_intern(X2). +my_load_intern(X) :- format(user_error,'Unknown atom ~q in results file.~n',[X]), - read(Handle,X), - my_load_intern(X,Handle,QueryID). - - + read(X2), + my_load_intern(X2). %======================================================================== @@ -1037,39 +1176,56 @@ mse_trainingset_only_for_linesearch(MSE) :- current_predicate(user:example/3) -> ( - - update_values, - findall(SquaredError, + update_values(probabilities), + findall(SquaredError, (user:example(QueryID,_Query,QueryProb), - once(update_query(QueryID,'.',probability)), - query_probability(QueryID,CurrentProb), - once(update_query_cleanup(QueryID)), - SquaredError is (CurrentProb-QueryProb)**2), + query_probability(QueryID,CurrentProb), + SquaredError is (CurrentProb-QueryProb)**2), AllSquaredErrors), length(AllSquaredErrors,Length), sum_list(AllSquaredErrors,SumAllSquaredErrors), - MSE is SumAllSquaredErrors/Length, - my_format(3,' (~8f)~n',[MSE]) + MSE is SumAllSquaredErrors/Length ); true ), retractall(values_correct). +% calculate the mse of the training data +mse_trainingset :- + ( + current_predicate(user:example/3) + -> + ( + update_values, + findall(SquaredError, + (user:example(QueryID,_Query,QueryProb), + query_probability(QueryID,CurrentProb), + SquaredError is (CurrentProb-QueryProb)**2), + AllSquaredErrors), + + length(AllSquaredErrors,Length), + sum_list(AllSquaredErrors,SumAllSquaredErrors), + min_list(AllSquaredErrors,MinError), + max_list(AllSquaredErrors,MaxError), + MSE is SumAllSquaredErrors/Length, + + logger_set_variable(mse_trainingset,MSE), + logger_set_variable(mse_min_trainingset,MinError), + logger_set_variable(mse_max_trainingset,MaxError) + ); true + ). + + -% calculate the mse of the test data mse_testset :- ( current_predicate(user:test_example/3) -> ( - my_format(2,'MSE_Test ',[]), - update_values, findall(SquaredError, (user:test_example(QueryID,_Query,QueryProb), - once(update_query(QueryID,'+',probability)), query_probability(QueryID,CurrentProb), - once(update_query_cleanup(QueryID)), SquaredError is (CurrentProb-QueryProb)**2), AllSquaredErrors), @@ -1081,8 +1237,7 @@ mse_testset :- logger_set_variable(mse_testset,MSE), logger_set_variable(mse_min_testset,MinError), - logger_set_variable(mse_max_testset,MaxError), - my_format(2,' (~8f)~n',[MSE]) + logger_set_variable(mse_max_testset,MaxError) ); true ). @@ -1096,15 +1251,25 @@ mse_testset :- %======================================================================== sigmoid(T,Sig) :- - learning_flag(sigmoid_slope,Slope), + sigmoid_slope(Slope), Sig is 1/(1+exp(-T*Slope)). inv_sigmoid(T,InvSig) :- - learning_flag(sigmoid_slope,Slope), + sigmoid_slope(Slope), InvSig is -log(1/T-1)/Slope. +%======================================================================== +%= this functions truncates probabilities too close to 1.0 or 0.0 +%= the reason is, applying the inverse sigmoid function would yield +/- inf +%= for such extreme values +%= +%= +Float, -Float +%======================================================================== +secure_probability(Prob,Prob_Secure) :- + TMP is max(0.000000001,Prob), + Prob_Secure is min(0.999999999,TMP). @@ -1130,7 +1295,7 @@ save_old_probabilities :- true ). -forget_old_probabilities :- +forget_old_values :- ( % go over all tunable facts tunable_fact(FactID,_), @@ -1145,31 +1310,36 @@ forget_old_probabilities :- add_gradient(Learning_Rate) :- ( % go over all tunable facts - tunable_fact(FactID,_), - atomic_concat(['old_prob_',FactID],Key), - atomic_concat(['grad_',FactID],Key2), - bb_get(Key,OldProbability), - bb_get(Key2,GradValue), + tunable_fact(FactID,_), + atomic_concat(['old_prob_',FactID],Key), + atomic_concat(['grad_',FactID],Key2), - inv_sigmoid(OldProbability,OldValue), - NewValue is OldValue -Learning_Rate*GradValue, - sigmoid(NewValue,NewProbability), + bb_get(Key,OldProbability), + bb_get(Key2,GradValue), - % Prevent "inf" by using values too close to 1.0 - Prob_Secure is min(0.999999999,max(0.000000001,NewProbability)), - set_fact_probability(FactID,Prob_Secure), + inv_sigmoid(OldProbability,OldValue), + NewValue is OldValue -Learning_Rate*GradValue, + sigmoid(NewValue,NewProbability), - fail; % go to next tunable fact - true + % Prevent "inf" by using values too close to 1.0 + secure_probability(NewProbability,NewProbabilityS), + set_fact_probability(FactID,NewProbabilityS), + + fail; % go to next tunable fact + + true ), - !, retractall(values_correct). +simulate :- + L = [0.6,1.0,2.0,3.0,10,50,100,200,300], + + findall((X,Y),(member(X,L),line_search_evaluate_point(X,Y)),List), + write(List),nl. gradient_descent :- - my_format(2,'Gradient ',[]), - + save_old_probabilities, update_values, @@ -1193,83 +1363,58 @@ gradient_descent :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % start calculate gradient %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - bb_put(mse_train_sum, 0.0), - bb_put(mse_train_min, 0.0), - bb_put(mse_train_max, 0.0), - - learning_flag(alpha,Alpha), - logger_set_variable(alpha,Alpha), - example_count(Example_Count), - - ( % go over all training examples - current_predicate(user:example/3), - user:example(QueryID,_Query,QueryProb), - once(update_query(QueryID,'.',all)), - query_probability(QueryID,BDDProb), - ( - QueryProb=:=0.0 - -> - Y2=Alpha; - Y2=1.0 - ), - Y is Y2*2/Example_Count * (BDDProb-QueryProb), - - % first do the calculations for the MSE on training set - - Squared_Error is (BDDProb-QueryProb)**2, - bb_get(mse_train_sum,Old_MSE_Train_Sum), - bb_get(mse_train_min,Old_MSE_Train_Min), - bb_get(mse_train_max,Old_MSE_Train_Max), - New_MSE_Train_Sum is Old_MSE_Train_Sum+Squared_Error, - New_MSE_Train_Min is min(Old_MSE_Train_Min,Squared_Error), - New_MSE_Train_Max is max(Old_MSE_Train_Max,Squared_Error), - bb_put(mse_train_sum,New_MSE_Train_Sum), - bb_put(mse_train_min,New_MSE_Train_Min), - bb_put(mse_train_max,New_MSE_Train_Max), - + alpha(Alpha), + example_count(ExampleCount), + ( % go over all training examples + current_predicate(user:example/3), + user:example(QueryID,_Query,QueryProb), + query_probability(QueryID,BDDProb), + ( + QueryProb=:=0.0 + -> + Y2=Alpha; + Y2=1.0 + ), + Y is Y2*2/ExampleCount * (BDDProb-QueryProb), - ( % go over all tunable facts - tunable_fact(FactID,_), - atomic_concat(['grad_',FactID],Key), - - % if the following query fails, - % it means, the fact is not used in the proof - % of QueryID, and the gradient is 0.0 and will - % not contribute to NewValue either way - % DON'T FORGET THIS IF YOU CHANGE SOMETHING HERE! - query_gradient(QueryID,FactID,GradValue), + ( % go over all tunable facts + + tunable_fact(FactID,_), + atomic_concat(['grad_',FactID],Key), + + % if the following query fails, + % it means, the fact is not used in the proof + % of QueryID, and the gradient is 0.0 and will + % not contribute to NewValue either way + % DON'T FORGET THIS IF YOU CHANGE SOMETHING HERE! + query_gradient(QueryID,FactID,GradValue), + + bb_get(Key,OldValue), + NewValue is OldValue + Y*GradValue, + bb_put(Key,NewValue), + fail; % go to next fact + + true + ), + fail; % go to next training example - bb_get(Key,OldValue), - NewValue is OldValue + Y*GradValue, - bb_put(Key,NewValue), - - fail; % go to next fact true - ), - - once(update_query_cleanup(QueryID)), - fail; % go to next training example - true ), %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % stop calculate gradient %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !, - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % start statistics on gradient %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - findall(V, ( - tunable_fact(FactID,_), - atomic_concat(['grad_',FactID],Key), - bb_get(Key,V) - ),Gradient_Values), + findall(V,(tunable_fact(FactID,_),atomic_concat(['grad_',FactID],Key),bb_get(Key,V)),GradientValues), - sum_list(Gradient_Values,GradSum), - max_list(Gradient_Values,GradMax), - min_list(Gradient_Values,GradMin), - length(Gradient_Values,GradLength), + sum_list(GradientValues,GradSum), + max_list(GradientValues,GradMax), + min_list(GradientValues,GradMin), + length(GradientValues,GradLength), GradMean is GradSum/GradLength, logger_set_variable(gradient_mean,GradMean), @@ -1278,37 +1423,25 @@ gradient_descent :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % stop statistics on gradient %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - bb_delete(mse_train_sum,MSE_Train_Sum), - bb_delete(mse_train_min,MSE_Train_Min), - bb_delete(mse_train_max,MSE_Train_Max), - MSE is MSE_Train_Sum/Example_Count, - - - logger_set_variable(mse_trainingset,MSE), - logger_set_variable(mse_min_trainingset,MSE_Train_Min), - logger_set_variable(mse_max_trainingset,MSE_Train_Max), - - my_format(2,'~n',[]), - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % start add gradient to current probabilities %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ( - learning_flag(line_search,false) + line_search(false) -> - learning_flag(learning_rate,LearningRate); + learning_rate(LearningRate); lineSearch(LearningRate,_) ), - my_format(3,'learning rate:~8f~n',[LearningRate]), + format('learning rate = ~12f~n',[LearningRate]), add_gradient(LearningRate), logger_set_variable(learning_rate,LearningRate), %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % stop add gradient to current probabilities %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !, - forget_old_probabilities. + forget_old_values. %======================================================================== %= @@ -1317,18 +1450,17 @@ gradient_descent :- line_search_evaluate_point(Learning_Rate,MSE) :- add_gradient(Learning_Rate), - my_format(2,'Line search (h=~8f) ',[Learning_Rate]), mse_trainingset_only_for_linesearch(MSE). lineSearch(Final_X,Final_Value) :- % Get Parameters for line search - learning_flag(line_search_tolerance,Tol), - learning_flag(line_search_tau,Tau), - learning_flag(line_search_interval,(A,B)), + line_search_tolerance(Tol), + line_search_tau(Tau), + line_search_interval(A,B), - my_format(3,'Line search in interval (~4f,~4f)~n',[A,B]), + format(' Running line search in interval (~5f,~5f)~n',[A,B]), % init values Acc is Tol * (B-A), @@ -1369,6 +1501,8 @@ lineSearch(Final_X,Final_Value) :- bb_get(line_search_value_left,FLeft), bb_get(line_search_value_right,FRight), + write(lineSearch(Iteration,Ak,Fl,Bk,Fr,Left,FLeft,Right,FRight)),nl, + ( % check for infinity, if there is, go to the left ( FLeft >= FRight, \+ FLeft = (+inf), \+ FRight = (+inf) ) @@ -1398,6 +1532,8 @@ lineSearch(Final_X,Final_Value) :- Next_Iteration is Iteration + 1, + ActAcc is BkNew -AkNew, + bb_put(line_search_iteration,Next_Iteration), bb_put(line_search_a,AkNew), @@ -1411,7 +1547,7 @@ lineSearch(Final_X,Final_Value) :- bb_put(line_search_value_right,FRightNew), % is the search interval smaller than the tolerance level? - BkNew-AkNew0, !. line_search_postcheck(V,X,V,X) :- - learning_flag(line_search_never_stop,false), + line_search_never_stop(false), !. line_search_postcheck(_,_, LLH, FinalPosition) :- - learning_flag(line_search_tolerance,Tolerance), - learning_flag(line_search_interval,(Left,Right)), + line_search_tolerance(Tolerance), + line_search_interval(Left,Right), Offset is (Right - Left) * Tolerance, @@ -1516,63 +1652,34 @@ my_5_min(V1,V2,V3,V4,V5,F1,F2,F3,F4,F5,VMin,FMin) :- (VMin=VTemp3,FMin=FTemp3); (VMin=V5,FMin=F5) ). - - -%======================================================================== -%= set the alpha parameter to the value -%= # positive training examples / # negative training examples -%= -%= training example is positive if P(e)=1 -%= training example is negative if P(e)=0 -%= -%= if there are training example with 00, - !, - set_learning_flag(alpha,1.0). -auto_alpha :- - findall(1,(user:example(_,_,P),P=:=1.0),Pos), - findall(0,(user:example(_,_,P),P=:=0.0),Neg), - length(Pos,NP), - length(Neg,NN), - Alpha is NP/NN, - set_learning_flag(alpha,Alpha). - + %======================================================================== %= initialize the logger module and set the flags for learning -%= don't change anything here! use set_learning_flag/2 instead +%= %======================================================================== global_initialize :- set_learning_flag(output_directory,'./output'), set_learning_flag(query_directory,'./queries'), - set_learning_flag(log_frequency,1), - set_learning_flag(rebuild_bdds,0), + set_learning_flag(log_frequency,5), + set_learning_flag(rebuild_bdds,false), + set_learning_flag(rebuild_bdds_it,1), set_learning_flag(reuse_initialized_bdds,false), set_learning_flag(learning_rate,examples), set_learning_flag(check_duplicate_bdds,true), set_learning_flag(probability_initializer,(FactID,P,random_probability(FactID,P))), - set_learning_flag(alpha,auto), + set_learning_flag(alpha,1.0), set_learning_flag(sigmoid_slope,1.0), % 1.0 gives standard sigmoid set_learning_flag(init_method,(Query,Probability,BDDFile,ProbFile, problog_kbest_save(Query,100,Probability,_Status,BDDFile,ProbFile))), set_learning_flag(line_search,false), set_learning_flag(line_search_never_stop,true), - set_learning_flag(line_search_tau,0.618033988749), + set_learning_flag(line_search_tau,0.618033988749895), set_learning_flag(line_search_tolerance,0.05), set_learning_flag(line_search_interval,(0,100)), - set_learning_flag(verbosity_level,5), logger_define_variable(iteration, int), logger_define_variable(duration,time), @@ -1588,8 +1695,7 @@ global_initialize :- logger_define_variable(ground_truth_diff,float), logger_define_variable(ground_truth_mindiff,float), logger_define_variable(ground_truth_maxdiff,float), - logger_define_variable(learning_rate,float), - logger_define_variable(alpha,float). + logger_define_variable(learning_rate,float). %======================================================================== %= diff --git a/packages/ProbLog/problog_learning/flags_learning.yap b/packages/ProbLog/learning/flags_learning.yap similarity index 100% rename from packages/ProbLog/problog_learning/flags_learning.yap rename to packages/ProbLog/learning/flags_learning.yap diff --git a/packages/ProbLog/problog_learning/logger.yap b/packages/ProbLog/learning/logger.yap similarity index 98% rename from packages/ProbLog/problog_learning/logger.yap rename to packages/ProbLog/learning/logger.yap index d9319d7c2..aa06250f9 100644 --- a/packages/ProbLog/problog_learning/logger.yap +++ b/packages/ProbLog/learning/logger.yap @@ -2,17 +2,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2009-06-17 22:22:00 +0200 (Wed, 17 Jun 2009) $ +% $Date: 2009-06-17 22:22:00 +0200 (Mi, 17 Jun 2009) $ % $Revision: 1550 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog % -% ProbLog was developed at Katholieke Universiteit Leuven -% -% Copyright 2009 -% Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann -% +% Copyright 2009 Katholieke Universiteit Leuven +% +% Authors: Luc De Raedt, Bernd Gutmann, Angelika Kimmig, +% Vitor Santos Costa +% +% % Main authors of this file: % Bernd Gutmann % diff --git a/packages/ProbLog/problog.yap b/packages/ProbLog/problog.yap index 034828e65..b4d353fb7 100644 --- a/packages/ProbLog/problog.yap +++ b/packages/ProbLog/problog.yap @@ -2,17 +2,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2009-07-21 18:30:23 +0200 (Tue, 21 Jul 2009) $ -% $Revision: 1805 $ +% $Date: 2009-06-17 22:22:00 +0200 (Mi, 17 Jun 2009) $ +% $Revision: 1550 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog % -% ProbLog was developed at Katholieke Universiteit Leuven -% -% Copyright 2009 -% Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann -% +% Copyright 2009 Katholieke Universiteit Leuven +% +% Authors: Luc De Raedt, Bernd Gutmann, Angelika Kimmig, +% Vitor Santos Costa +% +% % Main authors of this file: % Angelika Kimmig, Vitor Santos Costa,Bernd Gutmann % @@ -223,27 +224,27 @@ % angelika.kimmig@cs.kuleuven.be %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- module(problog, [problog_delta/5, - problog_threshold/5, - problog_low/4, - problog_kbest/4, - problog_kbest_save/6, - problog_max/3, - problog_exact/3, - problog_montecarlo/3, - problog_answers/2, - problog_table/1, - get_fact_probability/2, - set_fact_probability/2, - get_fact/2, - tunable_fact/2, - non_ground_fact/1, - export_facts/1, - problog_help/0, - show_inference/0, - problog_dir/1, - set_problog_flag/2, - problog_flag/2, - problog_flags/0]). + problog_threshold/5, + problog_low/4, + problog_kbest/4, + problog_kbest_save/6, + problog_max/3, + problog_exact/3, + problog_montecarlo/3, + problog_answers/2, + get_fact_probability/2, + set_fact_probability/2, + get_fact/2, + tunable_fact/2, + non_ground_fact/1, + export_facts/1, + problog_help/0, + show_inference/0, + problog_dir/1, + set_problog_flag/2, + problog_flag/2, + problog_flags/0, + op( 550, yfx, :: )]). :- style_check(all). :- yap_flag(unknown,error). @@ -272,12 +273,6 @@ :- ensure_loaded(library(system)). :- ensure_loaded(library(rbtrees)). -% op attaching probabilities to facts -:- op( 550, yfx, :: ). -:- op( 1150, fx, problog_table ). - -:- meta_predicate problog_table(:). - %%%%%%%%%%%%%%%%%%%%%%%% % control predicates on various levels %%%%%%%%%%%%%%%%%%%%%%%% @@ -313,17 +308,14 @@ :- dynamic dynamic_probability_fact/1. :- dynamic dynamic_probability_fact_extract/2. -% keep a tab on tabling -:- dynamic problog_tabled/1. - % directory where ProblogBDD executable is located % automatically set during loading -- assumes it is in same place as this file (problog.yap) %:- getcwd(PD),retractall(problog_dir(_)),assert(problog_dir(PD)). +% yap-6 separates executables and prolog progams... :- yap_flag(shared_object_search_path,PD), retractall(problog_dir(_)), assert(problog_dir(PD)). - %%%%%%%%%%%%%%%%%%%%%%%% % help %%%%%%%%%%%%%%%%%%%%%%%% @@ -371,7 +363,7 @@ init_global_params :- set_problog_flag(bdd_file,example_bdd), set_problog_flag(dir,output), set_problog_flag(save_bdd,false), - set_problog_flag(hacked_proofs,false), + set_problog_flag(fast_proofs,false), set_problog_flag(verbose,true). % problog_flags, % print_sep_line, @@ -401,12 +393,10 @@ problog_control(off,X) :- problog_control(check,X) :- call(X). -reset_control :- - problog_control(off,up), - problog_control(off,mc), - problog_control(off,limit), - problog_control(off,remember). -:- reset_control. +:- problog_control(off,up). +:- problog_control(off,mc). +:- problog_control(off,limit). +:- problog_control(off,remember). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % nice user syntax Prob::Fact @@ -437,7 +427,7 @@ user:term_expansion(P::Goal,Goal) :- P =:= 1, !. */ -user:term_expansion(P::Goal, problog:ProbFact) :- +user:term_expansion(P::Goal, problog:ProbFact) :- copy_term((P,Goal),(P_Copy,Goal_Copy)), functor(Goal, Name, Arity), atomic_concat([problog_,Name],ProblogName), @@ -446,7 +436,7 @@ user:term_expansion(P::Goal, problog:ProbFact) :- probclause_id(ID), ProbFact =.. [ProblogName,ID|L1], ( - (nonvar(P), P = t(TrueProb)) + (\+ var(P), P = t(TrueProb)) -> ( assert(tunable_fact(ID,TrueProb)), @@ -455,8 +445,6 @@ user:term_expansion(P::Goal, problog:ProbFact) :- ( ground(P) -> - EvalP is P, % allows one to use ground arithmetic expressions as probabilities - assert_static(prob_for_id(ID,EvalP)), % Prob is fixed -- assert it for quick retrieval LProb is log(P); ( % Probability is a variable... check wether it appears in the term @@ -496,6 +484,7 @@ problog_predicate(Name, Arity, ProblogName) :- ProbFact =.. [ProblogName,ID|L1], prolog_load_context(module,Mod), make_add_to_proof(ID2,ProbEval,AddToProof), + assert( (Mod:OriginalGoal :- ProbFact, ( non_ground_fact(ID) @@ -527,13 +516,11 @@ problog_predicate(Name, Arity, ProblogName) :- dynamic(problog:ProblogName/ArityPlus2). make_add_to_proof(ID2,ProbEval,O) :- - problog_flag(hacked_proofs,true), !, - O = hacked_add_to_proof(ID2,ProbEval). + problog_flag(fast_proofs,true), !, + O = fast_positive_add_to_proof(ID2,ProbEval). make_add_to_proof(ID2,ProbEval,add_to_proof(ID2,ProbEval)). - - % generate next global identifier probclause_id(ID) :- nb_getval(probclause_counter,ID), !, @@ -562,7 +549,7 @@ non_ground_fact_grounding_id(Goal,ID) :- nb_getval(non_ground_fact_grounding_id_counter,ID), ID2 is ID+1, nb_setval(non_ground_fact_grounding_id_counter,ID2), - once(assert(grounding_is_known(Goal,ID))) + assert(grounding_is_known(Goal,ID)) ) ). @@ -572,16 +559,10 @@ reset_non_ground_facts :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % access/update the probability of ID's fact -% hardware-access version: naively scan all problog-predicates (except if prob is recorded in static database), +% hardware-access version: naively scan all problog-predicates, % cut choice points if ID is ground (they'll all fail as ID is unique), % but not if it isn't (used to iterate over all facts when writing out probabilities for learning) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% using a dummy for the static prob database is more efficient than checking for current_predicate -prob_for_id(dummy,dummy). -get_fact_probability(ID,Prob) :- - ground(ID), - prob_for_id(ID,Prob), - !. get_fact_probability(ID,Prob) :- ( ground(ID) -> @@ -726,8 +707,10 @@ add_to_proof(ID,Prob) :- ) ). -% simpliciation -hacked_add_to_proof(ID,Prob) :- +% this is a version for long proofs, it assumes we are using +% tries, it assumes all our proofs never reuse ProbLog facts, and it assumes +% ground positive literals only. +fast_positive_add_to_proof(ID,Prob) :- b_getval(problog_probability, CurrentP), nb_getval(problog_threshold, CurrentThreshold), multiply_probabilities(CurrentP, Prob, NProb), @@ -822,16 +805,15 @@ multiply_probabilities(CurrentLogP, LogProb, NLogProb) :- % this is called by all inference methods before the actual ProbLog goal % to set up environment for proving -% it resets control flags, method specific values to be set afterwards! init_problog(Threshold) :- reset_non_ground_facts, - reset_control, LT is log(Threshold), b_setval(problog_probability, 0.0), b_setval(problog_current_proof, []), nb_setval(problog_threshold, LT), problog_flag(maxsteps,MaxS), - b_setval(problog_steps, MaxS). + b_setval(problog_steps, MaxS), + problog_control(off,limit). % idea: proofs that are refinements of known proof can be pruned as they don't add probability mass % note that current ptree implementation doesn't provide the check as there's no efficient method known so far... @@ -951,8 +933,8 @@ eval_dnf(ID,Prob,Status) :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% problog_threshold(Goal, Threshold, _, _, _) :- - init_problog_threshold(Threshold), problog_control(on,up), + init_problog_threshold(Threshold), problog_call(Goal), add_solution, fail. @@ -988,8 +970,8 @@ compute_bounds(LP, UP, Status) :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% problog_low(Goal, Threshold, _, _) :- - init_problog_low(Threshold), problog_control(off,up), + init_problog_low(Threshold), problog_call(Goal), add_solution, fail. @@ -1014,9 +996,9 @@ init_problog_low(Threshold) :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% problog_delta(Goal, Delta, Low, Up, Status) :- + problog_control(on,up), problog_flag(first_threshold,InitT), init_problog_delta(InitT,Delta), - problog_control(on,up), problog_delta_id(Goal,Status), delete_ptree(1), delete_ptree(2), @@ -1142,9 +1124,9 @@ eval_upper(N,UpP,ok) :- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% problog_max(Goal, Prob, Facts) :- + problog_control(off,up), problog_flag(first_threshold,InitT), init_problog_max(InitT), - problog_control(off,up), problog_max_id(Goal, Prob, FactIDs), ( FactIDs = [_|_] -> get_fact_list(FactIDs,Facts); Facts = FactIDs). @@ -1220,9 +1202,9 @@ problog_kbest_save(Goal, K, Prob, Status, BDDFile, ParamFile) :- true). problog_kbest(Goal, K, Prob, Status) :- + problog_control(off,up), problog_flag(first_threshold,InitT), init_problog_kbest(InitT), - problog_control(off,up), problog_kbest_id(Goal, K), retract(current_kbest(_,ListFound,_NumFound)), build_prefixtree(ListFound), @@ -1273,17 +1255,13 @@ update_current_kbest(K,NewLogProb,Cl) :- (NewLength < K -> assert(current_kbest(OldThres,NewList,NewLength)) ; - (NewLength>K - -> + (NewLength>K -> First is NewLength-K+1, cutoff(NewList,NewLength,First,FinalList,FinalLength) - ; - FinalList=NewList, FinalLength=NewLength - ), - FinalList=[NewThres-_|_], - nb_setval(problog_threshold,NewThres), - assert(current_kbest(NewThres,FinalList,FinalLength)) - ). + ; FinalList=NewList, FinalLength=NewLength), + FinalList=[NewThres-_|_], + nb_setval(problog_threshold,NewThres), + assert(current_kbest(NewThres,FinalList,FinalLength))). sorted_insert(A,[],[A]). sorted_insert(A-LA,[B1-LB1|B], [A-LA,B1-LB1|B] ) :- @@ -1401,33 +1379,14 @@ mc_prove(A) :- !, clean_sample :- reset_static_array(mc_sample), - problog_tabled(P),%show_table(P),table_statistics(P),get(_), - abolish_table(P), fail. clean_sample. -% find new proof -- need to reset control after init +% find new proof get_some_proof(Goal) :- init_problog(0), - problog_control(on,mc), problog_call(Goal). -problog_table(M:P) :- !, - problog_table(P,M). -problog_table(P) :- - prolog_load_context(module,M), - problog_table(P,M). - -problog_table(M:P,_) :- - problog_table(P,M). -problog_table((P1,P2),M) :- - problog_table(P1,M), - problog_table(P2,M). -problog_table(P,M) :- - table(M:P), - assert(problog_tabled(M:P)). - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % exact probability of all ground instances of Goal % output goes to File @@ -1446,4 +1405,4 @@ eval_answers :- problog_exact(G,P,_), format(answer,'answer(~q,~w).~n',[G,P]), fail. -eval_answers. +eval_answers. \ No newline at end of file diff --git a/packages/ProbLog/problog/flags.yap b/packages/ProbLog/problog/flags.yap index 0ef2f9c5d..6e1324c40 100644 --- a/packages/ProbLog/problog/flags.yap +++ b/packages/ProbLog/problog/flags.yap @@ -2,17 +2,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2009-06-17 22:22:00 +0200 (Wed, 17 Jun 2009) $ +% $Date: 2009-06-17 22:22:00 +0200 (Mi, 17 Jun 2009) $ % $Revision: 1550 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog % -% ProbLog was developed at Katholieke Universiteit Leuven -% -% Copyright 2009 -% Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann -% +% Copyright 2009 Katholieke Universiteit Leuven +% +% Authors: Luc De Raedt, Bernd Gutmann, Angelika Kimmig, +% Vitor Santos Costa +% +% % Main authors of this file: % Angelika Kimmig, Vitor Santos Costa % @@ -216,7 +217,7 @@ :- ensure_loaded(library(system)). -:- dynamic bdd_time/1, first_threshold/1, last_threshold/1, id_stepsize/1, prunecheck/1, maxsteps/1, mc_batchsize/1, mc_logfile/1, bdd_file/1, bdd_par_file/1, bdd_result/1, work_dir/1, save_bdd/1, problog_verbose/1, hacked_proofs/1. +:- dynamic bdd_time/1, first_threshold/1, last_threshold/1, id_stepsize/1, prunecheck/1, maxsteps/1, mc_batchsize/1, mc_logfile/1, bdd_file/1, bdd_par_file/1, bdd_result/1, work_dir/1, save_bdd/1, problog_verbose/1, fast_proofs/1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % global parameters that can be set using set_problog_flag/2 @@ -258,8 +259,8 @@ get_problog_flag(save_bdd,X) :- save_bdd(X). get_problog_flag(verbose,X) :- problog_verbose(X). -get_problog_flag(hacked_proofs,X) :- - hacked_proofs(X). +get_problog_flag(fast_proofs,X) :- + fast_proofs(X). %%%%%%%%%%%% @@ -474,17 +475,18 @@ set_problog_flag(verbose,_) :- flush_output(user), fail. -set_problog_flag(hacked_proofs,true) :- - retractall(hacked_proofs(_)), - assert(hacked_proofs(true)). -set_problog_flag(hacked_proofs,false) :- - retractall(hacked_proofs(_)), - assert(hacked_proofs(true)). -set_problog_flag(hacked_proofs,V) :- +set_problog_flag(fast_proofs,true) :- + retractall(fast_proofs(_)), + assert(fast_proofs(true)). +set_problog_flag(fast_proofs,false) :- + retractall(fast_proofs(_)), + assert(fast_proofs(true)). +set_problog_flag(fast_proofs,V) :- format(user,'\% ERROR: value ~w should be \'true\' or \'false\'!~n',[V]), flush_output(user), fail. + %%%%%%%%%%%%%%%%%%%%%%%% % show values %%%%%%%%%%%%%%%%%%%%%%%% diff --git a/packages/ProbLog/problog/print.yap b/packages/ProbLog/problog/print.yap index 355470939..860f3428a 100644 --- a/packages/ProbLog/problog/print.yap +++ b/packages/ProbLog/problog/print.yap @@ -2,17 +2,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2009-06-24 22:07:32 +0200 (Wed, 24 Jun 2009) $ -% $Revision: 1669 $ +% $Date: 2009-06-17 22:22:00 +0200 (Mi, 17 Jun 2009) $ +% $Revision: 1550 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog % -% ProbLog was developed at Katholieke Universiteit Leuven -% -% Copyright 2009 -% Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann -% +% Copyright 2009 Katholieke Universiteit Leuven +% +% Authors: Luc De Raedt, Bernd Gutmann, Angelika Kimmig, +% Vitor Santos Costa +% +% % Main authors of this file: % Angelika Kimmig, Vitor Santos Costa % @@ -212,16 +213,11 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- module(print, [print_param/4, - print_long_param/4, - print_sep_line/0, - print_inference/2]). + print_sep_line/0, + print_inference/2]). print_param(Keyword,Value,Function,Legal) :- format(user,'~w~55+~q~15+~w~30+~w~25+~n',[Keyword,Value,Function,Legal]). -print_long_param(Keyword,Value,Function,Legal) :- - format(user,'~w~55+~q~15+~w~30+~w~25+~n',[Keyword,Value,'','']), - format(user,'~w~55+~w~15+~w~30+~w~25+~n',['','',Function,Legal]). - print_sep_line :- sep_line(125). sep_line(0) :- diff --git a/packages/ProbLog/problog/tptree.yap b/packages/ProbLog/problog/tptree.yap index 71b4d56ef..f661895fe 100644 --- a/packages/ProbLog/problog/tptree.yap +++ b/packages/ProbLog/problog/tptree.yap @@ -2,17 +2,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2009-06-29 17:10:57 +0200 (Mon, 29 Jun 2009) $ -% $Revision: 1782 $ +% $Date: 2009-06-17 22:22:00 +0200 (Mi, 17 Jun 2009) $ +% $Revision: 1550 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog % -% ProbLog was developed at Katholieke Universiteit Leuven -% -% Copyright 2009 -% Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann -% +% Copyright 2009 Katholieke Universiteit Leuven +% +% Authors: Luc De Raedt, Bernd Gutmann, Angelika Kimmig, +% Vitor Santos Costa +% +% % Main authors of this file: % Angelika Kimmig, Vitor Santos Costa, Bernd Gutmann % @@ -272,7 +273,9 @@ init_ptree(ID) :- delete_ptree(ID) :- sym(ID,Sym), nb_getval(Sym, Trie), !, - trie_close(Trie). + trie_close(Trie), + trie_open(NewTrie), + nb_setval(Sym, NewTrie). delete_ptree(_). rename_ptree(OldID,NewID) :- diff --git a/packages/ProbLog/simplecudd/Example.c b/packages/ProbLog/simplecudd/Example.c index c0dab075f..a6a38628a 100644 --- a/packages/ProbLog/simplecudd/Example.c +++ b/packages/ProbLog/simplecudd/Example.c @@ -3,139 +3,182 @@ * SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * * SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * * * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* Copyright Katholieke Universiteit Leuven 2008 * * * * Author: Theofrastos Mantadelis * * File: Example.c * * * ******************************************************************************** * * -* The "Artistic License" * +* Artistic License 2.0 * * * -* Preamble * +* Copyright (c) 2000-2006, The Perl Foundation. * * * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * +* Everyone is permitted to copy and distribute verbatim copies of this license * +* document, but changing it is not allowed. * * * -* Definitions: * +* Preamble * * * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * +* This license establishes the terms under which a given free software Package * +* may be copied, modified, distributed, and/or redistributed. The intent is * +* that the Copyright Holder maintains some artistic control over the * +* development of that Package while still keeping the Package available as * +* open source and free software. * * * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * +* You are always permitted to make arrangements wholly outside of this license * +* directly with the Copyright Holder of a given Package. If the terms of this * +* license do not permit the full use that you propose to make of the Package, * +* you should contact the Copyright Holder and seek a different licensing * +* arrangement. * +* Definitions * * * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * +* "Copyright Holder" means the individual(s) or organization(s) named in the * +* copyright notice for the entire Package. * * * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * +* "Contributor" means any party that has contributed code or other material to * +* the Package, in accordance with the Copyright Holder's procedures. * * * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * +* "You" and "your" means any person who would like to copy, distribute, or * +* modify the Package. * * * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * +* "Package" means the collection of files distributed by the Copyright Holder, * +* and derivatives of that collection and/or of those files. A given Package * +* may consist of either the Standard Version, or a Modified Version. * * * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * +* "Distribute" means providing a copy of the Package or making it accessible * +* to anyone else, or in the case of a company or organization, to others * +* outside of your company or organization. * * * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * +* "Distributor Fee" means any fee that you charge for Distributing this * +* Package or providing support for this Package to another party. It does not * +* mean licensing fees. * * * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * +* "Standard Version" refers to the Package if it has not been modified, or has * +* been modified only in ways explicitly requested by the Copyright Holder. * * * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * +* "Modified Version" means the Package, if it has been changed, and such * +* changes were not explicitly requested by the Copyright Holder. * * * -* b) use the modified Package only within your corporation or organization. * +* "Original License" means this Artistic License as Distributed with the * +* Standard Version of the Package, in its current version or as it may be * +* modified by The Perl Foundation in the future. * * * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * +* "Source" form means the source code, documentation source, and configuration * +* files for the Package. * * * -* d) make other distribution arrangements with the Copyright Holder. * +* "Compiled" form means the compiled bytecode, object code, binary, or any * +* other form resulting from mechanical transformation or translation of the * +* Source form. * +* Permission for Use and Modification Without Distribution * * * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * +* (1) You are permitted to use the Standard Version and create and use * +* Modified Versions for any purpose without restriction, provided that you do * +* not Distribute the Modified Version. * +* Permissions for Redistribution of the Standard Version * * * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * +* (2) You may Distribute verbatim copies of the Source form of the Standard * +* Version of this Package in any medium without restriction, either gratis or * +* for a Distributor Fee, provided that you duplicate all of the original * +* copyright notices and associated disclaimers. At your discretion, such * +* verbatim copies may or may not include a Compiled form of the Package. * * * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * +* (3) You may apply any bug fixes, portability changes, and other * +* modifications made available from the Copyright Holder. The resulting * +* Package will still be considered the Standard Version, and as such will be * +* subject to the Original License. * +* Distribution of Modified Versions of the Package as Source * * * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * +* (4) You may Distribute your Modified Version as Source (either gratis or for * +* a Distributor Fee, and with or without a Compiled form of the Modified * +* Version) provided that you clearly document how it differs from the Standard * +* Version, including, but not limited to, documenting any non-standard * +* features, executables, or modules, and provided that you do at least ONE of * +* the following: * * * -* d) make other distribution arrangements with the Copyright Holder. * +* (a) make the Modified Version available to the Copyright Holder of the * +* Standard Version, under the Original License, so that the Copyright Holder * +* may include your modifications in the Standard Version. * +* (b) ensure that installation of your Modified Version does not prevent the * +* user installing or running the Standard Version. In addition, the Modified * +* Version must bear a name that is different from the name of the Standard * +* Version. * +* (c) allow anyone who receives a copy of the Modified Version to make the * +* Source form of the Modified Version available to others under * +* (i) the Original License or * +* (ii) a license that permits the licensee to freely copy, modify and * +* redistribute the Modified Version using the same licensing terms that apply * +* to the copy that the licensee received, and requires that the Source form of * +* the Modified Version, and of any works derived from it, be made freely * +* available in that license fees are prohibited but Distributor Fees are * +* allowed. * +* Distribution of Compiled Forms of the Standard Version or Modified Versions * +* without the Source * * * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * +* (5) You may Distribute Compiled forms of the Standard Version without the * +* Source, provided that you include complete instructions on how to get the * +* Source of the Standard Version. Such instructions must be valid at the time * +* of your distribution. If these instructions, at any time while you are * +* carrying out such distribution, become invalid, you must provide new * +* instructions on demand or cease further distribution. If you provide valid * +* instructions or cease distribution within thirty days after you become aware * +* that the instructions are invalid, then you do not forfeit any of your * +* rights under this license. * * * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * +* (6) You may Distribute a Modified Version in Compiled form without the * +* Source, provided that you comply with Section 4 with respect to the Source * +* of the Modified Version. * +* Aggregating or Linking the Package * * * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * +* (7) You may aggregate the Package (either the Standard Version or Modified * +* Version) with other packages and Distribute the resulting aggregation * +* provided that you do not charge a licensing fee for the Package. Distributor * +* Fees are permitted, and licensing fees for other components in the * +* aggregation are permitted. The terms of this license apply to the use and * +* Distribution of the Standard or Modified Versions as included in the * +* aggregation. * * * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * +* (8) You are permitted to link Modified and Standard Versions with other * +* works, to embed the Package in a larger work of your own, or to build * +* stand-alone binary or bytecode versions of applications that include the * +* Package, and Distribute the result without restriction, provided the result * +* does not expose a direct interface to the Package. * +* Items That are Not Considered Part of a Modified Version * * * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * +* (9) Works (including, but not limited to, modules and scripts) that merely * +* extend or make use of the Package, do not, by themselves, cause the Package * +* to be a Modified Version. In addition, such works are not considered parts * +* of the Package itself, and are not subject to the terms of this license. * +* General Provisions * * * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* (10) Any use, modification, and distribution of the Standard or Modified * +* Versions is governed by this Artistic License. By using, modifying or * +* distributing the Package, you accept this license. Do not use, modify, or * +* distribute the Package, if you do not accept this license. * +* * +* (11) If your Modified Version has been derived from a Modified Version made * +* by someone other than you, you are nevertheless required to ensure that your * +* Modified Version complies with the requirements of this license. * +* * +* (12) This license does not grant you the right to use any trademark, service * +* mark, tradename, or logo of the Copyright Holder. * +* * +* (13) This license includes the non-exclusive, worldwide, free-of-charge * +* patent license to make, have made, use, offer to sell, sell, import and * +* otherwise transfer the Package with respect to any patent claims licensable * +* by the Copyright Holder that are necessarily infringed by the Package. If * +* you institute patent litigation (including a cross-claim or counterclaim) * +* against any party alleging that the Package constitutes direct or * +* contributory patent infringement, then this Artistic License to you shall * +* terminate on the date that such litigation is filed. * +* * +* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER * +* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE * +* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * +* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. * +* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE * +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN * +* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF * +* SUCH DAMAGE. * * * * The End * * * @@ -228,7 +271,7 @@ void DFS(extmanager MyManager, DdNode *Current) { char *curnode; curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); if (GetIndex(Current) < MyManager.varmap.varcnt) { - printf("%s(%f,%i,%s)\n", curnode, MyManager.varmap.dvalue[GetIndex(Current)], MyManager.varmap.ivalue[GetIndex(Current)], MyManager.varmap.dynvalue[GetIndex(Current)]); + printf("%s(%f,%i,%s)\n", curnode, MyManager.varmap.dvalue[GetIndex(Current)], MyManager.varmap.ivalue[GetIndex(Current)], (char *) MyManager.varmap.dynvalue[GetIndex(Current)]); } else { printf("%s\n", curnode); } diff --git a/packages/ProbLog/simplecudd/ProblogBDD.c b/packages/ProbLog/simplecudd/ProblogBDD.c index 61c38e71e..052a055f9 100644 --- a/packages/ProbLog/simplecudd/ProblogBDD.c +++ b/packages/ProbLog/simplecudd/ProblogBDD.c @@ -3,140 +3,182 @@ * SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * * SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * * * -* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * -* and Katholieke Universiteit Leuven 2008 * +* Copyright Katholieke Universiteit Leuven 2008 * * * * Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * * File: ProblogBDD.c * * * ******************************************************************************** * * -* The "Artistic License" * +* Artistic License 2.0 * * * -* Preamble * +* Copyright (c) 2000-2006, The Perl Foundation. * * * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * +* Everyone is permitted to copy and distribute verbatim copies of this license * +* document, but changing it is not allowed. * * * -* Definitions: * +* Preamble * * * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * +* This license establishes the terms under which a given free software Package * +* may be copied, modified, distributed, and/or redistributed. The intent is * +* that the Copyright Holder maintains some artistic control over the * +* development of that Package while still keeping the Package available as * +* open source and free software. * * * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * +* You are always permitted to make arrangements wholly outside of this license * +* directly with the Copyright Holder of a given Package. If the terms of this * +* license do not permit the full use that you propose to make of the Package, * +* you should contact the Copyright Holder and seek a different licensing * +* arrangement. * +* Definitions * * * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * +* "Copyright Holder" means the individual(s) or organization(s) named in the * +* copyright notice for the entire Package. * * * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * +* "Contributor" means any party that has contributed code or other material to * +* the Package, in accordance with the Copyright Holder's procedures. * * * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * +* "You" and "your" means any person who would like to copy, distribute, or * +* modify the Package. * * * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * +* "Package" means the collection of files distributed by the Copyright Holder, * +* and derivatives of that collection and/or of those files. A given Package * +* may consist of either the Standard Version, or a Modified Version. * * * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * +* "Distribute" means providing a copy of the Package or making it accessible * +* to anyone else, or in the case of a company or organization, to others * +* outside of your company or organization. * * * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * +* "Distributor Fee" means any fee that you charge for Distributing this * +* Package or providing support for this Package to another party. It does not * +* mean licensing fees. * * * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * +* "Standard Version" refers to the Package if it has not been modified, or has * +* been modified only in ways explicitly requested by the Copyright Holder. * * * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * +* "Modified Version" means the Package, if it has been changed, and such * +* changes were not explicitly requested by the Copyright Holder. * * * -* b) use the modified Package only within your corporation or organization. * +* "Original License" means this Artistic License as Distributed with the * +* Standard Version of the Package, in its current version or as it may be * +* modified by The Perl Foundation in the future. * * * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * +* "Source" form means the source code, documentation source, and configuration * +* files for the Package. * * * -* d) make other distribution arrangements with the Copyright Holder. * +* "Compiled" form means the compiled bytecode, object code, binary, or any * +* other form resulting from mechanical transformation or translation of the * +* Source form. * +* Permission for Use and Modification Without Distribution * * * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * +* (1) You are permitted to use the Standard Version and create and use * +* Modified Versions for any purpose without restriction, provided that you do * +* not Distribute the Modified Version. * +* Permissions for Redistribution of the Standard Version * * * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * +* (2) You may Distribute verbatim copies of the Source form of the Standard * +* Version of this Package in any medium without restriction, either gratis or * +* for a Distributor Fee, provided that you duplicate all of the original * +* copyright notices and associated disclaimers. At your discretion, such * +* verbatim copies may or may not include a Compiled form of the Package. * * * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * +* (3) You may apply any bug fixes, portability changes, and other * +* modifications made available from the Copyright Holder. The resulting * +* Package will still be considered the Standard Version, and as such will be * +* subject to the Original License. * +* Distribution of Modified Versions of the Package as Source * * * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * +* (4) You may Distribute your Modified Version as Source (either gratis or for * +* a Distributor Fee, and with or without a Compiled form of the Modified * +* Version) provided that you clearly document how it differs from the Standard * +* Version, including, but not limited to, documenting any non-standard * +* features, executables, or modules, and provided that you do at least ONE of * +* the following: * * * -* d) make other distribution arrangements with the Copyright Holder. * +* (a) make the Modified Version available to the Copyright Holder of the * +* Standard Version, under the Original License, so that the Copyright Holder * +* may include your modifications in the Standard Version. * +* (b) ensure that installation of your Modified Version does not prevent the * +* user installing or running the Standard Version. In addition, the Modified * +* Version must bear a name that is different from the name of the Standard * +* Version. * +* (c) allow anyone who receives a copy of the Modified Version to make the * +* Source form of the Modified Version available to others under * +* (i) the Original License or * +* (ii) a license that permits the licensee to freely copy, modify and * +* redistribute the Modified Version using the same licensing terms that apply * +* to the copy that the licensee received, and requires that the Source form of * +* the Modified Version, and of any works derived from it, be made freely * +* available in that license fees are prohibited but Distributor Fees are * +* allowed. * +* Distribution of Compiled Forms of the Standard Version or Modified Versions * +* without the Source * * * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * +* (5) You may Distribute Compiled forms of the Standard Version without the * +* Source, provided that you include complete instructions on how to get the * +* Source of the Standard Version. Such instructions must be valid at the time * +* of your distribution. If these instructions, at any time while you are * +* carrying out such distribution, become invalid, you must provide new * +* instructions on demand or cease further distribution. If you provide valid * +* instructions or cease distribution within thirty days after you become aware * +* that the instructions are invalid, then you do not forfeit any of your * +* rights under this license. * * * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * +* (6) You may Distribute a Modified Version in Compiled form without the * +* Source, provided that you comply with Section 4 with respect to the Source * +* of the Modified Version. * +* Aggregating or Linking the Package * * * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * +* (7) You may aggregate the Package (either the Standard Version or Modified * +* Version) with other packages and Distribute the resulting aggregation * +* provided that you do not charge a licensing fee for the Package. Distributor * +* Fees are permitted, and licensing fees for other components in the * +* aggregation are permitted. The terms of this license apply to the use and * +* Distribution of the Standard or Modified Versions as included in the * +* aggregation. * * * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * +* (8) You are permitted to link Modified and Standard Versions with other * +* works, to embed the Package in a larger work of your own, or to build * +* stand-alone binary or bytecode versions of applications that include the * +* Package, and Distribute the result without restriction, provided the result * +* does not expose a direct interface to the Package. * +* Items That are Not Considered Part of a Modified Version * * * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * +* (9) Works (including, but not limited to, modules and scripts) that merely * +* extend or make use of the Package, do not, by themselves, cause the Package * +* to be a Modified Version. In addition, such works are not considered parts * +* of the Package itself, and are not subject to the terms of this license. * +* General Provisions * * * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* (10) Any use, modification, and distribution of the Standard or Modified * +* Versions is governed by this Artistic License. By using, modifying or * +* distributing the Package, you accept this license. Do not use, modify, or * +* distribute the Package, if you do not accept this license. * +* * +* (11) If your Modified Version has been derived from a Modified Version made * +* by someone other than you, you are nevertheless required to ensure that your * +* Modified Version complies with the requirements of this license. * +* * +* (12) This license does not grant you the right to use any trademark, service * +* mark, tradename, or logo of the Copyright Holder. * +* * +* (13) This license includes the non-exclusive, worldwide, free-of-charge * +* patent license to make, have made, use, offer to sell, sell, import and * +* otherwise transfer the Package with respect to any patent claims licensable * +* by the Copyright Holder that are necessarily infringed by the Package. If * +* you institute patent litigation (including a cross-claim or counterclaim) * +* against any party alleging that the Package constitutes direct or * +* contributory patent infringement, then this Artistic License to you shall * +* terminate on the date that such litigation is filed. * +* * +* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER * +* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE * +* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * +* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. * +* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE * +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN * +* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF * +* SUCH DAMAGE. * * * * The End * * * @@ -296,10 +338,10 @@ int main(int argc, char **arg) { probability = tvalue.probability; double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; if (varpattern == NULL) { - printf("query_gradient(%s,%s,%e).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); } else { varpattern[strlen(varpattern) - 2] = '\0'; - printf("query_gradient(%s,%s,%e).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); } ReInitHistory(MyManager.his, MyManager.varmap.varcnt); } @@ -313,15 +355,15 @@ int main(int argc, char **arg) { tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); probability = tvalue.probability; } - printf("query_probability(%s,%e).\n", arg[params.queryid], probability); + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); break; case 'l': tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); probability = tvalue.probability; - printf("query_probability(%s,%e).\n", arg[params.queryid], probability); + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); break; case 'p': - printf("probability(%e).\n", CalcProbability(MyManager, bdd)); + printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); break; case 'o': onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); diff --git a/packages/ProbLog/simplecudd/general.c b/packages/ProbLog/simplecudd/general.c index 64a7f88e1..658ad6d2c 100644 --- a/packages/ProbLog/simplecudd/general.c +++ b/packages/ProbLog/simplecudd/general.c @@ -3,139 +3,182 @@ * SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * * SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * * * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* Copyright Katholieke Universiteit Leuven 2008 * * * * Author: Theofrastos Mantadelis * * File: general.c * * * ******************************************************************************** * * -* The "Artistic License" * +* Artistic License 2.0 * * * -* Preamble * +* Copyright (c) 2000-2006, The Perl Foundation. * * * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * +* Everyone is permitted to copy and distribute verbatim copies of this license * +* document, but changing it is not allowed. * * * -* Definitions: * +* Preamble * * * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * +* This license establishes the terms under which a given free software Package * +* may be copied, modified, distributed, and/or redistributed. The intent is * +* that the Copyright Holder maintains some artistic control over the * +* development of that Package while still keeping the Package available as * +* open source and free software. * * * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * +* You are always permitted to make arrangements wholly outside of this license * +* directly with the Copyright Holder of a given Package. If the terms of this * +* license do not permit the full use that you propose to make of the Package, * +* you should contact the Copyright Holder and seek a different licensing * +* arrangement. * +* Definitions * * * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * +* "Copyright Holder" means the individual(s) or organization(s) named in the * +* copyright notice for the entire Package. * * * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * +* "Contributor" means any party that has contributed code or other material to * +* the Package, in accordance with the Copyright Holder's procedures. * * * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * +* "You" and "your" means any person who would like to copy, distribute, or * +* modify the Package. * * * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * +* "Package" means the collection of files distributed by the Copyright Holder, * +* and derivatives of that collection and/or of those files. A given Package * +* may consist of either the Standard Version, or a Modified Version. * * * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * +* "Distribute" means providing a copy of the Package or making it accessible * +* to anyone else, or in the case of a company or organization, to others * +* outside of your company or organization. * * * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * +* "Distributor Fee" means any fee that you charge for Distributing this * +* Package or providing support for this Package to another party. It does not * +* mean licensing fees. * * * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * +* "Standard Version" refers to the Package if it has not been modified, or has * +* been modified only in ways explicitly requested by the Copyright Holder. * * * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * +* "Modified Version" means the Package, if it has been changed, and such * +* changes were not explicitly requested by the Copyright Holder. * * * -* b) use the modified Package only within your corporation or organization. * +* "Original License" means this Artistic License as Distributed with the * +* Standard Version of the Package, in its current version or as it may be * +* modified by The Perl Foundation in the future. * * * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * +* "Source" form means the source code, documentation source, and configuration * +* files for the Package. * * * -* d) make other distribution arrangements with the Copyright Holder. * +* "Compiled" form means the compiled bytecode, object code, binary, or any * +* other form resulting from mechanical transformation or translation of the * +* Source form. * +* Permission for Use and Modification Without Distribution * * * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * +* (1) You are permitted to use the Standard Version and create and use * +* Modified Versions for any purpose without restriction, provided that you do * +* not Distribute the Modified Version. * +* Permissions for Redistribution of the Standard Version * * * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * +* (2) You may Distribute verbatim copies of the Source form of the Standard * +* Version of this Package in any medium without restriction, either gratis or * +* for a Distributor Fee, provided that you duplicate all of the original * +* copyright notices and associated disclaimers. At your discretion, such * +* verbatim copies may or may not include a Compiled form of the Package. * * * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * +* (3) You may apply any bug fixes, portability changes, and other * +* modifications made available from the Copyright Holder. The resulting * +* Package will still be considered the Standard Version, and as such will be * +* subject to the Original License. * +* Distribution of Modified Versions of the Package as Source * * * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * +* (4) You may Distribute your Modified Version as Source (either gratis or for * +* a Distributor Fee, and with or without a Compiled form of the Modified * +* Version) provided that you clearly document how it differs from the Standard * +* Version, including, but not limited to, documenting any non-standard * +* features, executables, or modules, and provided that you do at least ONE of * +* the following: * * * -* d) make other distribution arrangements with the Copyright Holder. * +* (a) make the Modified Version available to the Copyright Holder of the * +* Standard Version, under the Original License, so that the Copyright Holder * +* may include your modifications in the Standard Version. * +* (b) ensure that installation of your Modified Version does not prevent the * +* user installing or running the Standard Version. In addition, the Modified * +* Version must bear a name that is different from the name of the Standard * +* Version. * +* (c) allow anyone who receives a copy of the Modified Version to make the * +* Source form of the Modified Version available to others under * +* (i) the Original License or * +* (ii) a license that permits the licensee to freely copy, modify and * +* redistribute the Modified Version using the same licensing terms that apply * +* to the copy that the licensee received, and requires that the Source form of * +* the Modified Version, and of any works derived from it, be made freely * +* available in that license fees are prohibited but Distributor Fees are * +* allowed. * +* Distribution of Compiled Forms of the Standard Version or Modified Versions * +* without the Source * * * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * +* (5) You may Distribute Compiled forms of the Standard Version without the * +* Source, provided that you include complete instructions on how to get the * +* Source of the Standard Version. Such instructions must be valid at the time * +* of your distribution. If these instructions, at any time while you are * +* carrying out such distribution, become invalid, you must provide new * +* instructions on demand or cease further distribution. If you provide valid * +* instructions or cease distribution within thirty days after you become aware * +* that the instructions are invalid, then you do not forfeit any of your * +* rights under this license. * * * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * +* (6) You may Distribute a Modified Version in Compiled form without the * +* Source, provided that you comply with Section 4 with respect to the Source * +* of the Modified Version. * +* Aggregating or Linking the Package * * * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * +* (7) You may aggregate the Package (either the Standard Version or Modified * +* Version) with other packages and Distribute the resulting aggregation * +* provided that you do not charge a licensing fee for the Package. Distributor * +* Fees are permitted, and licensing fees for other components in the * +* aggregation are permitted. The terms of this license apply to the use and * +* Distribution of the Standard or Modified Versions as included in the * +* aggregation. * * * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * +* (8) You are permitted to link Modified and Standard Versions with other * +* works, to embed the Package in a larger work of your own, or to build * +* stand-alone binary or bytecode versions of applications that include the * +* Package, and Distribute the result without restriction, provided the result * +* does not expose a direct interface to the Package. * +* Items That are Not Considered Part of a Modified Version * * * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * +* (9) Works (including, but not limited to, modules and scripts) that merely * +* extend or make use of the Package, do not, by themselves, cause the Package * +* to be a Modified Version. In addition, such works are not considered parts * +* of the Package itself, and are not subject to the terms of this license. * +* General Provisions * * * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* (10) Any use, modification, and distribution of the Standard or Modified * +* Versions is governed by this Artistic License. By using, modifying or * +* distributing the Package, you accept this license. Do not use, modify, or * +* distribute the Package, if you do not accept this license. * +* * +* (11) If your Modified Version has been derived from a Modified Version made * +* by someone other than you, you are nevertheless required to ensure that your * +* Modified Version complies with the requirements of this license. * +* * +* (12) This license does not grant you the right to use any trademark, service * +* mark, tradename, or logo of the Copyright Holder. * +* * +* (13) This license includes the non-exclusive, worldwide, free-of-charge * +* patent license to make, have made, use, offer to sell, sell, import and * +* otherwise transfer the Package with respect to any patent claims licensable * +* by the Copyright Holder that are necessarily infringed by the Package. If * +* you institute patent litigation (including a cross-claim or counterclaim) * +* against any party alleging that the Package constitutes direct or * +* contributory patent infringement, then this Artistic License to you shall * +* terminate on the date that such litigation is filed. * +* * +* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER * +* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE * +* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * +* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. * +* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE * +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN * +* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF * +* SUCH DAMAGE. * * * * The End * * * diff --git a/packages/ProbLog/simplecudd/general.h b/packages/ProbLog/simplecudd/general.h index 4441ed623..618c9a92e 100644 --- a/packages/ProbLog/simplecudd/general.h +++ b/packages/ProbLog/simplecudd/general.h @@ -3,139 +3,182 @@ * SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * * SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * * * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* Copyright Katholieke Universiteit Leuven 2008 * * * * Author: Theofrastos Mantadelis * * File: general.h * * * ******************************************************************************** * * -* The "Artistic License" * +* Artistic License 2.0 * * * -* Preamble * +* Copyright (c) 2000-2006, The Perl Foundation. * * * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * +* Everyone is permitted to copy and distribute verbatim copies of this license * +* document, but changing it is not allowed. * * * -* Definitions: * +* Preamble * * * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * +* This license establishes the terms under which a given free software Package * +* may be copied, modified, distributed, and/or redistributed. The intent is * +* that the Copyright Holder maintains some artistic control over the * +* development of that Package while still keeping the Package available as * +* open source and free software. * * * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * +* You are always permitted to make arrangements wholly outside of this license * +* directly with the Copyright Holder of a given Package. If the terms of this * +* license do not permit the full use that you propose to make of the Package, * +* you should contact the Copyright Holder and seek a different licensing * +* arrangement. * +* Definitions * * * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * +* "Copyright Holder" means the individual(s) or organization(s) named in the * +* copyright notice for the entire Package. * * * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * +* "Contributor" means any party that has contributed code or other material to * +* the Package, in accordance with the Copyright Holder's procedures. * * * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * +* "You" and "your" means any person who would like to copy, distribute, or * +* modify the Package. * * * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * +* "Package" means the collection of files distributed by the Copyright Holder, * +* and derivatives of that collection and/or of those files. A given Package * +* may consist of either the Standard Version, or a Modified Version. * * * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * +* "Distribute" means providing a copy of the Package or making it accessible * +* to anyone else, or in the case of a company or organization, to others * +* outside of your company or organization. * * * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * +* "Distributor Fee" means any fee that you charge for Distributing this * +* Package or providing support for this Package to another party. It does not * +* mean licensing fees. * * * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * +* "Standard Version" refers to the Package if it has not been modified, or has * +* been modified only in ways explicitly requested by the Copyright Holder. * * * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * +* "Modified Version" means the Package, if it has been changed, and such * +* changes were not explicitly requested by the Copyright Holder. * * * -* b) use the modified Package only within your corporation or organization. * +* "Original License" means this Artistic License as Distributed with the * +* Standard Version of the Package, in its current version or as it may be * +* modified by The Perl Foundation in the future. * * * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * +* "Source" form means the source code, documentation source, and configuration * +* files for the Package. * * * -* d) make other distribution arrangements with the Copyright Holder. * +* "Compiled" form means the compiled bytecode, object code, binary, or any * +* other form resulting from mechanical transformation or translation of the * +* Source form. * +* Permission for Use and Modification Without Distribution * * * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * +* (1) You are permitted to use the Standard Version and create and use * +* Modified Versions for any purpose without restriction, provided that you do * +* not Distribute the Modified Version. * +* Permissions for Redistribution of the Standard Version * * * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * +* (2) You may Distribute verbatim copies of the Source form of the Standard * +* Version of this Package in any medium without restriction, either gratis or * +* for a Distributor Fee, provided that you duplicate all of the original * +* copyright notices and associated disclaimers. At your discretion, such * +* verbatim copies may or may not include a Compiled form of the Package. * * * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * +* (3) You may apply any bug fixes, portability changes, and other * +* modifications made available from the Copyright Holder. The resulting * +* Package will still be considered the Standard Version, and as such will be * +* subject to the Original License. * +* Distribution of Modified Versions of the Package as Source * * * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * +* (4) You may Distribute your Modified Version as Source (either gratis or for * +* a Distributor Fee, and with or without a Compiled form of the Modified * +* Version) provided that you clearly document how it differs from the Standard * +* Version, including, but not limited to, documenting any non-standard * +* features, executables, or modules, and provided that you do at least ONE of * +* the following: * * * -* d) make other distribution arrangements with the Copyright Holder. * +* (a) make the Modified Version available to the Copyright Holder of the * +* Standard Version, under the Original License, so that the Copyright Holder * +* may include your modifications in the Standard Version. * +* (b) ensure that installation of your Modified Version does not prevent the * +* user installing or running the Standard Version. In addition, the Modified * +* Version must bear a name that is different from the name of the Standard * +* Version. * +* (c) allow anyone who receives a copy of the Modified Version to make the * +* Source form of the Modified Version available to others under * +* (i) the Original License or * +* (ii) a license that permits the licensee to freely copy, modify and * +* redistribute the Modified Version using the same licensing terms that apply * +* to the copy that the licensee received, and requires that the Source form of * +* the Modified Version, and of any works derived from it, be made freely * +* available in that license fees are prohibited but Distributor Fees are * +* allowed. * +* Distribution of Compiled Forms of the Standard Version or Modified Versions * +* without the Source * * * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * +* (5) You may Distribute Compiled forms of the Standard Version without the * +* Source, provided that you include complete instructions on how to get the * +* Source of the Standard Version. Such instructions must be valid at the time * +* of your distribution. If these instructions, at any time while you are * +* carrying out such distribution, become invalid, you must provide new * +* instructions on demand or cease further distribution. If you provide valid * +* instructions or cease distribution within thirty days after you become aware * +* that the instructions are invalid, then you do not forfeit any of your * +* rights under this license. * * * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * +* (6) You may Distribute a Modified Version in Compiled form without the * +* Source, provided that you comply with Section 4 with respect to the Source * +* of the Modified Version. * +* Aggregating or Linking the Package * * * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * +* (7) You may aggregate the Package (either the Standard Version or Modified * +* Version) with other packages and Distribute the resulting aggregation * +* provided that you do not charge a licensing fee for the Package. Distributor * +* Fees are permitted, and licensing fees for other components in the * +* aggregation are permitted. The terms of this license apply to the use and * +* Distribution of the Standard or Modified Versions as included in the * +* aggregation. * * * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * +* (8) You are permitted to link Modified and Standard Versions with other * +* works, to embed the Package in a larger work of your own, or to build * +* stand-alone binary or bytecode versions of applications that include the * +* Package, and Distribute the result without restriction, provided the result * +* does not expose a direct interface to the Package. * +* Items That are Not Considered Part of a Modified Version * * * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * +* (9) Works (including, but not limited to, modules and scripts) that merely * +* extend or make use of the Package, do not, by themselves, cause the Package * +* to be a Modified Version. In addition, such works are not considered parts * +* of the Package itself, and are not subject to the terms of this license. * +* General Provisions * * * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* (10) Any use, modification, and distribution of the Standard or Modified * +* Versions is governed by this Artistic License. By using, modifying or * +* distributing the Package, you accept this license. Do not use, modify, or * +* distribute the Package, if you do not accept this license. * +* * +* (11) If your Modified Version has been derived from a Modified Version made * +* by someone other than you, you are nevertheless required to ensure that your * +* Modified Version complies with the requirements of this license. * +* * +* (12) This license does not grant you the right to use any trademark, service * +* mark, tradename, or logo of the Copyright Holder. * +* * +* (13) This license includes the non-exclusive, worldwide, free-of-charge * +* patent license to make, have made, use, offer to sell, sell, import and * +* otherwise transfer the Package with respect to any patent claims licensable * +* by the Copyright Holder that are necessarily infringed by the Package. If * +* you institute patent litigation (including a cross-claim or counterclaim) * +* against any party alleging that the Package constitutes direct or * +* contributory patent infringement, then this Artistic License to you shall * +* terminate on the date that such litigation is filed. * +* * +* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER * +* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE * +* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * +* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. * +* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE * +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN * +* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF * +* SUCH DAMAGE. * * * * The End * * * diff --git a/packages/ProbLog/simplecudd/simplecudd.c b/packages/ProbLog/simplecudd/simplecudd.c index fa5dc0820..f502be8b4 100644 --- a/packages/ProbLog/simplecudd/simplecudd.c +++ b/packages/ProbLog/simplecudd/simplecudd.c @@ -3,139 +3,182 @@ * SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * * SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * * * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* Copyright Katholieke Universiteit Leuven 2008 * * * * Author: Theofrastos Mantadelis * * File: simplecudd.c * * * ******************************************************************************** * * -* The "Artistic License" * +* Artistic License 2.0 * * * -* Preamble * +* Copyright (c) 2000-2006, The Perl Foundation. * * * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * +* Everyone is permitted to copy and distribute verbatim copies of this license * +* document, but changing it is not allowed. * * * -* Definitions: * +* Preamble * * * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * +* This license establishes the terms under which a given free software Package * +* may be copied, modified, distributed, and/or redistributed. The intent is * +* that the Copyright Holder maintains some artistic control over the * +* development of that Package while still keeping the Package available as * +* open source and free software. * * * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * +* You are always permitted to make arrangements wholly outside of this license * +* directly with the Copyright Holder of a given Package. If the terms of this * +* license do not permit the full use that you propose to make of the Package, * +* you should contact the Copyright Holder and seek a different licensing * +* arrangement. * +* Definitions * * * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * +* "Copyright Holder" means the individual(s) or organization(s) named in the * +* copyright notice for the entire Package. * * * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * +* "Contributor" means any party that has contributed code or other material to * +* the Package, in accordance with the Copyright Holder's procedures. * * * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * +* "You" and "your" means any person who would like to copy, distribute, or * +* modify the Package. * * * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * +* "Package" means the collection of files distributed by the Copyright Holder, * +* and derivatives of that collection and/or of those files. A given Package * +* may consist of either the Standard Version, or a Modified Version. * * * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * +* "Distribute" means providing a copy of the Package or making it accessible * +* to anyone else, or in the case of a company or organization, to others * +* outside of your company or organization. * * * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * +* "Distributor Fee" means any fee that you charge for Distributing this * +* Package or providing support for this Package to another party. It does not * +* mean licensing fees. * * * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * +* "Standard Version" refers to the Package if it has not been modified, or has * +* been modified only in ways explicitly requested by the Copyright Holder. * * * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * +* "Modified Version" means the Package, if it has been changed, and such * +* changes were not explicitly requested by the Copyright Holder. * * * -* b) use the modified Package only within your corporation or organization. * +* "Original License" means this Artistic License as Distributed with the * +* Standard Version of the Package, in its current version or as it may be * +* modified by The Perl Foundation in the future. * * * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * +* "Source" form means the source code, documentation source, and configuration * +* files for the Package. * * * -* d) make other distribution arrangements with the Copyright Holder. * +* "Compiled" form means the compiled bytecode, object code, binary, or any * +* other form resulting from mechanical transformation or translation of the * +* Source form. * +* Permission for Use and Modification Without Distribution * * * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * +* (1) You are permitted to use the Standard Version and create and use * +* Modified Versions for any purpose without restriction, provided that you do * +* not Distribute the Modified Version. * +* Permissions for Redistribution of the Standard Version * * * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * +* (2) You may Distribute verbatim copies of the Source form of the Standard * +* Version of this Package in any medium without restriction, either gratis or * +* for a Distributor Fee, provided that you duplicate all of the original * +* copyright notices and associated disclaimers. At your discretion, such * +* verbatim copies may or may not include a Compiled form of the Package. * * * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * +* (3) You may apply any bug fixes, portability changes, and other * +* modifications made available from the Copyright Holder. The resulting * +* Package will still be considered the Standard Version, and as such will be * +* subject to the Original License. * +* Distribution of Modified Versions of the Package as Source * * * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * +* (4) You may Distribute your Modified Version as Source (either gratis or for * +* a Distributor Fee, and with or without a Compiled form of the Modified * +* Version) provided that you clearly document how it differs from the Standard * +* Version, including, but not limited to, documenting any non-standard * +* features, executables, or modules, and provided that you do at least ONE of * +* the following: * * * -* d) make other distribution arrangements with the Copyright Holder. * +* (a) make the Modified Version available to the Copyright Holder of the * +* Standard Version, under the Original License, so that the Copyright Holder * +* may include your modifications in the Standard Version. * +* (b) ensure that installation of your Modified Version does not prevent the * +* user installing or running the Standard Version. In addition, the Modified * +* Version must bear a name that is different from the name of the Standard * +* Version. * +* (c) allow anyone who receives a copy of the Modified Version to make the * +* Source form of the Modified Version available to others under * +* (i) the Original License or * +* (ii) a license that permits the licensee to freely copy, modify and * +* redistribute the Modified Version using the same licensing terms that apply * +* to the copy that the licensee received, and requires that the Source form of * +* the Modified Version, and of any works derived from it, be made freely * +* available in that license fees are prohibited but Distributor Fees are * +* allowed. * +* Distribution of Compiled Forms of the Standard Version or Modified Versions * +* without the Source * * * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * +* (5) You may Distribute Compiled forms of the Standard Version without the * +* Source, provided that you include complete instructions on how to get the * +* Source of the Standard Version. Such instructions must be valid at the time * +* of your distribution. If these instructions, at any time while you are * +* carrying out such distribution, become invalid, you must provide new * +* instructions on demand or cease further distribution. If you provide valid * +* instructions or cease distribution within thirty days after you become aware * +* that the instructions are invalid, then you do not forfeit any of your * +* rights under this license. * * * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * +* (6) You may Distribute a Modified Version in Compiled form without the * +* Source, provided that you comply with Section 4 with respect to the Source * +* of the Modified Version. * +* Aggregating or Linking the Package * * * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * +* (7) You may aggregate the Package (either the Standard Version or Modified * +* Version) with other packages and Distribute the resulting aggregation * +* provided that you do not charge a licensing fee for the Package. Distributor * +* Fees are permitted, and licensing fees for other components in the * +* aggregation are permitted. The terms of this license apply to the use and * +* Distribution of the Standard or Modified Versions as included in the * +* aggregation. * * * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * +* (8) You are permitted to link Modified and Standard Versions with other * +* works, to embed the Package in a larger work of your own, or to build * +* stand-alone binary or bytecode versions of applications that include the * +* Package, and Distribute the result without restriction, provided the result * +* does not expose a direct interface to the Package. * +* Items That are Not Considered Part of a Modified Version * * * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * +* (9) Works (including, but not limited to, modules and scripts) that merely * +* extend or make use of the Package, do not, by themselves, cause the Package * +* to be a Modified Version. In addition, such works are not considered parts * +* of the Package itself, and are not subject to the terms of this license. * +* General Provisions * * * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* (10) Any use, modification, and distribution of the Standard or Modified * +* Versions is governed by this Artistic License. By using, modifying or * +* distributing the Package, you accept this license. Do not use, modify, or * +* distribute the Package, if you do not accept this license. * +* * +* (11) If your Modified Version has been derived from a Modified Version made * +* by someone other than you, you are nevertheless required to ensure that your * +* Modified Version complies with the requirements of this license. * +* * +* (12) This license does not grant you the right to use any trademark, service * +* mark, tradename, or logo of the Copyright Holder. * +* * +* (13) This license includes the non-exclusive, worldwide, free-of-charge * +* patent license to make, have made, use, offer to sell, sell, import and * +* otherwise transfer the Package with respect to any patent claims licensable * +* by the Copyright Holder that are necessarily infringed by the Package. If * +* you institute patent litigation (including a cross-claim or counterclaim) * +* against any party alleging that the Package constitutes direct or * +* contributory patent infringement, then this Artistic License to you shall * +* terminate on the date that such litigation is filed. * +* * +* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER * +* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE * +* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * +* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. * +* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE * +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN * +* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF * +* SUCH DAMAGE. * * * * The End * * * @@ -1088,7 +1131,7 @@ DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int max } endAt = clock(); secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %ld\n", term, iline, endAt - startAt); //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); if (bdd == NULL) { fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); @@ -1120,7 +1163,7 @@ DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int max else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); endAt = clock(); secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %ld\n", term, iline, endAt - startAt); //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); if (bdd == NULL) { fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); @@ -1400,7 +1443,7 @@ DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, } endAt = clock(); secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %ld\n", term, iline, endAt - startAt); //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); if (bdd == NULL) { fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); @@ -1432,7 +1475,7 @@ DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); endAt = clock(); secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %ld\n", term, iline, endAt - startAt); //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); if (bdd == NULL) { fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); diff --git a/packages/ProbLog/simplecudd/simplecudd.h b/packages/ProbLog/simplecudd/simplecudd.h index 5a03b2c94..cbc114954 100644 --- a/packages/ProbLog/simplecudd/simplecudd.h +++ b/packages/ProbLog/simplecudd/simplecudd.h @@ -3,139 +3,182 @@ * SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * * SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * * * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* Copyright Katholieke Universiteit Leuven 2008 * * * * Author: Theofrastos Mantadelis * * File: simplecudd.h * * * ******************************************************************************** * * -* The "Artistic License" * +* Artistic License 2.0 * * * -* Preamble * +* Copyright (c) 2000-2006, The Perl Foundation. * * * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * +* Everyone is permitted to copy and distribute verbatim copies of this license * +* document, but changing it is not allowed. * * * -* Definitions: * +* Preamble * * * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * +* This license establishes the terms under which a given free software Package * +* may be copied, modified, distributed, and/or redistributed. The intent is * +* that the Copyright Holder maintains some artistic control over the * +* development of that Package while still keeping the Package available as * +* open source and free software. * * * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * +* You are always permitted to make arrangements wholly outside of this license * +* directly with the Copyright Holder of a given Package. If the terms of this * +* license do not permit the full use that you propose to make of the Package, * +* you should contact the Copyright Holder and seek a different licensing * +* arrangement. * +* Definitions * * * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * +* "Copyright Holder" means the individual(s) or organization(s) named in the * +* copyright notice for the entire Package. * * * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * +* "Contributor" means any party that has contributed code or other material to * +* the Package, in accordance with the Copyright Holder's procedures. * * * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * +* "You" and "your" means any person who would like to copy, distribute, or * +* modify the Package. * * * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * +* "Package" means the collection of files distributed by the Copyright Holder, * +* and derivatives of that collection and/or of those files. A given Package * +* may consist of either the Standard Version, or a Modified Version. * * * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * +* "Distribute" means providing a copy of the Package or making it accessible * +* to anyone else, or in the case of a company or organization, to others * +* outside of your company or organization. * * * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * +* "Distributor Fee" means any fee that you charge for Distributing this * +* Package or providing support for this Package to another party. It does not * +* mean licensing fees. * * * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * +* "Standard Version" refers to the Package if it has not been modified, or has * +* been modified only in ways explicitly requested by the Copyright Holder. * * * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * +* "Modified Version" means the Package, if it has been changed, and such * +* changes were not explicitly requested by the Copyright Holder. * * * -* b) use the modified Package only within your corporation or organization. * +* "Original License" means this Artistic License as Distributed with the * +* Standard Version of the Package, in its current version or as it may be * +* modified by The Perl Foundation in the future. * * * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * +* "Source" form means the source code, documentation source, and configuration * +* files for the Package. * * * -* d) make other distribution arrangements with the Copyright Holder. * +* "Compiled" form means the compiled bytecode, object code, binary, or any * +* other form resulting from mechanical transformation or translation of the * +* Source form. * +* Permission for Use and Modification Without Distribution * * * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * +* (1) You are permitted to use the Standard Version and create and use * +* Modified Versions for any purpose without restriction, provided that you do * +* not Distribute the Modified Version. * +* Permissions for Redistribution of the Standard Version * * * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * +* (2) You may Distribute verbatim copies of the Source form of the Standard * +* Version of this Package in any medium without restriction, either gratis or * +* for a Distributor Fee, provided that you duplicate all of the original * +* copyright notices and associated disclaimers. At your discretion, such * +* verbatim copies may or may not include a Compiled form of the Package. * * * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * +* (3) You may apply any bug fixes, portability changes, and other * +* modifications made available from the Copyright Holder. The resulting * +* Package will still be considered the Standard Version, and as such will be * +* subject to the Original License. * +* Distribution of Modified Versions of the Package as Source * * * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * +* (4) You may Distribute your Modified Version as Source (either gratis or for * +* a Distributor Fee, and with or without a Compiled form of the Modified * +* Version) provided that you clearly document how it differs from the Standard * +* Version, including, but not limited to, documenting any non-standard * +* features, executables, or modules, and provided that you do at least ONE of * +* the following: * * * -* d) make other distribution arrangements with the Copyright Holder. * +* (a) make the Modified Version available to the Copyright Holder of the * +* Standard Version, under the Original License, so that the Copyright Holder * +* may include your modifications in the Standard Version. * +* (b) ensure that installation of your Modified Version does not prevent the * +* user installing or running the Standard Version. In addition, the Modified * +* Version must bear a name that is different from the name of the Standard * +* Version. * +* (c) allow anyone who receives a copy of the Modified Version to make the * +* Source form of the Modified Version available to others under * +* (i) the Original License or * +* (ii) a license that permits the licensee to freely copy, modify and * +* redistribute the Modified Version using the same licensing terms that apply * +* to the copy that the licensee received, and requires that the Source form of * +* the Modified Version, and of any works derived from it, be made freely * +* available in that license fees are prohibited but Distributor Fees are * +* allowed. * +* Distribution of Compiled Forms of the Standard Version or Modified Versions * +* without the Source * * * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * +* (5) You may Distribute Compiled forms of the Standard Version without the * +* Source, provided that you include complete instructions on how to get the * +* Source of the Standard Version. Such instructions must be valid at the time * +* of your distribution. If these instructions, at any time while you are * +* carrying out such distribution, become invalid, you must provide new * +* instructions on demand or cease further distribution. If you provide valid * +* instructions or cease distribution within thirty days after you become aware * +* that the instructions are invalid, then you do not forfeit any of your * +* rights under this license. * * * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * +* (6) You may Distribute a Modified Version in Compiled form without the * +* Source, provided that you comply with Section 4 with respect to the Source * +* of the Modified Version. * +* Aggregating or Linking the Package * * * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * +* (7) You may aggregate the Package (either the Standard Version or Modified * +* Version) with other packages and Distribute the resulting aggregation * +* provided that you do not charge a licensing fee for the Package. Distributor * +* Fees are permitted, and licensing fees for other components in the * +* aggregation are permitted. The terms of this license apply to the use and * +* Distribution of the Standard or Modified Versions as included in the * +* aggregation. * * * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * +* (8) You are permitted to link Modified and Standard Versions with other * +* works, to embed the Package in a larger work of your own, or to build * +* stand-alone binary or bytecode versions of applications that include the * +* Package, and Distribute the result without restriction, provided the result * +* does not expose a direct interface to the Package. * +* Items That are Not Considered Part of a Modified Version * * * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * +* (9) Works (including, but not limited to, modules and scripts) that merely * +* extend or make use of the Package, do not, by themselves, cause the Package * +* to be a Modified Version. In addition, such works are not considered parts * +* of the Package itself, and are not subject to the terms of this license. * +* General Provisions * * * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* (10) Any use, modification, and distribution of the Standard or Modified * +* Versions is governed by this Artistic License. By using, modifying or * +* distributing the Package, you accept this license. Do not use, modify, or * +* distribute the Package, if you do not accept this license. * +* * +* (11) If your Modified Version has been derived from a Modified Version made * +* by someone other than you, you are nevertheless required to ensure that your * +* Modified Version complies with the requirements of this license. * +* * +* (12) This license does not grant you the right to use any trademark, service * +* mark, tradename, or logo of the Copyright Holder. * +* * +* (13) This license includes the non-exclusive, worldwide, free-of-charge * +* patent license to make, have made, use, offer to sell, sell, import and * +* otherwise transfer the Package with respect to any patent claims licensable * +* by the Copyright Holder that are necessarily infringed by the Package. If * +* you institute patent litigation (including a cross-claim or counterclaim) * +* against any party alleging that the Package constitutes direct or * +* contributory patent infringement, then this Artistic License to you shall * +* terminate on the date that such litigation is filed. * +* * +* (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER * +* AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE * +* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * +* NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. * +* UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE * +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN * +* ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF * +* SUCH DAMAGE. * * * * The End * * *