Changes
This commit is contained in:
parent
de33c67f0e
commit
d3642e4fde
12 changed files with 397 additions and 207 deletions
|
|
@ -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
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
154
eo/src/eoBin.h
154
eo/src/eoBin.h
|
|
@ -1,78 +1,76 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// eoBin.h
|
// eoBin.h
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef eoBin_h
|
#ifndef eoBin_h
|
||||||
#define eoBin_h
|
#define eoBin_h
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <iostream> // ostream, istream
|
#include <iostream> // ostream, istream
|
||||||
#include <functional> // bind2nd
|
#include <functional> // bind2nd
|
||||||
#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:
|
/**
|
||||||
|
* (Default) Constructor.
|
||||||
/**
|
* @param size Size of the binary string.
|
||||||
* (Default) Constructor.
|
*/
|
||||||
* @param size Size of the binary string.
|
eoBin(unsigned size = 0, bool value = false):
|
||||||
*/
|
eoVector<bool,F>(size, value) {}
|
||||||
eoBin(unsigned size = 0, bool value = false):
|
|
||||||
eoVector<bool,F>(size, value) {}
|
/**
|
||||||
|
* Constructor.
|
||||||
/**
|
* @param size Size of the binary string.
|
||||||
* Constructor.
|
*/
|
||||||
* @param size Size of the binary string.
|
eoBin(unsigned size, const eoRnd<bool>& rnd): eoVector<bool,F>(size)
|
||||||
*/
|
{
|
||||||
eoBin(unsigned size, const eoRnd<bool>& rnd): eoVector<bool,F>(size)
|
generate(begin(), end(), rnd);
|
||||||
{
|
}
|
||||||
generate(begin(), end(), rnd);
|
|
||||||
}
|
/** Constructor from istream.
|
||||||
|
@param is The istream to read from.*/
|
||||||
/** Constructor from istream.
|
eoBin(istream& _is):eoVector<bool,F>(_is){};
|
||||||
@param is The istream to read from.*/
|
|
||||||
eoBin(istream& _is):eoVector<bool,F>(_is){};
|
/// My class name.
|
||||||
|
string className() const
|
||||||
/// My class name.
|
{
|
||||||
string className() const
|
return "eoBin";
|
||||||
{
|
}
|
||||||
return "eoBin";
|
|
||||||
}
|
/**
|
||||||
|
* To print me on a stream.
|
||||||
/**
|
* @param os The ostream.
|
||||||
* To print me on a stream.
|
*/
|
||||||
* @param os The ostream.
|
void printOn(ostream& os) const
|
||||||
*/
|
{
|
||||||
void printOn(ostream& os) const
|
copy(begin(), end(), ostream_iterator<bool>(os));
|
||||||
{
|
}
|
||||||
copy(begin(), end(), ostream_iterator<bool>(os));
|
|
||||||
}
|
/**
|
||||||
|
* To read me from a stream.
|
||||||
/**
|
* @param is The istream.
|
||||||
* To read me from a stream.
|
*/
|
||||||
* @param is The istream.
|
void readFrom(istream& is)
|
||||||
*/
|
{
|
||||||
void readFrom(istream& is)
|
string bits;
|
||||||
{
|
is >> bits;
|
||||||
string bits;
|
if (is)
|
||||||
is >> bits;
|
{
|
||||||
if (is)
|
resize(bits.size());
|
||||||
{
|
transform(bits.begin(), bits.end(), begin(),
|
||||||
resize(bits.size());
|
bind2nd(equal_to<char>(), '1'));
|
||||||
transform(bits.begin(), bits.end(), begin(),
|
}
|
||||||
bind2nd(equal_to<char>(), '1'));
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
};
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
#endif eoBin_h
|
||||||
|
|
||||||
#endif eoBin_h
|
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,53 @@
|
||||||
//-----------------------------------------------------------------------------
|
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||||
// t-eouniform
|
|
||||||
//-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
|
* t-eoRandom
|
||||||
#include <iostream> // cout
|
* Testing program for the eoRNG class
|
||||||
#include <strstream> // ostrstream, istrstream
|
* (c) GeNeura Team, 1999
|
||||||
#include <eoUniform.h> // eoBin
|
|
||||||
#include <eoNormal.h>
|
This library is free software; you can redistribute it and/or
|
||||||
#include <eoNegExp.h>
|
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.
|
||||||
|
|
||||||
main() {
|
This library is distributed in the hope that it will be useful,
|
||||||
eoNormal<float> n1(-2.5,3.5);
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
eoNormal<double> n2(0.003, 0.0005 );
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
eoNormal<unsigned long> n3( 10000000U, 10000U);
|
Lesser General Public License for more details.
|
||||||
eoNegExp<float> e1(3.5);
|
|
||||||
eoNegExp<double> e2(0.003 );
|
You should have received a copy of the GNU Lesser General Public
|
||||||
eoNegExp<long> e3( 10000U);
|
License along with this library; if not, write to the Free Software
|
||||||
cout << "n1\t\tn2\t\tn3\t\te1\t\te2\t\te3" << endl;
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
for ( unsigned i = 0; i < 100; i ++) {
|
|
||||||
cout << n1() << "\t" << n2() << "\t" << n3() << "\t" <<
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
e1() << "\t" << e2() << "\t" << e3() << endl;
|
|
||||||
}
|
*/
|
||||||
|
|
||||||
return 0; // to avoid VC++ complaints
|
//-----------------------------------------------------------------------------
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
#include <iostream> // cout
|
||||||
|
#include <strstream> // ostrstream, istrstream
|
||||||
|
#include <eoUniform.h> // eoBin
|
||||||
|
#include <eoNormal.h>
|
||||||
|
#include <eoNegExp.h>
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
main() {
|
||||||
|
eoNormal<float> n1(-2.5,3.5);
|
||||||
|
eoNormal<double> n2(0.003, 0.0005 );
|
||||||
|
eoNormal<unsigned long> n3( 10000000U, 10000U);
|
||||||
|
eoNegExp<float> e1(3.5);
|
||||||
|
eoNegExp<double> e2(0.003 );
|
||||||
|
eoNegExp<long> e3( 10000U);
|
||||||
|
cout << "n1\t\tn2\t\tn3\t\te1\t\te2\t\te3" << endl;
|
||||||
|
for ( unsigned i = 0; i < 100; i ++) {
|
||||||
|
cout << n1() << "\t" << n2() << "\t" << n3() << "\t" <<
|
||||||
|
e1() << "\t" << e2() << "\t" << e3() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; // to avoid VC++ complaints
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,71 +1,84 @@
|
||||||
//-----------------------------------------------------------------------------
|
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||||
// t-eobreeder.cpp
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
// t-eobreeder.cpp
|
||||||
// to avoid long name warnings
|
// This program test the breeder object
|
||||||
#pragma warning(disable:4786)
|
// (c) GeNeura Team, 1998
|
||||||
|
/*
|
||||||
#include <eoBin.h> // eoBin, eoPop, eoBreeder
|
This library is free software; you can redistribute it and/or
|
||||||
#include <eoPop.h>
|
modify it under the terms of the GNU General Public
|
||||||
#include <eoBitOp.h>
|
License as published by the Free Software Foundation; either
|
||||||
#include <eoProportionalOpSel.h>
|
version 2 of the License, or (at your option) any later version.
|
||||||
#include <eoBreeder.h>
|
|
||||||
|
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
|
||||||
typedef eoBin<float> Chrom;
|
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
|
||||||
void binary_value(Chrom& chrom)
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
{
|
|
||||||
float sum = 0;
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
for (unsigned i = 0; i < chrom.size(); i++)
|
|
||||||
if (chrom[i])
|
*/
|
||||||
sum += pow(2, chrom.size() - i - 1);
|
//-----------------------------------------------------------------------------
|
||||||
chrom.fitness(sum);
|
|
||||||
}
|
// to avoid long name warnings
|
||||||
|
#pragma warning(disable:4786)
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
#include <eoBin.h> // eoBin, eoPop, eoBreeder
|
||||||
main()
|
#include <eoPop.h>
|
||||||
{
|
#include <eoBitOp.h>
|
||||||
const unsigned POP_SIZE = 8, CHROM_SIZE = 4;
|
#include <eoProportionalOpSel.h>
|
||||||
unsigned i;
|
#include <eoBreeder.h>
|
||||||
|
|
||||||
eoUniform<Chrom::Type> uniform(false, true);
|
//-----------------------------------------------------------------------------
|
||||||
eoBinRandom<Chrom> random;
|
|
||||||
eoPop<Chrom> pop;
|
typedef eoBin<float> Chrom;
|
||||||
|
|
||||||
for (i = 0; i < POP_SIZE; ++i)
|
#include "binary_value.h"
|
||||||
{
|
|
||||||
Chrom chrom(CHROM_SIZE);
|
//-----------------------------------------------------------------------------
|
||||||
random(chrom);
|
|
||||||
binary_value(chrom);
|
main()
|
||||||
pop.push_back(chrom);
|
{
|
||||||
}
|
const unsigned POP_SIZE = 8, CHROM_SIZE = 4;
|
||||||
|
unsigned i;
|
||||||
cout << "population:" << endl;
|
|
||||||
for (i = 0; i < pop.size(); ++i)
|
eoUniform<Chrom::Type> uniform(false, true);
|
||||||
cout << pop[i] << " " << pop[i].fitness() << endl;
|
eoBinRandom<Chrom> random;
|
||||||
|
eoPop<Chrom> pop;
|
||||||
eoBinBitFlip<Chrom> bitflip;
|
|
||||||
eoBinCrossover<Chrom> xover;
|
for (i = 0; i < POP_SIZE; ++i)
|
||||||
eoProportionalOpSel<Chrom> propSel;
|
{
|
||||||
eoBreeder<Chrom> breeder( propSel );
|
Chrom chrom(CHROM_SIZE);
|
||||||
propSel.addOp(bitflip, 0.25);
|
random(chrom);
|
||||||
propSel.addOp(xover, 0.75);
|
binary_value(chrom);
|
||||||
|
pop.push_back(chrom);
|
||||||
breeder(pop);
|
}
|
||||||
|
|
||||||
// reevaluation of fitness
|
cout << "population:" << endl;
|
||||||
for_each(pop.begin(), pop.end(), binary_value);
|
for (i = 0; i < pop.size(); ++i)
|
||||||
|
cout << pop[i] << " " << pop[i].fitness() << endl;
|
||||||
cout << "new population:" << endl;
|
|
||||||
for (i = 0; i < pop.size(); ++i)
|
eoBinBitFlip<Chrom> bitflip;
|
||||||
cout << pop[i] << " " << pop[i].fitness() << endl;
|
eoBinCrossover<Chrom> xover;
|
||||||
|
eoProportionalOpSel<Chrom> propSel;
|
||||||
return 0;
|
eoBreeder<Chrom> breeder( propSel );
|
||||||
}
|
propSel.addOp(bitflip, 0.25);
|
||||||
|
propSel.addOp(xover, 0.75);
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
breeder(pop);
|
||||||
|
|
||||||
|
// reevaluation of fitness
|
||||||
|
for_each(pop.begin(), pop.end(), binary_value);
|
||||||
|
|
||||||
|
cout << "new population:" << endl;
|
||||||
|
for (i = 0; i < pop.size(); ++i)
|
||||||
|
cout << pop[i] << " " << pop[i].fitness() << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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
87
eo/test/t-selectOne.cpp
Normal 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
6
eo/win/Makefile.am
Normal 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\
|
||||||
Reference in a new issue