Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjohnwright committed Nov 12, 2015
2 parents f145403 + 755ce62 commit 5ad028d
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 504 deletions.
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ READLINE_VERSION = 6.3
TERMCAP_VERSION = 1.3.1
GSL_VERSION = 2.0



ifeq ($(OS),Windows_NT)
CCFLAGS += -D WIN32
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
Expand Down Expand Up @@ -36,17 +34,15 @@ else
endif
endif


all: cli r_package

cli: libnet readline
cli: pgmlab readline
make -C cli

r_package: pgmlab
make -C R/pgmlabR

r_package: libnet
make -C r_package/libnetR

libnet: sha gsl
pgmlab: sha gsl
make -C net

sha:
Expand All @@ -70,8 +66,16 @@ termcap:
make; \
make install;

make install:
make -C net install; \
make -C cli install

make uninstall:
make -C net uninstall; \
make -C cli uninstall

clean:
make -C net clean; \
make -C cli clean; \
make -C r_package/libnetR clean; \
make -C R/pgmlabR clean; \
rm bin/*
6 changes: 3 additions & 3 deletions r_package/libnetR/DESCRIPTION → R/pgmlabR/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: libnetR
Package: pgmlabR
Type: Package
Version: 1.0
Date: 2015-05-01
Expand All @@ -10,8 +10,8 @@ Authors@R: c(person("Adam", "Wright", role = c("aut", "cre"),
Author: Adam Wright [aut, cre], Hossein Radfar [aut]
Maintainer: Adam Wright <[email protected]>
Depends: R (>= 3.0.2)
Description: This is the R interface to LibNet. LibNet Consists of a c library that can be used for learning and inference on binary baysean probabilistic networks.
Description: This is the R interface to PGMLAB. PGMLAB Consists of a c library that can be used for learning and inference on binary baysean probabilistic networks.
License: GPL (>= 2)
LazyLoad: yes
URL: http://www.r-project.org, http://github.com/a8wright/libnet
URL: http://www.r-project.org, http://github.com/a8wright/PGMLAB
NeedsCompilation: yes
14 changes: 7 additions & 7 deletions r_package/libnetR/Makefile → R/pgmlabR/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ CC = gcc

R_VERSION = 3.2.2_1

TARGET = libnetR
LIBNET_LIB = ../../net/lib
TARGET = pgmlabR
PGMLAB_LIB = ../../net/lib


ifeq ($(OS),Windows_NT)
Expand All @@ -24,7 +24,7 @@ else
R_LIB = -L/usr/lib/R/lib -lR
INCLUDE_R = -I/usr/share/R/include
R_FLAGS = -Wl,Bsymbolic-functions -Wl,-z,relro -std=gnu99
SOFLAGS += -Wl,-rpath=$(LIBNET_LIB),-rpath=../external_lib/gsl/lib -fPIC
SOFLAGS += -Wl,-rpath=$(PGMLAB_LIB),-rpath=../external_lib/gsl/lib -fPIC
OFLAGS = -std=gnu99 -DNDEBUG -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g
endif
ifeq ($(UNAME_S),Darwin)
Expand All @@ -36,7 +36,7 @@ else
R_FLAGS = -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
SOFLAGS += -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
OFLAGS = -Wall -mtune=core2 -g -O2 -w
XLINKER = -Xlinker $(LIBNET_LIB)
XLINKER = -Xlinker $(PGMLAB_LIB)
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
Expand All @@ -51,15 +51,15 @@ else
endif

INCLUDE_GSL = -L../../external_lib/gsl/lib -I../../external_lib/gsl/include -lgsl -lgslcblas
INCLUDE_LIBNET = -L../../net/lib -lnet -I../../net/include -I../../resources/make_hash_table/include
INCLUDE_PGMLAB = -L../../net/lib -lpgmlab -I../../net/include -I../../resources/make_hash_table/include

all: object
mkdir -p lib; \
$(CC) $(LDFLAGS) $(SOFLAGS) $(R_LIB) -o lib/$(TARGET).$(SHARED_OBJECT_EXTENSION) obj/$(TARGET).o $(INCLUDE_LIBNET) $(RFLAGS)
$(CC) $(LDFLAGS) $(SOFLAGS) $(R_LIB) -o lib/$(TARGET).$(SHARED_OBJECT_EXTENSION) obj/$(TARGET).o $(INCLUDE_PGMLAB) $(RFLAGS)

object:
mkdir -p obj; \
$(CC) -DNDEBUG $(INCLUDE_R) $(OFLAGS) -c src/$(TARGET).c -o obj/$(TARGET).o $(INCLUDE_LIBNET) $(INCLUDE_GSL) $(XLINKER)
$(CC) -DNDEBUG $(INCLUDE_R) $(OFLAGS) -c src/$(TARGET).c -o obj/$(TARGET).o $(INCLUDE_PGMLAB) $(INCLUDE_GSL) $(XLINKER)

clean:
rm lib/* obj/*
File renamed without changes.
6 changes: 3 additions & 3 deletions r_package/libnetR/src/libnetR.c → R/pgmlabR/src/pgmlabR.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SEXP r_reaction_logic_to_factorgraph(SEXP reaction_logic_pathway_filepath_, SEXP

int exit_code = reaction_logic_to_factorgraph(reaction_logic_pathway_filepath, pathway_filepath, number_of_states);
if (exit_code != 0) {
char * strerr = strerror_libnet(exit_code);
char * strerr = strerror_pgmlab(exit_code);
Rprintf("ERROR: %s\n", strerr);
}

Expand All @@ -37,7 +37,7 @@ SEXP r_learning_discrete_BayNet(SEXP reaction_logic_pathway_filepath_, SEXP path
int exit_code = learning_discrete_BayNet(reaction_logic_pathway_filepath, pathway_filepath, observed_data_filepath, estimated_parameters_filepath,
number_of_states, em_max_iterations, em_log_likelihood_change_limit, em_parameters_change_limit, map_flag, logging);
if (exit_code != 0) {
char * strerr = strerror_libnet(exit_code);
char * strerr = strerror_pgmlab(exit_code);
Rprintf("ERROR: %s\n", strerr);
}

Expand All @@ -55,7 +55,7 @@ SEXP r_doLBPinference(SEXP reaction_logic_pathway_filepath_, SEXP pathway_filepa

int exit_code = doLBPinference(reaction_logic_pathway_filepath, pathway_filepath, observed_data_filepath, posterior_probabilities_filepath, number_of_states);
if (exit_code != 0) {
char * strerr = strerror_libnet(exit_code);
char * strerr = strerror_pgmlab(exit_code);
Rprintf("ERROR: %s\n", strerr);
}

Expand Down
84 changes: 37 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#LibNet
#PGMLAB (Probablistic Graphical Model Laboratory)

Libnet performs learning and inference in large discrete baysian networks. Libnet is a standalone C library, which has command line and R interfaces.
PGMLAB performs learning and inference in large discrete baysian networks. PGMLAB is a standalone C library, which has command line and R interfaces.

LibNet developed to fulfill three goals:
PGMLAB developed to fulfill three goals:

- To perform learning and inference in extremely large graphs.
- To be used by both expert and non expert in the field of machine learning
Expand All @@ -12,19 +12,21 @@ LibNet developed to fulfill three goals:

- Hossein Radfar
- Adam Wright
##Web Site
- Visit the PGMLAB website [here](http://oicr.github.io/PGMLAB)

##Wiki
- Please visit the LibNet wiki [here](https://github.com/OICR/LibNet/wiki) for details and theory.
- Make sure to follow the input file formats specifications [here](https://github.com/OICR/LibNet/wiki/File-Formats).
- Please visit the PGMLAB wiki [here](https://github.com/OICR/PGMLAB/wiki) for details and theory.
- Make sure to follow the input file formats specifications [here](https://github.com/OICR/PGMLAB/wiki/File-Formats).

##System requirements

LibNet has been tested on OS X and Ubuntu 14.04.
PGMLAB has been tested on OS X and Ubuntu 14.04.

###How to download, install and Run LibNet
###How to download, install and Run PGMLAB
####1. Download

- Download the latest version of LibNet from [here](https://github.com/OICR/LibNet/zipball/master)
- Download the latest version of PGMLAB from [here](https://github.com/OICR/PGMLAB/zipball/master)

####2. Installation

Expand All @@ -33,42 +35,33 @@ LibNet has been tested on OS X and Ubuntu 14.04.
Linux: sudo apt-get install texinfo
Mac OS X: follow the following instructions http://macappstore.org/texinfo/

#####2.2 Install LibNet Package
#####2.2 Install PGMLAB Package

- Type the following commands in a terminal:

cd .../your-download-directory/LibNet
make
cd .../your-download-directory/PGMLAB
make
make install (this will link PGMLAB to system paths, making PGMLAB accessible from anywhere on the host)

####3. Running LibNet

#####3.1 Generate hash for particular network with generateHash
####3 User Interfaces

######Library Path
There are two interaces to the shared object that come with this package: a command line interaface and a C interface. To make either of the interfaces you are required to have already compiled the PGMLAB shared object (3.2).

- Run the following command if you would like to access this library system wide (not necessary for basic installation)
#####3.1Command line interface

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<net/lib/libnet.[so|dynlib>

####4 User Interfaces

There are two interaces to the shared object that come with this package: a command line interaface and a C interface. To make either of the interfaces you are required to have already compiled the LibNet shared object (3.2).

#####4.1Command line interface

######4.1.2 Interacting with the command line interface
######3.1.2 Interacting with the command line interface

This command line interface can be used in two distinct ways. The first way is to supply the paths of the files in a config file, in the same way as the example config files in the config folder and flags to customize the parameters to be use and the second way is to input the information through an interactive interface. Further infromation on how to use these interface can be found in the wiki.

- Run the following commands for a description of the LibNet command line interface.
- Run the following commands for a description of the PGMLAB command line interface.

cd bin
./libnet --help
pgmlab --help

- The following will be outputed from the previous command

```
libnet [-gil] [--interactive] [--file-paths=file-paths] [--inference-use-logical-factorgraph] [--number-of-states=<int>] [--em-max-iterations=<int>] [--training-samples=<int>] [--log-likelihood-change-limit=<double>] [--parameters-change-limit=<double>] [--logging-on] [--maximum-a-posteriori-estimation] [--help] [--version]
pgmlab [-gil] [--interactive] [--file-paths=file-paths] [--inference-use-logical-factorgraph] [--number-of-states=<int>] [--em-max-iterations=<int>] [--training-samples=<int>] [--log-likelihood-change-limit=<double>] [--parameters-change-limit=<double>] [--logging-on] [--maximum-a-posteriori-estimation] [--help] [--version]
###Flag descriptions
-g, --generate-factorgraph Generate factor graph from reaction logic
Expand All @@ -90,33 +83,30 @@ libnet [-gil] [--interactive] [--file-paths=file-paths] [--inference-use-logical

*If you would like to use the interactive interface select the following flag: "--interactive".

*If you would like to run a new pathway you will need to rerun the generateHash program and then recompile the libnet program.
#####3.2 R interface

In order to call pgmlab from the R Console you will need to load the PGMLAB R shared object.

#####4.2 R interface

In order to call libnet from the R Console you will need to load the R LibNet shared object.

######4.2.1 Running R in order to be able to access the R LibNet shared object
######3.2.1 Running R in order to be able to access the PGMLAB R shared object

- Run on of the first two commands, depending on your OS, and then run one of the two options in the last line.

cd r_package/libnetR/ (for Linux)
cd r_package/ (for OS X)
cd R/pgmlabR/ (for Linux)
cd R/ (for OS X)
type r or rstudio

- You should now be in a R prompt

*The current working directory needs to be correct to have the shared obejects link to one another correctly

######4.2.2 Loading the LibNet shared ojbect within R or Rstudio
######3.2.2 Loading the PGMLAB shared ojbect within R or Rstudio

- Run the following command in order to load the shared object

dyn.load("<path to repo>/libnet/r_package/libnetR/lib/libnetR.so") (for Linux)
dyn.load("libnetR/lib/libnetR.so") (for OS X)
dyn.load("<path to repo>/PGMLAB/R/pgmlabR/lib/pgmlabR.so") (for Linux)
dyn.load("pgmlabR/lib/pgmlabR.so") (for OS X)

######4.2.3 Description of functions available from the R LibNet library
######3.2.3 Description of functions available from the PGMLAB R library

r_reaction_logic_to_factorgraph(SEXP reaction_logic_pathway_filepath_, SEXP pathway_filepath_, SEXP number_of_states_)

Expand All @@ -126,7 +116,7 @@ In order to call libnet from the R Console you will need to load the R LibNet sh

*All filepaths can be either full or abolute paths and the rest of the variables should be supplied as integer values.

######4.2.4 Example R function calls
######3.2.4 Example R function calls

*These relative paths are for linux and should be changed of OS X. In OS X the change should be to remove one of the '../' from the beginning of the each filepath.

Expand All @@ -144,16 +134,16 @@ In order to call libnet from the R Console you will need to load the R LibNet sh

*Functions will return 0 upon success and error codes otherwise.

####5 Libnet dependencies
####4 PGMLAB dependencies

All resources are included in the LibNet package.
All resources are included in the PGMLAB package.

#####5.1 Resources
#####4.1 Resources
| Name | Description | Link |
|---------------------------|------------------------|------|
| Minimal Perfect Hashing | Minimal Perfect Hashing wass Created by Bob Jenkins and is used to hashing the names of the nodes. This allows LibNet to very quickely query nodes by their unique hash | http://burtleburtle.net/bob/hash/perfect.html |
| Minimal Perfect Hashing | Minimal Perfect Hashing wass Created by Bob Jenkins and is used to hashing the names of the nodes. This allows PGMLAB to very quickely query nodes by their unique hash | http://burtleburtle.net/bob/hash/perfect.html |

#####5.2 External Libraries
#####4.2 External Libraries
| Name | Description | Link |
|---------------------------|------------------------|------|
| GNU Scientific Library (GSL) | GSL is a numerical library for C and C++ that provides a wirde range of mathematical routines | http://www.gnu.org/software/gsl/ |
Expand Down
18 changes: 9 additions & 9 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# other external libraries/tools
#
#
#
CWD = $(shell pwd)
LIBNET_LIB = ../net/lib
SOFLAGS =
################################
Expand Down Expand Up @@ -49,13 +50,13 @@ DEBUGFLAGS = -O0 -D _DEBUG
LIBDIRS = -L$(LIBNET_LIB)
RPATH = -Wl,-rpath=$(LIBNET_LIB)

TARGET = libnet
TARGET = pgmlab
TARGET_PATH = ../bin/$(TARGET)
SOURCES = $(shell echo src/*.c) $(shell echo ../resources/make_hash_table/src/*.c) ../resources/minini/minIni.c
HEADERS = $(shell echo include/*.h) $(shell echo ../resources/make_hash_table/src/*.h) ../resources/minini/minIni.h ../resources/minini/wxMinIni.h ../resources/minini/minGlue.h
OBJECTS = $(SOURCES:.c=.o)

INCLUDE_NET = -L../net/lib -I../net/include -lnet
INCLUDE_NET = -L../net/lib -I../net/include -l$(TARGET)
INCLUDE_GSL = -L../external_lib/gsl/lib -I../external_lib/gsl/include -lgsl -lgslcblas
INCLUDE_READLINE = -L../external_lib/readline/lib -I../external_lib/readline/include -lreadline
INCLUDE_TERMCAP = -L../external_lib/termcap/lib -I../external_lib/termcap/include -ltermcap
Expand All @@ -68,12 +69,11 @@ $(TARGET): folders
folders:
mkdir -p ../bin

readline:
cd ..; \
make readline
make install:
ln -s $(CWD)/../bin/$(TARGET) /usr/local/bin/$(TARGET)

make uninstall:
rm /usr/local/bin/$(TARGET)

clean:
rm -f $(TARGET) $(OBJECTS)



Loading

0 comments on commit 5ad028d

Please sign in to comment.