Skip to content

Latest commit

 

History

History
147 lines (110 loc) · 4.15 KB

README.md

File metadata and controls

147 lines (110 loc) · 4.15 KB

Moe

license

GCC / Clang (Linux) VS 14/15 (Win 32/64) Coverage (g++5)
Travis branch AppVeyor branch Codecov branch

Moe is a C++14 header-only dependency-free library providing generic implementations of some metaheuristic algorithms

Quick Overview

The main goal of Moe is to provide a generic and easy way to implement fast solving systems from any complexity with C++.

Moe stands for Maybe Overpowered Entity, but isn't limited to it.

Moe gives a way for the user to completely define the behavior of algorithms, all parameters are adjustable, and the structure allows to easily add features or custom Mutations/Crossover/Algorithms.

Take a look at a base sample using Moe (examples/square_root.cpp):

This example illustrates how Differential Evolution can be used to search for the square root of a number (in this case 2261953600), the known answer is 47560.

#include <moe/moe.hpp>
#include <iostream>
#include <string>

int main()
{
    DifferentialEvolution<int> moether(20);

    long long n = 2261953600;

    moether.setFitnessFunction( [n](auto moe) -> double
    {
        long long genotype = moe.genotype[0];
                
        double error = std::abs(n - genotype*genotype);

        return 1/(error+1);
    });

    moether.run( 50 );  // run 50 generations

    long long genotype = moether.getBestMoe().genotype[0];

    std::cout   << "genotype: "     << genotype << "\n"
                << "fitness: "      << moether.getBestMoe().fitness << std::endl;
}

Examples

Examples can be found here

Features

Moe contains the following features:

  • Algorithms:

    • Genetic Algorithm
      • Crossovers:
        • One Point
        • Two Point
        • Uniform
      • Mutations:
        • Substitution
        • Insertion
        • Deletion
        • Translocation
    • Differential Evolution
    • Particle Swarm Optimization
      • Abstract Classes
  • Planned:

    • Performance:
      • Parallel Implementation
    • Better Parameters handling
      • Serialization

How To Use

Add the "include" folder to your include paths and write

#include <moe/moe.hpp>

and you're ready to go !

Building

Moe uses CMake, options are available:

Options Description Default Value
BUILD_EXAMPLES Builds Examples ON
BUILD_TESTS Builds Catch Unit Tests OFF
DEBUG Enables debugging symbols OFF

Moe is successfully tested against:

  • GCC:
    • 5 (5.4.1)
    • 6 (6.2)
    • MinGW:
      • GCC 5.3
  • Clang:
    • 3.6 (3.6.2)
    • 3.7 (3.7.1)
    • 3.8 (3.8.0)
    • 3.9 (3.9.1)
  • MSVC:
    • Visual Studio 14 2015
    • Visual Studio 15 2017

Moe does not compile anymore on GCC 4.9

Compiling:

The following clone Moe and generates with CMake

git clone https://github.com/tonykero/Moe.git
cd Moe
mkdir build && cd build && cmake ..

then under linux

make

or

cmake --build .

or (if with MSVC, and -DDEBUG=1 was not specified)

cmake --build . --config Release

Contributing

Please read Contributing

License

The MIT License

Note: 'tests' folder contains catch.hpp which comes from https://github.com/philsquared/Catch and is licensed under the Boost Software License terms.