Go to file
Brett 88957ce805 little bit more docs 2025-01-28 15:25:47 -05:00
.github/workflows Update cmake-multi-platform.yml 2024-08-10 17:06:05 -04:00
.idea fixed one bug, pretty sure there are more 2025-01-20 17:08:46 -05:00
datasets moving changes 2025-01-10 18:59:58 -05:00
examples little bit more docs 2025-01-28 15:25:47 -05:00
include/blt/gp fix copy op, change selection behaviour 2025-01-21 21:20:16 -05:00
lib fix copy op, change selection behaviour 2025-01-21 21:20:16 -05:00
src fix copy op, change selection behaviour 2025-01-21 21:20:16 -05:00
tests trying to track down where github is saying there is an error 2025-01-28 11:22:25 -05:00
.gitignore finally push changes 2025-01-13 15:58:06 -05:00
.gitmodules init commit 2024-06-01 14:02:46 -04:00
CMakeLists.txt little bit more docs 2025-01-28 15:25:47 -05:00
LICENSE Create LICENSE 2024-10-04 15:10:57 -04:00
README.md moving changes 2025-01-10 18:59:58 -05:00
Rice_Cammeo_Osmancik.arff finally push changes 2025-01-13 15:58:06 -05:00
commit.py init commit 2024-06-01 14:02:46 -04:00
test_perf.sh i think this works now 2024-08-21 00:54:39 -04:00
test_perf_clang.sh i think this works now 2024-08-21 00:54:39 -04:00
test_perf_minsize_clang.sh i think this works now 2024-08-21 00:54:39 -04:00

README.md

blt-gp

Genetic Programming (GP) library for C++. Integrates directly into the C++ type system, a safe replacement for lilgp without performance compromises.

Easy to use and safe, without compromise

Using blt-gp is very easy, import the program header, define your operators, and then call the relevant functions to set up the program to your liking. Concrete examples can be found in the example folder and compiled using the CMake argument -DBUILD_EXAMPLES=ON

Operator example:

// Constructor takes an optional string that describes the function of the operator. Used in printing.
blt::gp::operation_t add([](float a, float b) {
  return a + b;
}, "add");

Operators can return different types or have differing types as arguments, this will automatically be recognized by the library.

// Any callable type can be passed as the function parameter
// so long as the function exists for the lifetime of the gp_program object.
bool compare_impl(bool type, float a, float b)
{
  return type ? (a > b) : (a < b);
}


blt::gp::operation_t compare(compare_impl, "compare");

Please note that if a type doesn't have a way to produce a terminal, or doesn't have a way of converting from a type that has a terminal, you will get an error.

Defining your fitness function is just as easy:

const auto fitness_function = [](blt::gp::tree_t& current_tree, blt::gp::fitness_t& fitness, blt::size_t current_index) {
    // Evaluate your fitness
    // ...
    // Write to the fitness out parameter. Only "adjusted_fitness" is used during evaluation.
    fitness.raw_fitness = static_cast<double>(fitness.hits);
    fitness.standardized_fitness = fitness.raw_fitness;
    // Higher values = better. Should be bounded [0, 1]
    fitness.adjusted_fitness = 1.0 - (1.0 / (1.0 + fitness.standardized_fitness));
    // returning true from this function ends the evaluation of the program, as this signals that a valid solution was found.
    // This function is allowed to return void.
    return static_cast<blt::size_t>(fitness.hits) == training_cases.size();
};

Performance

Bibliography

Rice (Cammeo and Osmancik) [Dataset]. (2019). UCI Machine Learning Repository. https://doi.org/10.24432/C5MW4Z.