Compare commits

..

3 Commits

5 changed files with 41 additions and 54 deletions

View File

@@ -9,17 +9,14 @@ BayesNet is a C++ library implementing Bayesian Network Classifiers. It provides
## Build System & Dependencies
### Dependency Management
The project supports **two package managers**:
#### vcpkg (Default)
- Uses vcpkg with private registry at <https://github.com/rmontanana/vcpkg-stash>
- Uses vcpkg with private registry at https://github.com/rmontanana/vcpkg-stash
- Core dependencies: libtorch, nlohmann-json, folding, fimdlp, arff-files, catch2
- All dependencies defined in `vcpkg.json` with version overrides
#### Conan (Alternative)
- Modern C++ package manager with better dependency resolution
- Configured via `conanfile.py` for packaging and distribution
- Supports subset of dependencies (libtorch, nlohmann-json, catch2)
@@ -28,7 +25,6 @@ The project supports **two package managers**:
### Build Commands
#### Using vcpkg (Default)
```bash
# Initialize dependencies
make init
@@ -53,7 +49,6 @@ make clean
```
#### Using Conan
```bash
# Install Conan first: pip install conan
@@ -79,7 +74,6 @@ make conan-clean
```
### CMake Configuration
- Uses CMake 3.27+ with C++17 standard
- Debug builds automatically enable testing and coverage
- Release builds optimize with `-Ofast`
@@ -95,7 +89,6 @@ make conan-clean
- Coverage reporting with lcov/genhtml
### Test Categories
- A2DE, BoostA2DE, BoostAODE, XSPODE, XSPnDE, XBAODE, XBA2DE
- Classifier, Ensemble, FeatureSelection, Metrics, Models
- Network, Node, MST, Modules
@@ -103,7 +96,6 @@ make conan-clean
## Code Architecture
### Core Structure
```
bayesnet/
├── BaseClassifier.h # Abstract base for all classifiers
@@ -115,14 +107,12 @@ bayesnet/
```
### Key Design Patterns
- **BaseClassifier** abstract interface for all algorithms
- Template-based design with both std::vector and torch::Tensor support
- Network/Node abstraction for Bayesian network representation
- Feature selection as separate, composable modules
### Data Handling
- Supports both discrete integer data and continuous data with discretization
- ARFF file format support through arff-files library
- Tensor operations via PyTorch C++ (libtorch)
@@ -138,7 +128,6 @@ bayesnet/
## Sample Applications
Sample code in `sample/` directory demonstrates library usage:
```bash
make sample fname=tests/data/iris.arff model=TANLd
```
@@ -146,7 +135,6 @@ make sample fname=tests/data/iris.arff model=TANLd
## Package Distribution
### Creating Conan Packages
```bash
# Create package locally
make conan-create
@@ -160,9 +148,7 @@ make conan-upload remote=myremote profile=myprofile
```
### Using the Library
With Conan:
```python
# conanfile.txt or conanfile.py
[requires]
@@ -173,7 +159,6 @@ cmake
```
With vcpkg:
```json
{
"dependencies": ["bayesnet"]

View File

@@ -18,7 +18,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
endif()
@@ -67,19 +68,18 @@ target_link_libraries(bayesnet
# -------
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE("Debug mode")
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE("Release mode")
set(ENABLE_TESTING ON)
set(CODE_COVERAGE ON)
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (ENABLE_TESTING)
MESSAGE(STATUS "Testing enabled")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors")
find_package(Catch2 CONFIG REQUIRED)
find_package(arff-files CONFIG REQUIRED)
enable_testing()
include(CTest)
add_subdirectory(tests)
else(ENABLE_TESTING)
message("Release mode")
endif (ENABLE_TESTING)
# Installation
@@ -99,14 +99,17 @@ configure_package_config_file(
install(TARGETS bayesnet
EXPORT bayesnetTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION lib
CONFIGURATIONS Release)
install(DIRECTORY bayesnet/
DESTINATION include/bayesnet
FILES_MATCHING
CONFIGURATIONS Release
PATTERN "*.h")
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h
DESTINATION include/bayesnet)
DESTINATION include/bayesnet
CONFIGURATIONS Release)
install(EXPORT bayesnetTargets
FILE bayesnetTargets.cmake

View File

@@ -24,15 +24,16 @@ conan profile new default --detect
[generators]
CMakeDeps
CMakeToolchain
```
1. Install dependencies:
2. Install dependencies:
```bash
conan install . --build=missing
```
1. In your CMakeLists.txt:
3. In your CMakeLists.txt:
```cmake
find_package(bayesnet REQUIRED)
@@ -68,8 +69,8 @@ make conan-create
For the custom dependencies, you'll need to create Conan recipes:
1. **folding**: Cross-validation library
1. **fimdlp**: Discretization library
1. **arff-files**: ARFF file format parser
2. **fimdlp**: Discretization library
3. **arff-files**: ARFF file format parser
Contact the maintainer or create custom recipes for these packages.

View File

@@ -1,6 +1,6 @@
SHELL := /bin/bash
.DEFAULT_GOAL := help
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean updatebadge doc doc-install init clean-test conan-debug conan-release conan-create conan-upload conan-clean conan-sample
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean updatebadge doc doc-install init clean-test debug release conan-create conan-upload conan-clean sample
f_release = build_Release
f_debug = build_Debug
@@ -196,8 +196,7 @@ debug: ## Build debug version using Conan
@conan install . \
-s build_type=Debug \
--build=missing \
-of $(f_debug) \
--profile=debug
-of $(f_debug)
@cmake -S . -B $(f_debug) \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_TESTING=ON \
@@ -210,8 +209,7 @@ release: ## Build release version using Conan
@conan install . \
-s build_type=Release \
--build=missing \
-of $(f_debug) \
--profile=release
-of $(f_debug)
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
@mkdir $(f_release)
@conan install . -s build_type=Release --build=missing -of $(f_release)
@@ -220,8 +218,8 @@ release: ## Build release version using Conan
conan-create: ## Create Conan package
@echo ">>> Creating Conan package..."
@conan create . --build=missing -tf "" --profile=release
@conan create . --build=missing -tf "" --profile=debug -o "&:enable_coverage=False" -o "&:enable_testing=False"
@conan create . --build=missing -tf "" --profile=release -tf ""
@conan create . --build=missing -tf "" --profile=debug
@echo ">>> Done"
profile ?= release