/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include "../../problems/eval/oneMaxEval.h" using EOT = eoBit; int main(int /*argc*/, char** /*argv*/) { size_t dim = 100; size_t pop_size = 10; oneMaxEval evalfunc; eoPopLoopEval eval(evalfunc); eoBooleanGenerator gen(0.5); eoInitFixedLength init(dim, gen); double cross_rate = 0.5; eoSequentialSelect select_cross; eoUBitXover crossover; eoRandomSelect select_aftercross; double mut_rate = 0.5; eoSequentialSelect select_mut; eoStandardBitMutation mutation(0.5); eoPlusReplacement replacement; eoGenContinue common_cont(dim*2); eoCombinedContinue gen_cont(common_cont); eoFastGA algo( cross_rate, select_cross, crossover, select_aftercross, mut_rate, select_mut, mutation, eval, replacement, common_cont ); eoPop pop; pop.append(pop_size, init); eval(pop,pop); algo(pop); std::cout << pop.best_element() << std::endl; }