ga/src/galibinitializer.cpp

00001 /********************************************************************************
00002  *  FARSA Genetic Algorithm Library                                             *
00003  *  Copyright (C) 2007-2008 Gianluca Massera <emmegian@yahoo.it>                *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 #include "gaconfig.h"
00021 #include "crossovers/onepoint.h"
00022 #include "evaluations/multitrials.h"
00023 #include "gas/laralga.h"
00024 #include "gas/simplega.h"
00025 #include "gas/parallelga.h"
00026 #include "gas/nsga2.h"
00027 #include "gas/stefanosteadystatega.h"
00028 #include "core/genome.h"
00029 #include "genotypes/realgenotype.h"
00030 #include "genotypes/signedrangegenotype.h"
00031 #include "mutations/flipbit.h"
00032 #include "mutations/randombit.h"
00033 #include "mutations/randomfloat.h"
00034 #include "mutations/gaussianfloat.h"
00035 #include "reproductions/fixedsize.h"
00036 #include "selections/deterministicrank.h"
00037 #include "selections/roulettewheelselection.h"
00038 
00039 // Headers from the utilities library
00040 #include "configurationparameters.h"
00041 #include "parametersettable.h"
00042 #include "factory.h"
00043 #include "logger.h"
00044 
00045 namespace farsa {
00046 
00047 bool initGALib() {
00048     static bool dummy = false;
00049     if ( dummy ) return true;
00050     //--- Init the Factory
00051     Factory::getInstance().registerClass<Crossover>( "Crossover", "ParameterSettableWithConfigureFunction" );
00052     Factory::getInstance().registerClass<OnePoint>( "OnePoint", "Crossover" );
00053 
00054     Factory::getInstance().registerClass<Evaluation>( "Evaluation", "ParameterSettableWithConfigureFunction" );
00055     Factory::getInstance().registerClass<MultiTrials>( "MultiTrials", "Evaluation" );
00056 
00057     Factory::getInstance().registerClass<GeneticAlgo>( "GeneticAlgo", "ParameterSettableWithConfigureFunction" );
00058     Factory::getInstance().registerClass<LaralGA>( "LaralGA", "GeneticAlgo" );
00059     Factory::getInstance().registerClass<SimpleGA>( "SimpleGA", "GeneticAlgo" );
00060     Factory::getInstance().registerClass<ParallelGA>( "ParallelGA", "GeneticAlgo" );
00061     Factory::getInstance().registerClass<NSGA2>( "NSGA2", "GeneticAlgo" );
00062     Factory::getInstance().registerClass<StefanoSteadyStateGA>( "StefanoSteadyStateGA", "GeneticAlgo" );
00063 
00064     Factory::getInstance().registerClass<Genotype>( "Genotype", "ParameterSettableWithConfigureFunction" );
00065     Factory::getInstance().registerClass<DoubleGenotype>( "DoubleGenotype", "Genotype" );
00066     Factory::getInstance().registerClass<RealGenotype>( "RealGenotype", "DoubleGenotype" );
00067     Factory::getInstance().registerClass<SignedRangeGenotype>( "SignedRangeGenotype", "DoubleGenotype" );
00068 
00069     Factory::getInstance().registerClass<Genome>( "Genome", "ParameterSettableWithConfigureFunction" );
00070 
00071     Factory::getInstance().registerClass<Mutation>( "Mutation", "ParameterSettableWithConfigureFunction" );
00072     Factory::getInstance().registerClass<FlipBit>( "FlipBit", "Mutation" );
00073     Factory::getInstance().registerClass<RandomBit>( "RandomBit", "Mutation" );
00074     Factory::getInstance().registerClass<RandomFloat>( "RandomFloat", "Mutation" );
00075     Factory::getInstance().registerClass<GaussianFloat>( "GaussianFloat", "Mutation" );
00076 
00077     Factory::getInstance().registerClass<Reproduction>( "Reproduction", "ParameterSettableWithConfigureFunction" );
00078     Factory::getInstance().registerClass<FixedSize>( "FixedSize", "Reproduction" );
00079 
00080     Factory::getInstance().registerClass<Selection>( "Selection", "ParameterSettableWithConfigureFunction" );
00081     Factory::getInstance().registerClass<DeterministicRank>( "DeterministicRank", "Selection" );
00082     Factory::getInstance().registerClass<RouletteWheelSelection>( "RouletteWheelSelection", "Selection" );
00083 
00084     dummy = true;
00085     Logger::info( "Library GA initialized" );
00086     return true;
00087 }
00088 
00089 } // end namespace farsa