Go to file
Brett 094fa76b58
Update README.md
2024-10-04 16:32:15 -04:00
.github/workflows Update cmake-multi-platform.yml 2024-08-10 17:06:05 -04:00
.idea fix the tests: 2024-09-12 15:24:27 -04:00
examples fix the tests: 2024-09-12 15:24:27 -04:00
include/blt/gp fix the tests: 2024-09-12 15:24:27 -04:00
lib continue work on new crossover 2024-09-10 15:47:44 -04:00
src fix the tests: 2024-09-12 15:24:27 -04:00
tests fix the tests: 2024-09-12 15:24:27 -04:00
.gitignore adding rice because symbolic regression is too unstable 2024-08-27 16:31:34 -04:00
.gitmodules init commit 2024-06-01 14:02:46 -04:00
CMakeLists.txt fix the tests: 2024-09-12 15:24:27 -04:00
LICENSE Create LICENSE 2024-10-04 15:10:57 -04:00
README.md Update README.md 2024-10-04 16:32:15 -04:00
commit.py init commit 2024-06-01 14:02:46 -04:00
dev_branch.txt need to add threading next! 2024-08-17 02:20:32 -04:00
dhat.out.293761 fix thread issue 2024-09-02 15:41:20 -04:00
main_branch.txt need to add threading next! 2024-08-17 02:20:32 -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
thread_branch.txt silly 2024-08-18 01:28:23 -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