Recently, I am studying the use of genetic algorithm for my research studies. After a quick search for C++ API on the Internet, I can identify
GALib and
Evolving Objects (EO), which seems to be a good start to study how it works.
Setting up the GALib is simple that requires downloading the code and add it to a IDE. And I can run the code without much problem. GALib is also well-documented. However, it does not support Estimation of Distribution Algorithm (EDA) which EO does. For EO, it takes me two days to figure out how to compile and run the build-in examples. Simply because I don't know CMake and EO requires it for building the program, while I cannot find any useful information on the Internet for setting up the EO on Windows platform. That's why I write this blog to record the procedure to setting up EO on Windows.
I am using Windows 7 Home and NetBeans 7.3.1 (on Java SE 1.6). To start, I have installed the following compiler and Make Tool.
- Cygwin 4.7.3 (includes gcc, g++ and GNU assembler, GNU Make and GNU Debugger)
- CMake Tool 2.8.4
The following is step-by-step procedure and I also recommend to read the
FAQ in the EO website before start.
1. Use the GIT tools in NetBeans to clone the code using the following link.
git://eodev.git.sourceforge.net/gitroot/eodev/eodev
2. Select EO1.3.1 only from the list of remote branches. Click Next and enter d:\ as parent directory and specify "eodev" as clone name. Then, click Finish and wait until the source code populated in the d:\eodev directory.
3. After completion of the cloning, Netbeans will ask for creating a new project. Then, choose create C/C++ project using existing sources, specify folder containing the sources, tool collection and configuration model you prefer. Choose custom mode and click Next.
4. Then you will see the following build tools configuration.The CMakeLists.txt is important that tells how to generate the Makefile for later compiling. Just leave all the items unchanged and click Next.
5. Specify the working directory and build/clean command, then click Next.
6. Specify the source directory and click Next
7. Specify automatic configuration for the code assistance settings
8. Finally, specify the project name and click Finish.
9. A new project is added to the projects explorer and Netbeans will try to build the software. However, it will return the following error messages telling it cannot identify the C and C++ compilers. As you may see all the backslashes are missing in the location name.
10. To build the code, it requires two files:CMakeLists.txt and Makefiles. CMakeLists.txt is located under the EO directory, i.e. d:\eodev\eo. Try to modify the following lines in the file and save it.
- Uncomment the following line
#cmake_minimum_required(VERSION 2.8)
- Add the following lines under ADD_SUBDIRECTORY(tutorial) so that all the lesson codes are included during the build:
ADD_SUBDIRECTORY(tutorial/lesson1)
ADD_SUBDIRECTORY(tutorial/lesson2)
ADD_SUBDIRECTORY(tutorial/lesson3)
ADD_SUBDIRECTORY(tutorial/lesson4)
ADD_SUBDIRECTORY(tutorial/lesson5)
ADD_SUBDIRECTORY(tutorial/lession6)
11. Start the CMake GUI, specify d:/eodev/eo as the location of source code and location to build the binaries. Clear the cache by clicking File>Delete Cache.
12. Click "Configure" and a window will be displayed asking for generator, select "Unix Makefiles" and select "Specify Native Compilers". Enter C:/cygwin/bin/g++.exe for C++ and C:/cygwin/bin/gcc.exe for C.
13. Click Advanced to see all the variables. In particular, specify the followings
CMAKE_BUILD_TYPE = debug
CMAKE_CXX_COMPILER = C:/cygwin/bin/g++.exe
CMAKE_CXX_COMPILER_WITH_PATH = C:/cygwin/bin/g++.exe
CMAKE_C_COMPILER = C:/cygwin/bin/gcc.exe
CMAKE_C_COMPILER_WITH_PATH = C:/cygwin/bin/gcc.exe
CMAKE_RC_COMPILER= c:/cygwin/bin/
windres.exe
CMAKE_RC_COMPILER_ENV_VAR = c:/cygwin/bin/
windres.exe
CMAKE_CXX_FLAGS =
CMAKE_CXX_FLAGS_RELWITHDEBINFO= -O2 -g
CMAKE_CXX_FLAGS_RELEASE=-O2
CMAKE_CXX_FLAGS_DEBUG=-O0 -g
Then click "Configure". If everything okay, "Configuring done" will be displayed. Further click "Generate" to create the makefile.
14. Back to Netbeans, click "Clean and Build" to start the building process.
15. During the building process, the following errors are encountered.
D:/eodev/eo/tutorial/Lesson2/FirstBitEA.cpp:128:40: error: no matching function for call to ‘eoPropCombinedQuadOp >::add(eoNPtsBitXover >&, const double&, bool)’
D:/eodev/eo/tutorial/Lesson2/FirstBitEA.cpp:128:40: note: candidate is:
In file included from D:/eodev/eo/src/eo:63:0,
from D:/eodev/eo/tutorial/Lesson2/FirstBitEA.cpp:18:
D:/eodev/eo/src/eoProportionalCombinedOp.h:202:16: note: void eoPropCombinedQuadOp::add(eoQuadOp&, double) [with EOT = eoBit]
D:/eodev/eo/src/eoProportionalCombinedOp.h:202:16: note: candidate expects 2 arguments, 3 provided
This refers to line 128 of FirstBitEA.cpp that the eoPropCombinedQuadOp.add function accepts two arguments only, but 3 are found. Just remove the third argument. Similar error can be found in FirstRealEA.cpp line 125 and other files.
16. This completes the settings and you can start to explore the example codes.