Option to use BayesNet local or vcpkg in CMakeLists

This commit is contained in:
2025-05-09 19:16:17 +02:00
parent 16b4923851
commit aa19ab6c21
7 changed files with 48 additions and 38 deletions

View File

@@ -22,6 +22,7 @@ set(CMAKE_CXX_FLAGS_DEBUG " ${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O
# Options
# -------
option(BAYESNET_VCPKG_CONFIG "Use vcpkg version of BayesNet" ON)
option(ENABLE_TESTING "Unit testing build" OFF)
option(CODE_COVERAGE "Collect coverage from test library" OFF)
@@ -76,13 +77,32 @@ find_package(folding CONFIG REQUIRED)
find_package(argparse CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS python)
find_package(arff-files CONFIG REQUIRED)
find_package(bayesnet CONFIG REQUIRED)
find_package(ZLIB REQUIRED)
find_library(LIBZIP_LIBRARY NAMES zip)
# BayesNet
# if set to ON it will use the vcpkg version of BayesNet else it will use the locally installed version
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_LIBRARIES=${BayesNet_LIBRARIES}")
message(STATUS "BayesNet_INCLUDE_DIRS=${Bayesnet_INCLUDE_DIRS}")
# PyClassifiers
find_library(PyClassifiers NAMES libPyClassifiers PyClassifiers libPyClassifiers.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
find_path(PyClassifiers_INCLUDE_DIRS REQUIRED NAMES pyclassifiers PATHS ${Platform_SOURCE_DIR}/../lib/include)
message(STATUS "PyClassifiers=${PyClassifiers}")
message(STATUS "PyClassifiers_INCLUDE_DIRS=${PyClassifiers_INCLUDE_DIRS}")

View File

@@ -1,6 +1,6 @@
SHELL := /bin/bash
.DEFAULT_GOAL := help
.PHONY: init clean coverage setup help build test clean debug release buildr buildd install dependency testp testb clang-uml
.PHONY: init clean coverage setup help build test clean debug release buildr buildd install dependency testp testb clang-uml debug_local release_local example
f_release = build_Release
f_debug = build_Debug
@@ -76,18 +76,31 @@ buildr: ## Build the release targets
clang-uml: ## Create uml class and sequence diagrams
clang-uml -p --add-compile-flag -I /usr/lib/gcc/x86_64-redhat-linux/8/include/
debug: ## Build a debug version of the project
debug: ## Build a debug version of the project with BayesNet from vcpkg
@echo ">>> Building Debug Platform...";
@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 -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@cmake -S . -B $(f_debug) -DBAYESNET_VCPKG_CONFIG=ON -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
release: ## Build a Release version of the project
debug_local: ## Build a debug version of the project with BayesNet local
@echo ">>> Building Debug Platform...";
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
@mkdir $(f_debug);
@cmake -S . -B $(f_debug) -DBAYESNET_VCPKG_CONFIG=OFF -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
release: ## Build a Release version of the project with BayesNet from vcpkg
@echo ">>> Building Release Platform...";
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release);
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@cmake -S . -B $(f_release) -DBAYESNET_VCPKG_CONFIG=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
release_local: ## Build a Release version of the project with BayesNet local
@echo ">>> Building Release Platform...";
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release);
@cmake -S . -B $(f_release) -DBAYESNET_VCPKG_CONFIG=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@echo ">>> Done";
opt = ""

View File

@@ -1,23 +0,0 @@
[submodule "lib/catch2"]
path = lib/catch2
main = v2.x
update = merge
url = https://github.com/catchorg/Catch2.git
[submodule "lib/argparse"]
path = lib/argparse
url = https://github.com/p-ranav/argparse
master = master
update = merge
[submodule "lib/json"]
path = lib/json
url = https://github.com/nlohmann/json.git
master = master
update = merge
[submodule "lib/libxlsxwriter"]
path = lib/libxlsxwriter
url = https://github.com/jmcnamara/libxlsxwriter.git
main = main
update = merge
[submodule "lib/folding"]
path = lib/folding
url = https://github.com/rmontanana/Folding

Submodule lib/argparse deleted from cbd9fd8ed6

Submodule lib/mdlp deleted from cfb993f5ec

View File

@@ -5,7 +5,6 @@ include_directories(
${TORCH_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/configured_files/include
${PyClassifiers_INCLUDE_DIRS}
${Bayesnet_INCLUDE_DIRS}
## Platform
${Platform_SOURCE_DIR}/src
${Platform_SOURCE_DIR}/results
@@ -35,7 +34,7 @@ add_executable(b_grid commands/b_grid.cpp ${grid_sources}
experimental_clfs/XA1DE.cpp
experimental_clfs/ExpClf.cpp
)
target_link_libraries(b_grid ${MPI_CXX_LIBRARIES} "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy)
target_link_libraries(b_grid ${MPI_CXX_LIBRARIES} "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy)
# b_list
add_executable(b_list commands/b_list.cpp
@@ -46,7 +45,7 @@ add_executable(b_list commands/b_list.cpp
experimental_clfs/XA1DE.cpp
experimental_clfs/ExpClf.cpp
)
target_link_libraries(b_list "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy "${XLSXWRITER_LIB}")
target_link_libraries(b_list "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy "${XLSXWRITER_LIB}")
# b_main
set(main_sources Experiment.cpp Models.cpp HyperParameters.cpp Scores.cpp ArgumentsExperiment.cpp)
@@ -58,7 +57,7 @@ add_executable(b_main commands/b_main.cpp ${main_sources}
experimental_clfs/XA1DE.cpp
experimental_clfs/ExpClf.cpp
)
target_link_libraries(b_main "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy)
target_link_libraries(b_main "${PyClassifiers}" bayesnet::bayesnet fimdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" Boost::python Boost::numpy)
# b_manage
set(manage_sources ManageScreen.cpp OptionsMenu.cpp ResultsManager.cpp)

View File

@@ -262,13 +262,15 @@ namespace platform {
auto y_proba_train = clf->predict_proba(X_train);
Scores scores(y_train, y_proba_train, num_classes, labels);
score_train_value = score == score_t::ACCURACY ? scores.accuracy() : scores.auc();
confusion_matrices_train.push_back(scores.get_confusion_matrix_json(true));
if (discretized)
confusion_matrices_train.push_back(scores.get_confusion_matrix_json(true));
}
//
// Test model
//
if (!quiet)
showProgress(nfold + 1, getColor(clf->getStatus()), "c");
std::cout << "Discretized: " << discretized << " " << score_train_value << std::endl;
test_timer.start();
// auto y_predict = clf->predict(X_test);
auto y_proba_test = clf->predict_proba(X_test);
@@ -277,7 +279,8 @@ namespace platform {
test_time[item] = test_timer.getDuration();
score_train[item] = score_train_value;
score_test[item] = score_test_value;
confusion_matrices.push_back(scores.get_confusion_matrix_json(true));
if (discretized)
confusion_matrices.push_back(scores.get_confusion_matrix_json(true));
if (!quiet)
std::cout << "\b\b\b, " << flush;
//