diff --git a/CMakeLists.txt b/CMakeLists.txt index 327f09b..f8a3a0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") 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) # CMakes modules # -------------- @@ -76,3 +77,12 @@ if (ENABLE_TESTING) include(CTest) add_subdirectory(tests) endif (ENABLE_TESTING) + +# Installation +# ------------ +install(TARGETS BayesNet + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + CONFIGURATIONS Release) +install(DIRECTORY src/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h") +install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/config.h DESTINATION include/bayesnet CONFIGURATIONS Release) \ No newline at end of file diff --git a/Makefile b/Makefile index d376787..dfa0e9f 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,11 @@ clean: ## Clean the tests info $(call ClearTests) @echo ">>> Done"; +install: ## Install library + @echo ">>> Installing BayesNet..."; + @cmake --install $(f_release) + @echo ">>> Done"; + debug: ## Build a debug version of the project @echo ">>> Building Debug BayesNet..."; @if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi diff --git a/lib/catch2 b/lib/catch2 index ed6ac8a..8ac8190 160000 --- a/lib/catch2 +++ b/lib/catch2 @@ -1 +1 @@ -Subproject commit ed6ac8a629f9a4206575be784c1e340da2a94855 +Subproject commit 8ac8190e494a381072c89f5e161b92a08d98b37b diff --git a/sample/sample.cc b/sample/sample.cc index 54b8639..89902af 100644 --- a/sample/sample.cc +++ b/sample/sample.cc @@ -1,6 +1,6 @@ -#include "ArffFiles.h" -#include "CPPFImdlp.h" -#include "BoostAODE.h" +#include +#include +#include "ensembles/BoostAODE.h" std::vector discretizeDataset(std::vector& X, mdlp::labels_t& y) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e798319..024362c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,15 +4,10 @@ include_directories( ${BayesNet_SOURCE_DIR}/lib/folding ${BayesNet_SOURCE_DIR}/lib/json/include ${BayesNet_SOURCE_DIR}/src - ${BayesNet_SOURCE_DIR}/src/feature_selection - ${BayesNet_SOURCE_DIR}/src/bayesian_network - ${BayesNet_SOURCE_DIR}/src/classifiers - ${BayesNet_SOURCE_DIR}/src/ensembles - ${BayesNet_SOURCE_DIR}/src/utils ${CMAKE_BINARY_DIR}/configured_files/include ) file(GLOB_RECURSE Sources "*.cc") add_library(BayesNet ${Sources}) -target_link_libraries(BayesNet mdlp "${TORCH_LIBRARIES}") \ No newline at end of file +target_link_libraries(BayesNet mdlp "${TORCH_LIBRARIES}") diff --git a/src/bayesian_network/Network.cc b/src/bayesian_network/Network.cc index 0357ba6..6e7e8f1 100644 --- a/src/bayesian_network/Network.cc +++ b/src/bayesian_network/Network.cc @@ -1,7 +1,7 @@ #include #include #include "Network.h" -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { Network::Network() : features(std::vector()), className(""), classNumStates(0), fitted(false), laplaceSmoothing(0) {} Network::Network(float maxT) : features(std::vector()), className(""), classNumStates(0), maxThreads(maxT), fitted(false), laplaceSmoothing(0) {} diff --git a/src/classifiers/Classifier.cc b/src/classifiers/Classifier.cc index ba63753..10a5b2d 100644 --- a/src/classifiers/Classifier.cc +++ b/src/classifiers/Classifier.cc @@ -1,5 +1,5 @@ #include "Classifier.h" -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {} diff --git a/src/classifiers/Classifier.h b/src/classifiers/Classifier.h index 2c43533..103ad7c 100644 --- a/src/classifiers/Classifier.h +++ b/src/classifiers/Classifier.h @@ -2,8 +2,8 @@ #define CLASSIFIER_H #include #include "BaseClassifier.h" -#include "Network.h" -#include "BayesMetrics.h" +#include "bayesian_network/Network.h" +#include "utils/BayesMetrics.h" namespace bayesnet { class Classifier : public BaseClassifier { diff --git a/src/classifiers/KDB.h b/src/classifiers/KDB.h index 95fb315..166803a 100644 --- a/src/classifiers/KDB.h +++ b/src/classifiers/KDB.h @@ -2,7 +2,7 @@ #define KDB_H #include #include "Classifier.h" -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { class KDB : public Classifier { private: diff --git a/src/classifiers/Proposal.h b/src/classifiers/Proposal.h index 6c4872c..3686db9 100644 --- a/src/classifiers/Proposal.h +++ b/src/classifiers/Proposal.h @@ -3,7 +3,7 @@ #include #include #include -#include "Network.h" +#include "bayesian_network/Network.h" #include "CPPFImdlp.h" #include "Classifier.h" diff --git a/src/ensembles/AODE.h b/src/ensembles/AODE.h index b8bec94..592b1e8 100644 --- a/src/ensembles/AODE.h +++ b/src/ensembles/AODE.h @@ -1,7 +1,7 @@ #ifndef AODE_H #define AODE_H #include "Ensemble.h" -#include "SPODE.h" +#include "classifiers/SPODE.h" namespace bayesnet { class AODE : public Ensemble { public: diff --git a/src/ensembles/AODELd.h b/src/ensembles/AODELd.h index dd8f29f..b8d2fe3 100644 --- a/src/ensembles/AODELd.h +++ b/src/ensembles/AODELd.h @@ -1,8 +1,8 @@ #ifndef AODELD_H #define AODELD_H #include "Ensemble.h" -#include "Proposal.h" -#include "SPODELd.h" +#include "classifiers/Proposal.h" +#include "classifiers/SPODELd.h" namespace bayesnet { class AODELd : public Ensemble, public Proposal { diff --git a/src/ensembles/BoostAODE.cc b/src/ensembles/BoostAODE.cc index 6ccd775..202b02c 100644 --- a/src/ensembles/BoostAODE.cc +++ b/src/ensembles/BoostAODE.cc @@ -2,11 +2,11 @@ #include #include #include +#include #include "BoostAODE.h" -#include "CFS.h" -#include "FCBF.h" -#include "IWSS.h" -#include "folding.hpp" +#include "feature_selection/CFS.h" +#include "feature_selection/FCBF.h" +#include "feature_selection/IWSS.h" namespace bayesnet { struct { diff --git a/src/ensembles/BoostAODE.h b/src/ensembles/BoostAODE.h index c58bc3e..e21b38a 100644 --- a/src/ensembles/BoostAODE.h +++ b/src/ensembles/BoostAODE.h @@ -2,8 +2,8 @@ #define BOOSTAODE_H #include "Ensemble.h" #include -#include "SPODE.h" -#include "FeatureSelect.h" +#include "classifiers/SPODE.h" +#include "feature_selection/FeatureSelect.h" namespace bayesnet { class BoostAODE : public Ensemble { public: diff --git a/src/ensembles/Ensemble.h b/src/ensembles/Ensemble.h index cd42cee..cf021ae 100644 --- a/src/ensembles/Ensemble.h +++ b/src/ensembles/Ensemble.h @@ -1,9 +1,9 @@ #ifndef ENSEMBLE_H #define ENSEMBLE_H #include -#include "Classifier.h" -#include "BayesMetrics.h" -#include "bayesnetUtils.h" +#include "classifiers/Classifier.h" +#include "utils/BayesMetrics.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { class Ensemble : public Classifier { diff --git a/src/feature_selection/CFS.cc b/src/feature_selection/CFS.cc index 24a489f..b17b4f2 100644 --- a/src/feature_selection/CFS.cc +++ b/src/feature_selection/CFS.cc @@ -1,6 +1,6 @@ #include "CFS.h" #include -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { void CFS::fit() { diff --git a/src/feature_selection/CFS.h b/src/feature_selection/CFS.h index 154ba55..5b718f3 100644 --- a/src/feature_selection/CFS.h +++ b/src/feature_selection/CFS.h @@ -2,7 +2,7 @@ #define CFS_H #include #include -#include "FeatureSelect.h" +#include "feature_selection/FeatureSelect.h" namespace bayesnet { class CFS : public FeatureSelect { public: diff --git a/src/feature_selection/FCBF.cc b/src/feature_selection/FCBF.cc index f92c593..1e37722 100644 --- a/src/feature_selection/FCBF.cc +++ b/src/feature_selection/FCBF.cc @@ -1,4 +1,4 @@ -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" #include "FCBF.h" namespace bayesnet { diff --git a/src/feature_selection/FCBF.h b/src/feature_selection/FCBF.h index 1b30cba..c323664 100644 --- a/src/feature_selection/FCBF.h +++ b/src/feature_selection/FCBF.h @@ -2,7 +2,7 @@ #define FCBF_H #include #include -#include "FeatureSelect.h" +#include "feature_selection/FeatureSelect.h" namespace bayesnet { class FCBF : public FeatureSelect { public: diff --git a/src/feature_selection/FeatureSelect.cc b/src/feature_selection/FeatureSelect.cc index fba1228..29c0643 100644 --- a/src/feature_selection/FeatureSelect.cc +++ b/src/feature_selection/FeatureSelect.cc @@ -1,6 +1,6 @@ #include "FeatureSelect.h" #include -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { FeatureSelect::FeatureSelect(const torch::Tensor& samples, const std::vector& features, const std::string& className, const int maxFeatures, const int classNumStates, const torch::Tensor& weights) : Metrics(samples, features, className, classNumStates), maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures), weights(weights) diff --git a/src/feature_selection/FeatureSelect.h b/src/feature_selection/FeatureSelect.h index d5c56ed..a697dd7 100644 --- a/src/feature_selection/FeatureSelect.h +++ b/src/feature_selection/FeatureSelect.h @@ -2,7 +2,7 @@ #define FEATURE_SELECT_H #include #include -#include "BayesMetrics.h" +#include "utils/BayesMetrics.h" namespace bayesnet { class FeatureSelect : public Metrics { public: diff --git a/src/feature_selection/IWSS.cc b/src/feature_selection/IWSS.cc index e63bf6b..80cd89e 100644 --- a/src/feature_selection/IWSS.cc +++ b/src/feature_selection/IWSS.cc @@ -1,6 +1,6 @@ #include "IWSS.h" #include -#include "bayesnetUtils.h" +#include "utils/bayesnetUtils.h" namespace bayesnet { IWSS::IWSS(const torch::Tensor& samples, const std::vector& features, const std::string& className, const int maxFeatures, const int classNumStates, const torch::Tensor& weights, const double threshold) : FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights), threshold(threshold)