This commit is contained in:
jmerelo 1999-12-17 09:19:13 +00:00
commit d3642e4fde
12 changed files with 397 additions and 207 deletions

View file

@ -4,9 +4,14 @@
## ##
############################################################################### ###############################################################################
SUBDIRS = src test SUBDIRS = src test win
#Directory for documents
DOCDIR = ~/public_html/eodocs DOCDIR = ~/public_html/eodocs
#Directory for indices -- not useful for the user
IDXDIR = ~/index
EXTRA_DIST=LICENSE
docs: docs:
doc++ -d $(DOCDIR) -B foot.html -f src/*.h src/*.cpp doc++ -d $(DOCDIR) -B foot.html -f src/*.h src/*.cpp
/home/jmerelo/bin/index -e html -i /home/jmerelo/index/neweo.idx /home/jmerelo/public_html/eodocs/ -v 3 /home/jmerelo/bin/index -e html -i $(IDXDIR)/neweo.idx $(DOCDIR)/ -v 3

View file

@ -1,11 +1,13 @@
AC_INIT(src/eo) AC_INIT(src/eo)
AM_INIT_AUTOMAKE(eo, 0.0.5) AM_INIT_AUTOMAKE(eo, 0.0.8)
AC_PROG_CXX AC_PROG_CXX
CXXFLAGS=-g
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
AC_OUTPUT(Makefile src/Makefile test/Makefile) AC_OUTPUT(Makefile src/Makefile test/Makefile win/Makefile)

View file

@ -12,11 +12,9 @@
#include <string> // string #include <string> // string
#include <eoVector.h> // EO #include <eoVector.h> // EO
/***************************************************************************** /** eoBin: implementation of binary chromosome.
* eoBin: implementation of binary chromosome. * * based on STL's bit_vector (vector<bool>).
* based on STL's bit_vector (vector<bool>). * */
*****************************************************************************/
template <class F> class eoBin: public eoVector<bool, F> template <class F> class eoBin: public eoVector<bool, F>
{ {
public: public:

View file

@ -31,10 +31,12 @@
#include <eoEvalFunc.h> #include <eoEvalFunc.h>
#include <eoPopOps.h> // eoSelect, eoTranform, eoMerge #include <eoPopOps.h> // eoSelect, eoTranform, eoMerge
//-----------------------------------------------------------------------------
// eoGeneration
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** eoGeneration
* Single step of a evolutionary algorithm. Applies selection, then genetic
* operators, replaces using a replacement policy, and finally evaluates the
* new ones */
template<class Chrom> class eoGeneration: public eoAlgo<Chrom> template<class Chrom> class eoGeneration: public eoAlgo<Chrom>
{ {
public: public:

View file

@ -5,6 +5,7 @@
############################################################################### ###############################################################################
DEPS = $(top_builddir)/src/libeo.a DEPS = $(top_builddir)/src/libeo.a
EXTRA_DIST = LICENSE
############################################################################### ###############################################################################
@ -13,7 +14,17 @@ LDADDS = $(top_builddir)/src/libeo.a
############################################################################### ###############################################################################
noinst_PROGRAMS = t-eobreeder t-eoinclusion t-eoinsertion t-eo t-eofitness t-eoproblem t-eobin t-eolottery t-eo2dVector t-eogeneration t-eoEasyEA t-eoNonUniform t-eoUniform t-eoRandom t-parser t-eoESFull t-eoESOps t-eoAtomOps noinst_PROGRAMS = t-eobreeder t-eoinclusion t-eoinsertion t-eo t-eofitness \
t-eoproblem t-eobin t-eolottery t-eo2dVector t-eogeneration t-eoEasyEA\
t-eoNonUniform t-eoUniform t-eoRandom t-parser t-eoESFull t-eoESOps\
t-eoAtomOps t-selectOne
###############################################################################
t_selectOne_SOURCES = t-selectOne.cpp
t_selectOne_DEPENDENCIES = $(DEPS)
t_selectOne_LDFLAGS = -lm
t_selectOne_LDADD = $(LDADDS)
############################################################################### ###############################################################################
@ -73,7 +84,7 @@ t_eoEasyEA_LDADD = $(LDADDS)
############################################################################### ###############################################################################
t_eobreeder_SOURCES = t-eobreeder.cpp t_eobreeder_SOURCES = t-eobreeder.cpp binary_value.h
t_eobreeder_DEPENDENCIES = $(DEPS) t_eobreeder_DEPENDENCIES = $(DEPS)
t_eobreeder_LDFLAGS = -lm t_eobreeder_LDFLAGS = -lm
t_eobreeder_LDADD = $(LDADDS) t_eobreeder_LDADD = $(LDADDS)

View file

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.4a from Makefile.am # Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
@ -49,10 +49,9 @@ AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@ AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@ transform = @program_transform_name@
NORMAL_INSTALL = : NORMAL_INSTALL = :
@ -79,6 +78,7 @@ RANLIB = @RANLIB@
VERSION = @VERSION@ VERSION = @VERSION@
DEPS = $(top_builddir)/src/libeo.a DEPS = $(top_builddir)/src/libeo.a
EXTRA_DIST = LICENSE
############################################################################### ###############################################################################
@ -87,7 +87,15 @@ LDADDS = $(top_builddir)/src/libeo.a
############################################################################### ###############################################################################
noinst_PROGRAMS = t-eobreeder t-eoinclusion t-eoinsertion t-eo t-eofitness t-eoproblem t-eobin t-eolottery t-eo2dVector t-eogeneration t-eoEasyEA t-eoNonUniform t-eoUniform t-eoRandom t-parser t-eoESFull t-eoESOps t-eoAtomOps noinst_PROGRAMS = t-eobreeder t-eoinclusion t-eoinsertion t-eo t-eofitness t-eoproblem t-eobin t-eolottery t-eo2dVector t-eogeneration t-eoEasyEA t-eoNonUniform t-eoUniform t-eoRandom t-parser t-eoESFull t-eoESOps t-eoAtomOps t-selectOne
###############################################################################
t_selectOne_SOURCES = t-selectOne.cpp
t_selectOne_DEPENDENCIES = $(DEPS)
t_selectOne_LDFLAGS = -lm
t_selectOne_LDADD = $(LDADDS)
############################################################################### ###############################################################################
@ -147,7 +155,7 @@ t_eoEasyEA_LDADD = $(LDADDS)
############################################################################### ###############################################################################
t_eobreeder_SOURCES = t-eobreeder.cpp t_eobreeder_SOURCES = t-eobreeder.cpp binary_value.h
t_eobreeder_DEPENDENCIES = $(DEPS) t_eobreeder_DEPENDENCIES = $(DEPS)
t_eobreeder_LDFLAGS = -lm t_eobreeder_LDFLAGS = -lm
t_eobreeder_LDADD = $(LDADDS) t_eobreeder_LDADD = $(LDADDS)
@ -241,6 +249,7 @@ t_parser_OBJECTS = t-parser.o
t_eoESFull_OBJECTS = t-eoESFull.o t_eoESFull_OBJECTS = t-eoESFull.o
t_eoESOps_OBJECTS = t-eoESOps.o t_eoESOps_OBJECTS = t-eoESOps.o
t_eoAtomOps_OBJECTS = t-eoAtomOps.o t_eoAtomOps_OBJECTS = t-eoAtomOps.o
t_selectOne_OBJECTS = t-selectOne.o
CXXFLAGS = @CXXFLAGS@ CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
@ -258,8 +267,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = gtar
GZIP_ENV = --best GZIP_ENV = --best
SOURCES = $(t_eobreeder_SOURCES) $(t_eoinclusion_SOURCES) $(t_eoinsertion_SOURCES) $(t_eo_SOURCES) $(t_eofitness_SOURCES) $(t_eoproblem_SOURCES) $(t_eobin_SOURCES) $(t_eolottery_SOURCES) $(t_eo2dVector_SOURCES) $(t_eogeneration_SOURCES) $(t_eoEasyEA_SOURCES) $(t_eoNonUniform_SOURCES) $(t_eoUniform_SOURCES) $(t_eoRandom_SOURCES) $(t_parser_SOURCES) $(t_eoESFull_SOURCES) $(t_eoESOps_SOURCES) $(t_eoAtomOps_SOURCES) SOURCES = $(t_eobreeder_SOURCES) $(t_eoinclusion_SOURCES) $(t_eoinsertion_SOURCES) $(t_eo_SOURCES) $(t_eofitness_SOURCES) $(t_eoproblem_SOURCES) $(t_eobin_SOURCES) $(t_eolottery_SOURCES) $(t_eo2dVector_SOURCES) $(t_eogeneration_SOURCES) $(t_eoEasyEA_SOURCES) $(t_eoNonUniform_SOURCES) $(t_eoUniform_SOURCES) $(t_eoRandom_SOURCES) $(t_parser_SOURCES) $(t_eoESFull_SOURCES) $(t_eoESOps_SOURCES) $(t_eoAtomOps_SOURCES) $(t_selectOne_SOURCES)
OBJECTS = $(t_eobreeder_OBJECTS) $(t_eoinclusion_OBJECTS) $(t_eoinsertion_OBJECTS) $(t_eo_OBJECTS) $(t_eofitness_OBJECTS) $(t_eoproblem_OBJECTS) $(t_eobin_OBJECTS) $(t_eolottery_OBJECTS) $(t_eo2dVector_OBJECTS) $(t_eogeneration_OBJECTS) $(t_eoEasyEA_OBJECTS) $(t_eoNonUniform_OBJECTS) $(t_eoUniform_OBJECTS) $(t_eoRandom_OBJECTS) $(t_parser_OBJECTS) $(t_eoESFull_OBJECTS) $(t_eoESOps_OBJECTS) $(t_eoAtomOps_OBJECTS) OBJECTS = $(t_eobreeder_OBJECTS) $(t_eoinclusion_OBJECTS) $(t_eoinsertion_OBJECTS) $(t_eo_OBJECTS) $(t_eofitness_OBJECTS) $(t_eoproblem_OBJECTS) $(t_eobin_OBJECTS) $(t_eolottery_OBJECTS) $(t_eo2dVector_OBJECTS) $(t_eogeneration_OBJECTS) $(t_eoEasyEA_OBJECTS) $(t_eoNonUniform_OBJECTS) $(t_eoUniform_OBJECTS) $(t_eoRandom_OBJECTS) $(t_parser_OBJECTS) $(t_eoESFull_OBJECTS) $(t_eoESOps_OBJECTS) $(t_eoAtomOps_OBJECTS) $(t_selectOne_OBJECTS)
all: all-redirect all: all-redirect
.SUFFIXES: .SUFFIXES:
@ -390,6 +399,10 @@ t-eoESOps: $(t_eoESOps_OBJECTS) $(t_eoESOps_DEPENDENCIES)
t-eoAtomOps: $(t_eoAtomOps_OBJECTS) $(t_eoAtomOps_DEPENDENCIES) t-eoAtomOps: $(t_eoAtomOps_OBJECTS) $(t_eoAtomOps_DEPENDENCIES)
@rm -f t-eoAtomOps @rm -f t-eoAtomOps
$(CXXLINK) $(t_eoAtomOps_LDFLAGS) $(t_eoAtomOps_OBJECTS) $(t_eoAtomOps_LDADD) $(LIBS) $(CXXLINK) $(t_eoAtomOps_LDFLAGS) $(t_eoAtomOps_OBJECTS) $(t_eoAtomOps_LDADD) $(LIBS)
t-selectOne: $(t_selectOne_OBJECTS) $(t_selectOne_DEPENDENCIES)
@rm -f t-selectOne
$(CXXLINK) $(t_selectOne_LDFLAGS) $(t_selectOne_OBJECTS) $(t_selectOne_LDADD) $(LIBS)
.cc.o: .cc.o:
$(CXXCOMPILE) -c $< $(CXXCOMPILE) -c $<
.cc.lo: .cc.lo:
@ -436,7 +449,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \ @for file in $(DISTFILES); do \
d=$(srcdir); \ d=$(srcdir); \
if test -d $$d/$$file; then \ if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \ cp -pr $$/$$file $(distdir)/$$file; \
else \ else \
test -f $(distdir)/$$file \ test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@ -465,7 +478,7 @@ uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) all-am: Makefile $(PROGRAMS)
all-redirect: all-am all-redirect: all-am
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs:

View file

@ -1,6 +1,30 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
/*-----------------------------------------------------------------------------
* t-eoRandom
* Testing program for the eoRNG class
* (c) GeNeura Team, 1999
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// t-eouniform
//-----------------------------------------------------------------------------
#include <iostream> // cout #include <iostream> // cout
#include <strstream> // ostrstream, istrstream #include <strstream> // ostrstream, istrstream

View file

@ -1,5 +1,27 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// t-eobin.cpp // t-eobin.cpp
// This program test the the binary cromosomes and several genetic operators
// (c) GeNeura Team, 1999
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <iostream> // cout #include <iostream> // cout
@ -102,7 +124,7 @@ main()
for (float r = 0.1; r < 1.0; r += 0.1) for (float r = 0.1; r < 1.0; r += 0.1)
{ {
eoBinUxOver<Chrom> uxover(r); eoUniformXOver<Chrom> uxover(r);
fill(chrom.begin(), chrom.end(), false); fill(chrom.begin(), chrom.end(), false);
fill(chrom2.begin(), chrom2.end(), true); fill(chrom2.begin(), chrom2.end(), true);
uxover(chrom, chrom2); uxover(chrom, chrom2);
@ -110,6 +132,20 @@ main()
<< chrom << " " << chrom2 << endl; << chrom << " " << chrom2 << endl;
} }
// Check multiOps
eoMultiMonOp<Chrom> mOp( &next );
mOp.adOp( &bitflip );
cout << "before multiMonOp............ " << chrom << endl;
mOp( chrom );
cout << "after multiMonOp .............. " << chrom << endl;
eoBinGxOver<Chrom> gxover(2, 4);
eoMultiBinOp<Chrom> mbOp( &gxover );
mOp.adOp( &bitflip );
cout << "before multiBinOp............ " << chrom << " " << chrom2 << endl;
mbOp( chrom, chrom2 );
cout << "after multiBinOp .............. " << chrom << " " << chrom2 <<endl;
return 0; return 0;
} }

View file

@ -1,5 +1,27 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// t-eobreeder.cpp // t-eobreeder.cpp
// This program test the breeder object
// (c) GeNeura Team, 1998
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// to avoid long name warnings // to avoid long name warnings
@ -15,16 +37,7 @@
typedef eoBin<float> Chrom; typedef eoBin<float> Chrom;
//----------------------------------------------------------------------------- #include "binary_value.h"
void binary_value(Chrom& chrom)
{
float sum = 0;
for (unsigned i = 0; i < chrom.size(); i++)
if (chrom[i])
sum += pow(2, chrom.size() - i - 1);
chrom.fitness(sum);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -2,22 +2,15 @@
// t-eoinclusion.cpp // t-eoinclusion.cpp
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <eo> // eoBin, eoPop, eoInclusion #include <eoBin.h>
#include <eoPop.h>
#include <eoInclusion.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
typedef eoBin<float> Chrom; typedef eoBin<float> Chrom;
//----------------------------------------------------------------------------- #include "binary_value.h"
void binary_value(Chrom& chrom)
{
float sum = 0;
for (unsigned i = 0; i < chrom.size(); i++)
if (chrom[i])
sum += pow(2, chrom.size() - i - 1);
chrom.fitness(sum);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

87
eo/test/t-selectOne.cpp Normal file
View file

@ -0,0 +1,87 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// t-selectOne.cpp
// This program test the breeder object
// (c) GeNeura Team, 1998
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
*/
//-----------------------------------------------------------------------------
// to avoid long name warnings
#pragma warning(disable:4786)
#include <eoBin.h> // eoBin, eoPop, eoBreeder
#include <eoPop.h>
#include <eoBitOp.h>
#include <eoUniformSelect.h>
#include <eoStochTournament.h>
#include <eoDetTournament.h>
//-----------------------------------------------------------------------------
typedef eoBin<float> Chrom;
#include "binary_value.h"
//-----------------------------------------------------------------------------
main()
{
const unsigned POP_SIZE = 8, CHROM_SIZE = 4;
unsigned i;
eoUniform<Chrom::Type> uniform(false, true);
eoBinRandom<Chrom> random;
eoPop<Chrom> pop;
// Create the population
for (i = 0; i < POP_SIZE; ++i) {
Chrom chrom(CHROM_SIZE);
random(chrom);
binary_value(chrom);
pop.push_back(chrom);
}
// print population
cout << "population:" << endl;
for (i = 0; i < pop.size(); ++i)
cout << pop[i] << " " << pop[i].fitness() << endl;
// Declare 1-selectors
eoUniformSelect<Chrom> uSelect;
Chrom aChrom;
aChrom = uSelect( pop );
cout << "Uniform Select " << aChrom << " " << aChrom.fitness() << endl;
eoStochTournament<Chrom> sSelect(0.7);
aChrom = sSelect( pop );
cout << "Stochastic Tournament " << aChrom << " " << aChrom.fitness() << endl;
eoDetTournament<Chrom> dSelect(3);
aChrom = dSelect( pop );
cout << "Deterministic Tournament " << aChrom << " " << aChrom.fitness() << endl;
return 0;
}
//-----------------------------------------------------------------------------

6
eo/win/Makefile.am Normal file
View file

@ -0,0 +1,6 @@
EXTRA_DIST=EO.dsw random.dsp t_eoinsertion.dsp t_ops.dsp\
atomops.dsp t_eoaged.dsp t_eornd.dsp t_opsel.dsp\
t_eobin.dsp t_eostring.dsp t_opselmason.dsp\
eo.dsp t_eobitfact.dsp t_eovector.dsp t_pop.dsp\
t_eobreeder.dsp t_es.dsp t_popops.dsp\
eolib.dsp t_eoid.dsp t_lottery.dsp\