diff --git a/.gitignore b/.gitignore
index be457cd..2da8b45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,4 +45,4 @@ docs/man3
docs/man
docs/Doxyfile
.cache
-
+vcpkg_installed
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 7a453f1..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,21 +0,0 @@
-[submodule "lib/json"]
- path = lib/json
- url = https://github.com/nlohmann/json.git
- master = master
- update = merge
-[submodule "lib/folding"]
- path = lib/folding
- url = https://github.com/rmontanana/folding
- main = main
- update = merge
-[submodule "tests/lib/catch2"]
- path = tests/lib/catch2
- url = https://github.com/catchorg/Catch2.git
- main = main
- update = merge
-[submodule "tests/lib/Files"]
- path = tests/lib/Files
- url = https://github.com/rmontanana/ArffFiles
-[submodule "lib/mdlp"]
- path = lib/mdlp
- url = https://github.com/rmontanana/mdlp
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a716115..59f08a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [1.1.0] - 2025-04-27
+
### Internal
-- Add changes to .clang-format to ajust to vscode format style thanks to https://clang-format-configurator.site/
+- Add changes to .clang-format to ajust to vscode format style thanks to
+- Remove all the dependencies as git submodules and add them as vcpkg dependencies.
+- Fix the dependencies versions for this specific BayesNet version.
## [1.0.7] 2025-03-16
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 359c806..5212607 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20)
project(BayesNet
- VERSION 1.0.7
+ VERSION 1.1.0
DESCRIPTION "Bayesian Network and basic classifiers Library."
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
LANGUAGES CXX
@@ -41,7 +41,6 @@ option(INSTALL_GTEST "Enable installation of googletest." OFF)
# CMakes modules
# --------------
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
-include(AddGitSubmodule)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE("Debug mode")
@@ -65,9 +64,10 @@ endif (ENABLE_CLANG_TIDY)
# External libraries - dependencies of BayesNet
# ---------------------------------------------
-# include(FetchContent)
-add_git_submodule("lib/json")
-add_git_submodule("lib/mdlp")
+find_package(Torch CONFIG REQUIRED)
+find_package(fimdlp CONFIG REQUIRED)
+find_package(nlohmann_json CONFIG REQUIRED)
+find_package(folding CONFIG REQUIRED)
# Subdirectories
# --------------
@@ -78,7 +78,7 @@ add_subdirectory(bayesnet)
# -------
if (ENABLE_TESTING)
MESSAGE(STATUS "Testing enabled")
- add_subdirectory(tests/lib/catch2)
+ find_package(Catch2 CONFIG REQUIRED)
include(CTest)
add_subdirectory(tests)
endif (ENABLE_TESTING)
diff --git a/Makefile b/Makefile
index a77c862..b663aa8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
SHELL := /bin/bash
.DEFAULT_GOAL := help
-.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge doc doc-install
+.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge doc doc-install init clean-test
f_release = build_Release
f_debug = build_Debug
@@ -63,7 +63,7 @@ buildd: ## Build the debug targets
buildr: ## Build the release targets
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
-clean: ## Clean the tests info
+clean-test: ## Clean the tests info
@echo ">>> Cleaning Debug BayesNet tests...";
$(call ClearTests)
@echo ">>> Done";
@@ -79,25 +79,40 @@ install: ## Install library
@cmake --install $(f_release) --prefix $(prefix)
@echo ">>> Done";
+init: ## Initialize the project installing dependencies
+ @echo ">>> Installing dependencies"
+ @vcpkg install
+ @echo ">>> Done";
+
+clean: ## Clean the project
+ @echo ">>> Cleaning the project..."
+ @if test -d build_Debug ; then echo "- Deleting build_Debug folder" ; rm -rf build_Debug; fi
+ @if test -d build_Release ; then echo "- Deleting build_Release folder" ; rm -rf build_Release; fi
+ @if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
+ @if test -d vcpkg_installed ; then echo "- Deleting vcpkg_installed folder" ; rm -rf vcpkg_installed; fi
+ @$(MAKE) clean-test
+ @echo ">>> Done";
+
debug: ## Build a debug version of the project
@echo ">>> Building Debug BayesNet...";
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
@mkdir $(f_debug);
- @cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON
+ @cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
release: ## Build a Release version of the project
@echo ">>> Building Release BayesNet...";
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release);
- @cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
+ @cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
fname = "tests/data/iris.arff"
sample: ## Build sample
@echo ">>> Building Sample...";
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
- @cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug && cmake --build build -t bayesnet_sample
+ @cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && \
+ cmake --build build -t bayesnet_sample
sample/build/bayesnet_sample $(fname)
@echo ">>> Done";
@@ -112,7 +127,7 @@ sample2: ## Build sample2
opt = ""
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
@echo ">>> Running BayesNet tests...";
- @$(MAKE) clean
+ @$(MAKE) clean-test
@cmake --build $(f_debug) -t $(test_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
@for t in $(test_targets); do \
echo ">>> Running $$t...";\
@@ -133,6 +148,7 @@ coverage: ## Run tests and generate coverage report (build/index.html)
$(lcov) --directory CMakeFiles --capture --demangle-cpp --ignore-errors source,source --output-file coverage.info >/dev/null 2>&1; \
$(lcov) --remove coverage.info '/usr/*' --output-file coverage.info >/dev/null 2>&1; \
$(lcov) --remove coverage.info 'lib/*' --output-file coverage.info >/dev/null 2>&1; \
+ $(lcov) --remove coverage.info 'include/*' --output-file coverage.info >/dev/null 2>&1; \
$(lcov) --remove coverage.info 'libtorch/*' --output-file coverage.info >/dev/null 2>&1; \
$(lcov) --remove coverage.info 'tests/*' --output-file coverage.info >/dev/null 2>&1; \
$(lcov) --remove coverage.info 'bayesnet/utils/loguru.*' --ignore-errors unused --output-file coverage.info >/dev/null 2>&1; \
diff --git a/README.md b/README.md
index f448f1b..936d67f 100644
--- a/README.md
+++ b/README.md
@@ -12,43 +12,103 @@
Bayesian Network Classifiers library
-## Dependencies
+## Setup
-The only external dependency is [libtorch](https://pytorch.org/cppdocs/installing.html) which can be installed with the following commands:
+### Using the vcpkg library
-```bash
-wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
-unzip libtorch-shared-with-deps-latest.zip
+You can use the library with the vcpkg library manager. In your project you have to add the following files:
+
+#### vcpkg.json
+
+```json
+{
+ "name": "sample-project",
+ "version-string": "0.1.0",
+ "dependencies": [
+ "bayesnet"
+ ]
+}
```
-## Setup
+#### vcpkg-configuration.json
+
+```json
+{
+ "registries": [
+ {
+ "kind": "git",
+ "repository": "https://github.com/rmontanana/vcpkg-stash",
+ "baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
+ "packages": [
+ "folding",
+ "bayesnet",
+ "arff-files",
+ "fimdlp",
+ "libtorch-bin"
+ ]
+ }
+ ],
+ "default-registry": {
+ "kind": "git",
+ "repository": "https://github.com/microsoft/vcpkg",
+ "baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605"
+ }
+}
+```
+
+#### CMakeLists.txt
+
+You have to include the following lines in your `CMakeLists.txt` file:
+
+```cmake
+find_package(bayesnet CONFIG REQUIRED)
+
+add_executable(myapp main.cpp)
+
+target_link_libraries(myapp PRIVATE bayesnet::bayesnet)
+```
+
+After that, you can use the `vcpkg` command to install the dependencies:
+
+```bash
+vcpkg install
+```
+
+**Note: In the `sample` folder you can find a sample application that uses the library. You can use it as a reference to create your own application.**
+
+## Playing with the library
+
+The dependencies are managed with [vcpkg](https://vcpkg.io/) and supported by a private vcpkg repository in [https://github.com/rmontanana/vcpkg-stash](https://github.com/rmontanana/vcpkg-stash).
### Getting the code
```bash
-git clone --recurse-submodules https://github.com/doctorado-ml/bayesnet
+git clone https://github.com/doctorado-ml/bayesnet
```
+Once you have the code, you can use the `make` command to build the project. The `Makefile` is used to manage the build process and it will automatically download and install the dependencies.
+
### Release
```bash
-make release
-make buildr
-sudo make install
+make init # Install dependencies
+make release # Build the release version
+make buildr # compile and link the release version
```
### Debug & Tests
```bash
-make debug
-make test
+make init # Install dependencies
+make debug # Build the debug version
+make test # Run the tests
```
### Coverage
```bash
-make coverage
-make viewcoverage
+make coverage # Run the tests with coverage
+make viewcoverage # View the coverage report in the browser
```
### Sample app
diff --git a/bayesnet/classifiers/Proposal.h b/bayesnet/classifiers/Proposal.h
index dd011d8..26118bf 100644
--- a/bayesnet/classifiers/Proposal.h
+++ b/bayesnet/classifiers/Proposal.h
@@ -9,7 +9,7 @@
#include
#include