Giter Club home page Giter Club logo

dc's Introduction

Distributional Clauses (beta)

Probabilistic logic language for inference, planning and learning in static and dynamic domains
DC: Distributional Clauses for inference in static models. (example and tutorial at examples/tutorial.pl)
DCPF: Distributional Clauses Particle Filter for filtering in dynamic models
HYPE: planner for hybrid MDPs based on DCPF (the code will be soon available)

The code is in beta, if you need help or find a bug please write an issue or contact me at davide (DOT) nitti (AT) cs (DOT) kuleuven (DOT) be

Prerequisites

Install Yap prolog (tested on YAP 6.2.2), follow these instructions:

cd yap-6.2.2
mkdir arch
cd arch
../configure --enable-tabling=yes --enable-dynamic-loading
make
sudo make install
sudo make install_library

Install GSL library, e.g., for Ubuntu 14.04:

sudo apt-get install libgsl0-dev libgsl0ldbl

For more recent Ubuntu distributions (e.g., 16.04) use this instead:

sudo apt-get install libgsl2 libgsl2:i386

Install boost library, e.g., for Ubuntu:

sudo apt-get install libboost-all-dev

Compilation

Execute

sh make.sh

Test

Execute

sh test.sh

or equivalently

yap -L examples/example1.pl

Expected output (the error values may differ):

Testing example1.pl...
Absolute error drawn(1) ~= 1: 4.91269841260689e-05
Absolute error drawn(1) ~= 2: 0.000294206349202047
Absolute error drawn(1) ~= 3: 0.00178948412698662
Absolute error average g ~ Gaussian(0,0.1): 0.000900261603206224
% 0.290 CPU in 0.291 seconds ( 99% CPU)

Tutorials

DC tutorial

A quick DC tutorial is available at examples/tutorial.pl
To run the tutorial, execute inside examples:

yap -l tutorial.pl

then write test_coin(N). followed by enter or other queries as explained in the file

dc's People

Contributors

davidenitti avatar

Stargazers

Davide De Martini avatar Ra avatar  avatar Harsha avatar Santiago Castro avatar Vishal Belsare avatar Lewis Hammond avatar Weiyu Liu avatar Olivier Kamers avatar Sebastijan Dumancic avatar Steffen Michels avatar Nuno Edgar Nunes Fernandes avatar Thiago P. Bueno avatar Fabrizio Riguzzi avatar Nuno Mendes avatar Douglas R. Miles avatar

Watchers

Douglas R. Miles avatar James Cloos avatar Julian Löchner avatar Sebastijan Dumancic avatar Olivier Kamers avatar  avatar Nuno Edgar Nunes Fernandes avatar Fabrizio Riguzzi avatar

dc's Issues

Problem implementing aggregation functions in DC

I am implementing an aggregation function in DC. The problem is that the head of the DC clause is not firing (the head random variable is not drawn from the probability distribution) when the body of the clause is true. The DC code is below:


%%% -- Mode: Prolog; --
:- use_module('../DC/dcpf.pl').
:- use_module('../DC/random/sampling.pl').
:- use_module('../DC/distributionalclause.pl').
:- use_module(library(lists)).
:- use_module(library(random)).

:- set_options(default).
:- set_inference(backward(lazy)).
:- initialization(init).

builtin(lmax( _ , _ )).
builtin(oneElementOfList( _ , _ )).

% Randomly picks one element of the list.
oneElementOfList([], []).
oneElementOfList(List, Elt) :- length(List, Length), random(0, Length, Index), nth0(Index, List, Elt).

% Finds a element occuring the most number of times in the list.
lmax(L, M) :- lmax(L, [], [], M).
lmax([], Seen, MMax, Max) :- MMax=[] -> Max=Seen; lmax(MMax, [], [], Max).
lmax([H|T], Seen, MMax, Max) :- (member(H, Seen) -> lmax(T, Seen, [H|MMax], Max); lmax(T, [H|Seen], MMax, Max)).
maxMod(X, P) ~ val(Max) := findall_forward(X,P,L), lmax(L, Max1), oneElementOfList(Max1, Max).

% Facts
marks(ann, bio) ~ val(high).
marks(ann, chem) ~ val(high).
marks(ann, phy) ~ val(low).

% Rule
grade(S) ~ finite([0.1:low, 0.9:high]) := maxMod(M, marks(S,C) ~= M) ~= high.

% Find probabilities
testMod(N) :-
query([],[],(maxMod(M, marks(ann,C) ~= M) ~= high),N,P),
write('probability: '),writeln(P).

testGrade(N) :-
query([],[],(grade(ann) ~= high),N,P),
write('probability: '),writeln(P).


After executing the above code I get
?- testMod(100).
probability: 1.0

?- testGrade(100).
probability: 0.0

Which means that the body is the clause "grade(S) ~ finite([0.1:low, 0.9:high]) := maxMod(M, marks(S,C) ~= M) ~= high." is always true but the head never fires.

I have invested a lot of time in resolving the issue but was not successful. Can you please check the issue?

Program gives permission error on abolish_all_tables

Everytime I run any provided example, like yap -L examples/example1.pl, I get this permission error:

ERROR!! (/home/littlebrat/Git/DC/distributionalclause.pl:70).

PERMISSION ERROR- in line 70, system predicate abolish_all_tables: modifying static procedure abolish_all_tables/0

Absolute error drawn(1) ~= 1: 0.00138055555555389
Absolute error drawn(1) ~= 2: 0.00197777777777297
Absolute error drawn(1) ~= 3: 0.00067246031746343
Absolute error average g ~ Gaussian(0,0.1): 0.0018059877648761
% 0.176 CPU in 0.179 seconds ( 98% CPU)

I tried running it as a super user, but it also returns the same error. Is this expected behavior?

can't "make" when installing yap (5th step)

I got stucked at the 5th step of:
cd yap-6.3
mkdir arch
cd arch
../configure --enable-tabling=yes --enable-dynamic-loading
make
sudo make install
sudo make install_library

Output:
config.status: creating packages/clpqr/Makefile
config.status: creating packages/swi-minisat2/Makefile
config.status: creating packages/swi-minisat2/C/Makefile
config.status: creating packages/real/Makefile
config.status: creating packages/real/rconfig.h
config.status: creating packages/myddas/Makefile
config.status: creating packages/CLPBN/Makefile
config.status: creating packages/CLPBN/horus/Makefile
config.status: creating packages/prism/src/c/Makefile
config.status: creating packages/prism/src/prolog/Makefile
config.status: creating packages/yap-lbfgs/Makefile
config.status: creating config.h
config.status: creating YapTermConfig.h
config.status: YapTermConfig.h is unchanged
config.status: creating packages/raptor/raptor_config.h
config.status: packages/raptor/raptor_config.h is unchanged
yantian@yantian-Inspiron-7348:~/yap-6.3-master/arch$ make
make: *** No rule to make target H/dglobals.h', needed byyap'. Stop.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.