OpenCLGA is a python library for running genetic algorithm among Open CL devices, like GPU, CPU, DSP, etc. In the best case, you can run your GA parallelly at all of your Open CL devices which give you the maximum computing power of your machine. In the worse case, which you only have CPU, you still can run the code at parallel CPU mode.
We had implemented OpenCLGA at ocl_ga.py which encapsulate GA follow (population, crossover, mutation, fitness calculation). User could solve their problem by providing the fitness calculation function and run the code.
Please note that OpenCLGA is implemented at Python 3.5 or above. It should work at Python 2.x but it is not guaranteed.
Taiwan Travel example: https://youtu.be/4pqmuV8RkMg
Prerequisite: install PYOPENCL
Option A. Please refer to https://wiki.tiker.net/PyOpenCL to find your OS or
Option B. Install by ourself
Run OpenCLGA examples
- Enter virtual env (optional):
For Windows with MinGW environment.
$> source <NameOfEnv>/Scripts/activate
For Linux/Mac OS X environment.
$> source ./NameOfEnv/bin/activate
Download the code from Github or git clone the repository via the following command.
<NameOfEnv>$> git clone https://github.com/PyOCL/OpenCLGA.git
Execute the code.
<NameOfEnv>$> pip3 install git+git://github.com/PyOCL/OpenCLGA.git <NameOfEnv>$> unzip OpenCLGA-master.zip <NameOfEnv>$> cd OpenCLGA-master <NameOfEnv>$> python3 examples/tsp/simple_tsp.py
NOTE : In external process mode, if "no device" exception happen during create_some_context(), Please set PYOPENCL_CTX=N (N is the device number you want by default) at first.
NOTE : Since we didn't publish this project to pipa. We need to install this project with source, `pip3 install .`.