00001 /* 00002 The Evolving Distribution Objects framework (EDO) is a template-based, 00003 ANSI-C++ evolutionary computation library which helps you to write your 00004 own estimation of distribution algorithms. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 00020 Copyright (C) 2010 Thales group 00021 */ 00022 /* 00023 Authors: 00024 Johann Dréo <johann.dreo@thalesgroup.com> 00025 */ 00026 00027 #define _USE_MATH_DEFINES 00028 #include <math.h> 00029 00030 #include <eo> 00031 #include <edo> 00032 #include <es.h> 00033 00034 typedef eoReal< eoMinimizingFitness > EOT; 00035 00036 int main(void) 00037 { 00038 EOT sol; 00039 sol.push_back( M_PI * 1 ); 00040 sol.push_back( M_PI * 2 ); 00041 sol.push_back( M_PI * 3 ); 00042 sol.push_back( M_PI * 4 ); 00043 sol.push_back( M_PI * 4 + M_PI / 2 ); 00044 sol.push_back( M_PI * 5 + M_PI / 2 ); 00045 // we expect {pi,0,pi,0,pi/2,pi+pi/2} 00046 std::cout << "expect: INVALID 4 3.14159 0 3.14159 0 1.5708 4.71239" << std::endl; 00047 00048 edoRepairer<EOT>* repare = new edoRepairerModulo<EOT>( 2 * M_PI ); // modulo 2pi 00049 00050 (*repare)(sol); 00051 00052 std::cout << sol << std::endl; 00053 00054 return 0; 00055 }