First profiles

Signed-off-by: Ricardo Montañana Gómez <rmontanana@gmail.com>
This commit is contained in:
2025-06-30 22:40:35 +02:00
parent 3e94d400e2
commit 7a9d4178d9
18 changed files with 271 additions and 214 deletions

View File

@@ -10,37 +10,6 @@ project(bayesnet
set(CMAKE_CXX_STANDARD 17)
cmake_policy(SET CMP0135 NEW)
# Package manager detection
if(EXISTS ${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
include(${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
set(USING_CONAN TRUE)
message(STATUS "Using Conan package manager")
else()
set(USING_CONAN FALSE)
message(STATUS "Using vcpkg package manager")
endif()
# Find packages - works with both Conan and vcpkg
find_package(Torch CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
# These packages might not be available in Conan yet, so we handle them conditionally
if(NOT USING_CONAN)
find_package(fimdlp CONFIG REQUIRED)
find_package(folding CONFIG REQUIRED)
else()
# For Conan, we'll need to either find alternatives or create custom packages
# For now, we'll look for them and warn if not found
find_package(fimdlp CONFIG QUIET)
find_package(folding CONFIG QUIET)
if(NOT fimdlp_FOUND)
message(WARNING "fimdlp not found - you may need to create a custom Conan recipe")
endif()
if(NOT folding_FOUND)
message(WARNING "folding not found - you may need to create a custom Conan recipe")
endif()
endif()
# Global CMake variables
# ----------------------
set(CMAKE_CXX_STANDARD 17)
@@ -57,17 +26,32 @@ endif()
# Options
# -------
option(ENABLE_CLANG_TIDY "Enable to add clang tidy" OFF)
option(ENABLE_TESTING "Unit testing build" OFF)
option(CODE_COVERAGE "Collect coverage from test library" OFF)
option(INSTALL_GTEST "Enable installation of googletest" OFF)
option(USING_CONAN "Use Conan package manager" OFF)
if(USING_CONAN)
message(STATUS "Using Conan package manager")
else(USING_CONAN)
message(STATUS "Using vcpkg package manager")
endif(USING_CONAN)
find_package(Torch CONFIG REQUIRED)
if(NOT TARGET torch::torch)
add_library(torch::torch INTERFACE IMPORTED GLOBAL)
# expose include paths and libraries that the find-module discovered
set_target_properties(torch::torch PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${TORCH_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${TORCH_LIBRARIES}")
endif()
find_package(fimdlp CONFIG REQUIRED)
find_package(folding CONFIG REQUIRED)
find_package(nlohmann_json REQUIRED)
add_subdirectory(config)
if (ENABLE_CLANG_TIDY)
include(StaticAnalyzers) # clang-tidy
endif (ENABLE_CLANG_TIDY)
# Add the library
# ---------------
include_directories(
@@ -79,16 +63,13 @@ file(GLOB_RECURSE Sources "bayesnet/*.cc")
add_library(bayesnet ${Sources})
# Link libraries conditionally based on package manager
set(BAYESNET_LINK_LIBRARIES "${TORCH_LIBRARIES}")
if(fimdlp_FOUND)
list(APPEND BAYESNET_LINK_LIBRARIES fimdlp::fimdlp)
endif()
if(folding_FOUND)
list(APPEND BAYESNET_LINK_LIBRARIES folding::folding)
endif()
target_link_libraries(bayesnet ${BAYESNET_LINK_LIBRARIES})
target_link_libraries(bayesnet
nlohmann_json::nlohmann_json
folding::folding
fimdlp::fimdlp
torch::torch
arff-files::arff-files
)
# Testing
# -------

View File

@@ -5,6 +5,7 @@
},
"include": [
"build/Release/generators/CMakePresets.json",
"build_Release/build/Release/generators/CMakePresets.json"
"build_Release/build/Release/generators/CMakePresets.json",
"build_Debug/build/Debug/generators/CMakePresets.json"
]
}

266
Makefile
View File

@@ -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 init clean-test conan-init conan-debug conan-release conan-create conan-upload conan-clean
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean vcpkg-debug vcpkg-release vcpkg-sample updatebadge doc doc-install init clean-test conan-debug conan-release conan-create conan-upload conan-clean conan-sample
f_release = build_Release
f_debug = build_Debug
@@ -31,7 +31,6 @@ define ClearTests
fi ;
endef
setup: ## Install dependencies for tests and coverage
@if [ "$(shell uname)" = "Darwin" ]; then \
brew install gcovr; \
@@ -43,47 +42,6 @@ setup: ## Install dependencies for tests and coverage
fi
@echo "* You should install plantuml & graphviz for the diagrams"
diagrams: ## Create an UML class diagram & dependency of the project (diagrams/BayesNet.png)
@which $(plantuml) || (echo ">>> Please install plantuml"; exit 1)
@which $(dot) || (echo ">>> Please install graphviz"; exit 1)
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
@export PLANTUML_LIMIT_SIZE=16384
@echo ">>> Creating UML class diagram of the project...";
@$(clang-uml) -p
@cd $(f_diagrams); \
$(plantuml) -tsvg BayesNet.puml
@echo ">>> Creating dependency graph diagram of the project...";
$(MAKE) debug
cd $(f_debug) && cmake .. --graphviz=dependency.dot
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
buildd: ## Build the debug targets
cmake --build $(f_debug) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
buildr: ## Build the release targets
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
clean-test: ## Clean the tests info
@echo ">>> Cleaning Debug BayesNet tests...";
$(call ClearTests)
@echo ">>> Done";
uninstall: ## Uninstall library
@echo ">>> Uninstalling BayesNet...";
xargs rm < $(f_release)/install_manifest.txt
@echo ">>> Done";
prefix = "/usr/local"
install: ## Install library
@echo ">>> Installing BayesNet...";
@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 -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
@@ -96,37 +54,38 @@ clean: ## Clean the project
@$(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 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
# Build targets
# =============
buildd: ## Build the debug targets
cmake --build $(f_debug) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
buildr: ## Build the release targets
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
# Install targets
# ===============
uninstall: ## Uninstall library
@echo ">>> Uninstalling BayesNet...";
xargs rm < $(f_release)/install_manifest.txt
@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 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
prefix = "/usr/local"
install: ## Install library
@echo ">>> Installing BayesNet...";
@cmake --install $(f_release) --prefix $(prefix)
@echo ">>> Done";
fname = "tests/data/iris.arff"
model = "TANLd"
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=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && \
cmake --build build -t bayesnet_sample
sample/build/bayesnet_sample $(fname) $(model)
@echo ">>> Done";
fname = "tests/data/iris.arff"
sample2: ## Build sample2
@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_xspode
sample/build/bayesnet_sample_xspode $(fname)
@echo ">>> Done";
# Test targets
# ============
clean-test: ## Clean the tests info
@echo ">>> Cleaning Debug BayesNet tests...";
$(call ClearTests)
@echo ">>> Done";
opt = ""
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
@@ -182,6 +141,9 @@ updatebadge: ## Update the coverage badge in README.md
@env python update_coverage.py $(f_debug)/tests
@echo ">>> Done";
# Documentation targets
# =====================
doc: ## Generate documentation
@echo ">>> Generating documentation..."
@cmake --build $(f_release) -t doxygen
@@ -196,6 +158,20 @@ doc: ## Generate documentation
fi
@echo ">>> Done";
diagrams: ## Create an UML class diagram & dependency of the project (diagrams/BayesNet.png)
@which $(plantuml) || (echo ">>> Please install plantuml"; exit 1)
@which $(dot) || (echo ">>> Please install graphviz"; exit 1)
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
@export PLANTUML_LIMIT_SIZE=16384
@echo ">>> Creating UML class diagram of the project...";
@$(clang-uml) -p
@cd $(f_diagrams); \
$(plantuml) -tsvg BayesNet.puml
@echo ">>> Creating dependency graph diagram of the project...";
$(MAKE) debug
cd $(f_debug) && cmake .. --graphviz=dependency.dot
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
docdir = ""
doc-install: ## Install documentation
@echo ">>> Installing documentation..."
@@ -210,6 +186,111 @@ doc-install: ## Install documentation
@sudo cp -rp $(mansrcdir) $(mandestdir)
@echo ">>> Done";
# Conan package manager targets
# =============================
# conan-debug: ## Build debug version using Conan
# @echo ">>> Building Debug BayesNet with Conan..."
# @if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
# @mkdir $(f_debug)
# @conan install . -s build_type=Debug --build=missing -of $(f_debug)
# @cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -D USING_CONAN=ON -DCMAKE_TOOLCHAIN_FILE=$(f_debug)/build/Debug/generators/conan_toolchain.cmake
# @echo ">>> Done"
conan-debug: ## Build debug version using Conan
@echo ">>> Building *Debug* BayesNet with Conan..."
@rm -rf $(f_debug) # wipe previous tree
@conan install . \
-s build_type=Debug \
--build=missing \
-of $(f_debug) \
--profile=debug
@cmake -S . -B $(f_debug) \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_TESTING=ON \
-DCODE_COVERAGE=ON \
-DUSING_CONAN=ON \
-DCMAKE_TOOLCHAIN_FILE=$(f_debug)/build/Debug/generators/conan_toolchain.cmake
@echo ">>> Done"
conan-release: ## Build release version using Conan
@echo ">>> Building Release BayesNet with Conan..."
@conan install . \
-s build_type=Release \
--build=missing \
-of $(f_debug) \
--profile=release
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release)
@conan install . -s build_type=Release --build=missing -of $(f_release)
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -D USING_CONAN=ON -DCMAKE_TOOLCHAIN_FILE=$(f_release)/build/Release/generators/conan_toolchain.cmake
@echo ">>> Done"
conan-create: ## Create Conan package
@echo ">>> Creating Conan package..."
@conan create . --build=missing -tf "" --profile=release
@conan create . --build=missing -tf "" --profile=debug
@echo ">>> Done"
profile ?= default
remote ?= Cimmeria
conan-upload: ## Upload package to Conan remote (profile=default remote=conancenter)
@echo ">>> Uploading to Conan remote $(remote) with profile $(profile)..."
@conan upload bayesnet/$(grep version conanfile.py | cut -d'"' -f2) -r $(remote) --confirm
@echo ">>> Done"
conan-clean: ## Clean Conan cache and build folders
@echo ">>> Cleaning Conan cache and build folders..."
@conan remove "*" --confirm
@if test -d "$(f_release)" ; then rm -rf "$(f_release)"; fi
@if test -d "$(f_debug)" ; then rm -rf "$(f_debug)"; fi
@echo ">>> Done"
fname = "tests/data/iris.arff"
model = "TANLd"
conan-sample: ## Build sample with Conan
@echo ">>> Building Sample with Conan...";
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
@cd sample && conan install . --output-folder=build --build=missing
@cd sample && cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake && \
cmake --build build -t bayesnet_sample
sample/build/bayesnet_sample $(fname) $(model)
@echo ">>> Done";
# vcpkg package manager targets
# =============================
vcpkg-init: ## Initialize the project installing dependencies using vcpkg
@echo ">>> Installing dependencies with vcpkg"
@vcpkg install
@echo ">>> Done";
vcpkg-debug: ## Build a debug version of the project using vcpkg
@echo ">>> Building Debug BayesNet with vcpkg...";
@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 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
vcpkg-release: ## Build a Release version of the project using vcpkg
@echo ">>> Building Release BayesNet with vcpkg...";
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_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"
model = "TANLd"
vcpkg-sample: ## Build sample with vcpkg
@echo ">>> Building Sample with vcpkg...";
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
@cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Release -DUSING_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && \
cmake --build build -t bayesnet_sample
sample/build/bayesnet_sample $(fname) $(model)
@echo ">>> Done";
# Help target
# ===========
help: ## Show help message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
@@ -225,49 +306,4 @@ help: ## Show help message
printf "%-20s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done
# Conan package manager targets
# ============================
conan-init: ## Install dependencies using Conan
@echo ">>> Installing dependencies with Conan"
@which conan || (echo ">>> Please install Conan first: pip install conan"; exit 1)
@conan profile detect --force
@conan install . --build=missing
@echo ">>> Done"
conan-debug: ## Build debug version using Conan
@echo ">>> Building Debug BayesNet with Conan..."
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
@mkdir $(f_debug)
@conan install . -s build_type=Debug -o enable_testing=True -o enable_coverage=True --build=missing -of $(f_debug)
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON
@echo ">>> Done"
conan-release: ## Build release version using Conan
@echo ">>> Building Release BayesNet with Conan..."
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release)
@conan install . -s build_type=Release --build=missing -of $(f_release)
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
@echo ">>> Done"
conan-create: ## Create Conan package
@echo ">>> Creating Conan package..."
@conan create . --build=missing
@echo ">>> Done"
profile ?= default
remote ?= conancenter
conan-upload: ## Upload package to Conan remote (profile=default remote=conancenter)
@echo ">>> Uploading to Conan remote $(remote) with profile $(profile)..."
@conan upload bayesnet/$(shell grep version conanfile.py | cut -d'"' -f2) -r $(remote) --confirm
@echo ">>> Done"
conan-clean: ## Clean Conan cache and build folders
@echo ">>> Cleaning Conan cache and build folders..."
@conan remove "*" --confirm
@if test -d "$(f_release)" ; then rm -rf "$(f_release)"; fi
@if test -d "$(f_debug)" ; then rm -rf "$(f_debug)"; fi
@echo ">>> Done"
done

View File

@@ -1,13 +0,0 @@
include_directories(
${BayesNet_SOURCE_DIR}/lib/log
${BayesNet_SOURCE_DIR}/lib/mdlp/src
${BayesNet_SOURCE_DIR}/lib/folding
${BayesNet_SOURCE_DIR}/lib/json/include
${BayesNet_SOURCE_DIR}
${CMAKE_BINARY_DIR}/configured_files/include
)
file(GLOB_RECURSE Sources "*.cc")
add_library(BayesNet ${Sources})
target_link_libraries(BayesNet fimdlp "${TORCH_LIBRARIES}")

View File

@@ -5,7 +5,7 @@ import os
class BayesNetConan(ConanFile):
name = "bayesnet"
version = "1.1.2"
version = "1.2.0"
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
@@ -23,7 +23,7 @@ class BayesNetConan(ConanFile):
}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "bayesnet/*", "config/*", "cmake/*", "tests/*", "bayesnetConfig.cmake.in"
exports_sources = "CMakeLists.txt", "bayesnet/*", "config/*", "cmake/*", "docs/*", "tests/*", "bayesnetConfig.cmake.in"
def config_options(self):
if self.settings.os == "Windows":
@@ -37,19 +37,13 @@ class BayesNetConan(ConanFile):
# Core dependencies
self.requires("libtorch/2.7.0")
self.requires("nlohmann_json/3.11.3")
# Custom dependencies - these will need to be available in your Conan center or custom remotes
# For now, we'll comment them out and provide instructions in the README
self.requires("folding/1.1.1") # Custom package
self.requires("fimdlp/2.1.0") # Custom package
self.requires("arff-files/1.2.0") # Custom package
# Test dependencies
if self.options.enable_testing:
self.requires("catch2/3.8.1")
def build_requirements(self):
self.build_requires("cmake/[>=3.27]")
self.test_requires("arff-files/1.2.0") # Custom package
self.test_requires("catch2/3.8.1")
def layout(self):
cmake_layout(self)

View File

@@ -3,10 +3,6 @@
#include <string>
#include <string_view>
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
static constexpr std::string_view project_name = "@PROJECT_NAME@";
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";

View File

@@ -4,37 +4,38 @@ project(bayesnet_sample VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Release)
find_package(Torch CONFIG REQUIRED)
find_package(fimdlp CONFIG REQUIRED)
find_package(folding CONFIG REQUIRED)
find_package(arff-files CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(bayesnet CONFIG REQUIRED)
option(BAYESNET_VCPKG_CONFIG "Use vcpkg config for BayesNet" ON)
# option(USING_VCPKG "Use vcpkg config for BayesNet" OFF)
# option(USING_CONAN "Use Conan config for BayesNet" OFF)
if (BAYESNET_VCPKG_CONFIG)
message(STATUS "Using BayesNet vcpkg config")
find_package(bayesnet CONFIG REQUIRED)
set(BayesNet_LIBRARIES bayesnet::bayesnet)
else(BAYESNET_VCPKG_CONFIG)
message(STATUS "Using BayesNet local library config")
find_library(bayesnet NAMES libbayesnet bayesnet libbayesnet.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
find_path(Bayesnet_INCLUDE_DIRS REQUIRED NAMES bayesnet PATHS ${Platform_SOURCE_DIR}/../lib/include)
add_library(bayesnet::bayesnet UNKNOWN IMPORTED)
set_target_properties(bayesnet::bayesnet PROPERTIES
IMPORTED_LOCATION ${bayesnet}
INTERFACE_INCLUDE_DIRECTORIES ${Bayesnet_INCLUDE_DIRS}
)
endif(BAYESNET_VCPKG_CONFIG)
message(STATUS "BayesNet: ${bayesnet}")
# if (USING_VCPKG OR USING_CONAN)
# message(STATUS "Using BayesNet vcpkg config")
# find_package(bayesnet CONFIG REQUIRED)
# set(BayesNet_LIBRARIES bayesnet::bayesnet)
# else(USING_VCPKG)
# message(STATUS "Using BayesNet local library config")
# find_library(bayesnet NAMES libbayesnet bayesnet libbayesnet.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
# find_path(Bayesnet_INCLUDE_DIRS REQUIRED NAMES bayesnet PATHS ${Platform_SOURCE_DIR}/../lib/include)
# add_library(bayesnet::bayesnet UNKNOWN IMPORTED)
# set_target_properties(bayesnet::bayesnet PROPERTIES
# IMPORTED_LOCATION ${bayesnet}
# INTERFACE_INCLUDE_DIRECTORIES ${Bayesnet_INCLUDE_DIRS}
# )
# endif(USING_VCPKG)
# message(STATUS "BayesNet: ${bayesnet}")
add_executable(bayesnet_sample sample.cc)
target_link_libraries(bayesnet_sample PRIVATE
fimdlp::fimdlp
arff-files::arff-files
"${TORCH_LIBRARIES}"
arff-files::arff-files
torch::torch
bayesnet::bayesnet
folding::folding
nlohmann_json::nlohmann_json
)

View File

@@ -0,0 +1,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"build/CMakePresets.json"
]
}

14
sample/conanfile.txt Normal file
View File

@@ -0,0 +1,14 @@
[requires]
libtorch/2.7.0
arff-files/1.2.0
fimdlp/2.1.0
folding/1.1.1
bayesnet/1.2.0
nlohmann_json/3.11.3
[generators]
CMakeToolchain
CMakeDeps
[options]
libtorch/2.7.0:shared=True

View File

@@ -6,7 +6,7 @@
#include <map>
#include <string>
#include <ArffFiles/ArffFiles.hpp>
#include <ArffFiles.hpp>
#include <fimdlp/CPPFImdlp.h>
#include <bayesnet/classifiers/TANLd.h>
#include <bayesnet/classifiers/KDBLd.h>

View File

@@ -0,0 +1 @@
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/conanbuildenv-release-x86_64.sh"

View File

@@ -0,0 +1,16 @@
script_folder="/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators"
echo "echo Restoring environment" > "$script_folder/deactivate_conanbuildenv-release-x86_64.sh"
for v in PATH
do
is_defined="true"
value=$(printenv $v) || is_defined="" || true
if [ -n "$value" ] || [ -n "$is_defined" ]
then
echo export "$v='$value'" >> "$script_folder/deactivate_conanbuildenv-release-x86_64.sh"
else
echo unset $v >> "$script_folder/deactivate_conanbuildenv-release-x86_64.sh"
fi
done
export PATH="/home/rmontanana/.conan2/p/cmakeab16c849c207b/p/bin:$PATH"

View File

@@ -0,0 +1 @@
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/conanrunenv-release-x86_64.sh"

View File

@@ -0,0 +1,17 @@
script_folder="/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators"
echo "echo Restoring environment" > "$script_folder/deactivate_conanrunenv-release-x86_64.sh"
for v in LD_LIBRARY_PATH DYLD_LIBRARY_PATH
do
is_defined="true"
value=$(printenv $v) || is_defined="" || true
if [ -n "$value" ] || [ -n "$is_defined" ]
then
echo export "$v='$value'" >> "$script_folder/deactivate_conanrunenv-release-x86_64.sh"
else
echo unset $v >> "$script_folder/deactivate_conanrunenv-release-x86_64.sh"
fi
done
export LD_LIBRARY_PATH="/home/rmontanana/.conan2/p/libto33fc3f5110c64/p/lib:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="/home/rmontanana/.conan2/p/libto33fc3f5110c64/p/lib:$DYLD_LIBRARY_PATH"

View File

@@ -0,0 +1 @@
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/deactivate_conanbuildenv-release-x86_64.sh"

View File

@@ -0,0 +1 @@
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/deactivate_conanrunenv-release-x86_64.sh"

View File

@@ -2,12 +2,13 @@ if(ENABLE_TESTING)
include_directories(
${BayesNet_SOURCE_DIR}
${CMAKE_BINARY_DIR}/configured_files/include
${nlohmann_json_INCLUDE_DIRS}
)
file(GLOB_RECURSE BayesNet_SOURCES "${bayesnet_SOURCE_DIR}/bayesnet/*.cc")
add_executable(TestBayesNet TestBayesNetwork.cc TestBayesNode.cc TestBayesClassifier.cc TestXSPnDE.cc TestXBA2DE.cc
TestBayesModels.cc TestBayesMetrics.cc TestFeatureSelection.cc TestBoostAODE.cc TestXBAODE.cc TestA2DE.cc
TestUtils.cc TestBayesEnsemble.cc TestModulesVersions.cc TestBoostA2DE.cc TestMST.cc TestXSPODE.cc ${BayesNet_SOURCES})
target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp::fimdlp PRIVATE Catch2::Catch2WithMain)
target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp::fimdlp PRIVATE Catch2::Catch2WithMain folding::folding)
add_test(NAME BayesNetworkTest COMMAND TestBayesNet)
add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]")
add_test(NAME BoostA2DE COMMAND TestBayesNet "[BoostA2DE]")

View File

@@ -11,7 +11,7 @@
#include <vector>
#include <map>
#include <tuple>
#include <ArffFiles/ArffFiles.hpp>
#include <ArffFiles.hpp>
#include <fimdlp/CPPFImdlp.h>
#include <folding.hpp>
#include <bayesnet/network/Network.h>