t-dispatcher-round.cpp
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     Pierre Savéant <pierre.saveant@thalesgroup.com>
00026 */
00027 
00028 #include <eo>
00029 #include <edo>
00030 #include <es.h>
00031 
00032 typedef eoReal< eoMinimizingFitness > EOT;
00033 
00034 int main(void)
00035 {
00036     EOT sol;
00037     sol.push_back(1.1);
00038     sol.push_back(1.1);
00039     sol.push_back(3.9);
00040     sol.push_back(3.9);
00041     sol.push_back(5.4);
00042     sol.push_back(5.6);
00043     sol.push_back(7.011);
00044     sol.push_back(8.09);
00045     sol.push_back(8.21);
00046     
00047     std::cout << "expect: INVALID  9 1 2 3 4 5 6 7 8.1 8.2" << std::endl;
00048 
00049     edoRepairer<EOT>* rep1 = new edoRepairerFloor<EOT>();
00050     edoRepairer<EOT>* rep2 = new edoRepairerCeil<EOT>();
00051     edoRepairer<EOT>* rep3 = new edoRepairerRound<EOT>();
00052     edoRepairer<EOT>* rep4 = new edoRepairerRoundDecimals<EOT>( 10 );
00053 
00054     std::vector<unsigned int> indexes1;
00055     indexes1.push_back(0);
00056     indexes1.push_back(2);
00057 
00058     std::vector<unsigned int> indexes2;
00059     indexes2.push_back(1);
00060     indexes2.push_back(3);
00061 
00062     std::vector<unsigned int> indexes3;
00063     indexes3.push_back(4);
00064     indexes3.push_back(5);
00065 
00066     std::vector<unsigned int> indexes4;
00067     indexes4.push_back(6);
00068     indexes4.push_back(7);
00069     indexes4.push_back(8);
00070 
00071     edoRepairerDispatcher<EOT> repare( indexes1, rep1 );
00072     repare.add( indexes2, rep2 );
00073     repare.add( indexes3, rep3 );
00074     repare.add( indexes4, rep4 );
00075 
00076     repare(sol);
00077 
00078     std::cout << sol << std::endl;
00079 
00080     return 0;
00081 }
 All Classes Functions Variables Typedefs