Skip to content

Python interface to the CMA-ES and MOCMA-ES of the SHARK ML library

Notifications You must be signed in to change notification settings

jduerholt/pyshark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyshark

This project tries to provide a Python scripting interface for the CMA-ES and MO-CMA-ES algorithms implemented in the SHARK ML library. Its purpose is to create a simple python interface to the MO-CMA-ES algorithm. For more elaborate solutions have a look at the DEAP or chocolate project. The wrapper for the single-objective CMA-ES algorithm has been implemented for didactic purposes. For production calculations using Python I recommend the implementation by Nikolaus Hansen.

Getting Started

Prerequisites

In order to use this wrapper you have to have a working Shark installation. Please make sure, that Shark is build as shared library. This wrapper has only been tested with Shark release 3.1.4. In addition at least Python 2.7, including numpy and ctypes are needed. If you want to use the provided example for the MO-CMA-ES algorithm the optproblems package has to be installed.

Installation

In order to install the code follow the following steps:

git clone https://github.com/jduerholt/pyshark.git
cd pyshark
mkdir build
cd build
cmake "-DShark_DIR=/PATH/TO/SHARK" ../src/.
make
cd ../pyshark
ln -s ../build/libsharkwrapper .

In addition, make sure that the pyshark directory is in the PYTHONPATH.

Using the code

Two examples showing how to use the code are given in the examples subdirectory.

CMA-ES

The file cma.py use CMA-ES to optimize a three dimensional sphere function. Run the example by the help of the following command:

python cma.py

At the end it will print the final solution after 500 iterations.

MO-CMA-ES

The file mocma.py uses the multi-objective variant of CMA-ES to optimize the DTLZ2 objective function in dimension three using two objectives. The example can be run by executing the following command:

python mocma.py

At the end it will print the solutions after 2500 iterations. In addition a file called pareto.dat is created holding the values of the optimal solutions.

Acknowledgments

  • Prof. Tobias Glasmachers for a great lecture on Evolutionary Algorithms and for initial help with wrapping Shark.

About

Python interface to the CMA-ES and MOCMA-ES of the SHARK ML library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published