move paradiseo/eo to deprecated/ before merge with eodev

This commit is contained in:
Johann Dreo 2012-10-05 15:12:12 +02:00
commit 0c5120f675
717 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,100 @@
/* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
-----------------------------------------------------------------------------
eoExternalEO.h
Definition of an object that allows an external struct to be inserted in EO
(c) Maarten Keijzer (mkeijzer@mad.scientist.com) and GeNeura Team, 1999, 2000
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; 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
*/
#ifndef eoExternalEO_h
#define eoExternalEO_h
#include <EO.h> // EO
/**
* Definition of an object that allows an external struct
* to be inserted in EO. This struct or class can be of any
* form, the only thing this class does is attach a fitness
* value to it and makes it the appropriate type (derives it from EO).
*
* @ingroup Utilities
*/
template <class Fit, class External>
class eoExternalEO : public EO<Fit>, virtual public External
{
public :
eoExternalEO()
: External(), EO<Fit>()
{}
/** Init externalEo with the struct itself and set fitness to zero */
eoExternalEO(const External& ext)
: EO<Fit>(), External(ext)
{}
eoExternalEO(std::istream& is, const External& ext)
: EO<Fit>(), External(ext)
{ readFrom(is); }
/**
* Read object, the external struct needs to have an operator>> defined
*/
virtual void readFrom(std::istream& _is)
{
EO<Fit>::readFrom(_is);
_is >> static_cast<External&>(*this);
}
/**
* Write object. Called printOn since it prints the object _on_ a stream.
* @param _os A std::ostream.
*/
virtual void printOn(std::ostream& _os) const
{
EO<Fit>::printOn(_os);
_os << static_cast<const External&>(*this);
}
};
/** @example t-eoExternalEO.cpp
*/
/** To remove ambiguities between EO<F> and External, streaming operators are defined yet again
* @ingroup Utilities
*/
template <class F, class External>
std::ostream& operator<<(std::ostream& os, const eoExternalEO<F, External>& eo)
{
eo.printOn(os);
return os;
}
/** To remove ambiguities between EO<F> and External, streaming operators are defined yet again
* @ingroup Utilities
*/
template <class F, class External>
std::istream& operator>>(std::istream& is, eoExternalEO<F, External>& eo)
{
eo.readFrom(is);
return is;
}
#endif

View file

@ -0,0 +1,180 @@
/* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
-----------------------------------------------------------------------------
eoExternalOpFunc.h
Defines eoExternalInitOpFunc, eoExternalMonOpFunc, eoExternalBinOpFunc, eoExternalQuadOpFunc
that are used to wrap a function pointer to externally defined initialization
and 'genetic' operators
(c) Maarten Keijzer (mkeijzer@mad.scientist.com) and GeNeura Team, 1999, 2000
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; 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
*/
#ifndef eoExternalOpFunc_h
#define eoExternalOpFunc_h
#include <other/eoExternalEO.h>
#include <eoOp.h>
#include <eoInit.h>
#include <eoEvalFunc.h>
/**
Initialization of external struct, ctor expects a function of the following
signature:
External func();
Where External is the user defined struct or class
@ingroup Utilities
*/
template <class F, class External, class ExternalEO = eoExternalEO<F, External> >
class eoExternalInit : public eoInit<ExternalEO>
{
public :
eoExternalInit(External (*_init)(void)) : init(_init) {}
void operator()(ExternalEO& _eo)
{
_eo.External::operator=( (*init)() );
_eo.invalidate();
}
private :
External (*init)(void);
};
/**
Evaluation of external struct, ctor expects a function of the following
signature:
Fit func(External&);
Where External is the user defined struct or class and Fit the fitness type
@ingroup Utilities
*/
template <class F, class External, class ExternalEO = eoExternalEO<F, External> >
class eoExternalEvalFunc : public eoEvalFunc<ExternalEO>
{
public :
eoExternalEvalFunc(F (*_eval)(const External&)) : eval(_eval) {}
void operator()(ExternalEO& eo)
{
if (eo.invalid())
eo.fitness( (*eval)(eo) );
}
private :
F (*eval)(const External&);
};
/**
Mutation of external struct, ctor expects a function of the following
signature:
bool func(External&);
Where External is the user defined struct or class.
The function should return true when it changed something, false otherwise
@ingroup Utilities
*/
template <class F, class External, class ExternalEO = eoExternalEO<F, External> >
class eoExternalMonOp : public eoMonOp<ExternalEO>
{
public :
eoExternalMonOp(bool (*_mutate)(External&)) : mutate(_mutate) {}
bool operator()(ExternalEO& eo)
{
return (*mutate)(eo);
}
private :
bool (*mutate)(External&);
};
/**
Crossover of external struct, ctor expects a function of the following
signature:
bool func(External&, const External&);
Where External is the user defined struct or class
The function should return true when it changed something, false otherwise
@ingroup Utilities
*/
template <class F, class External, class ExternalEO = eoExternalEO<F, External> >
class eoExternalBinOp : public eoBinOp<ExternalEO>
{
public :
eoExternalBinOp(bool (*_binop)(External&, const External&)) : binop(_binop) {}
bool operator()(ExternalEO& eo1, const ExternalEO& eo2)
{
return (*binop)(eo1, eo2);
}
private :
bool (*binop)(External&, const External&);
};
/**
Crossover of external struct, ctor expects a function of the following
signature:
bool func(External&, External&);
Where External is the user defined struct or class
The function should return true when it changed something, false otherwise
@ingroup Utilities
*/
template <class F, class External, class ExternalEO = eoExternalEO<F, External> >
class eoExternalQuadOp : public eoQuadOp<ExternalEO>
{
public :
eoExternalQuadOp(bool (*_quadop)(External&, External&)) : quadop(_quadop) {}
bool operator()(ExternalEO& eo1, ExternalEO& eo2)
{
return (*quadop)(eo1, eo2);
}
private :
bool (*quadop)(External&, External&);
};
#endif

View file

@ -0,0 +1,84 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoString.h
// (c) GeNeura Team, 1998
/*
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; 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
*/
//-----------------------------------------------------------------------------
#ifndef _eoString_H
#define _eoString_H
// STL libraries
#include <iostream>
#include <string>
#include <stdexcept>
#include <EO.h>
//-----------------------------------------------------------------------------
// eoString
//-----------------------------------------------------------------------------
/** Adaptor that turns an STL std::string into an EO
@ingroup Representations
@ingroup Utilities
*/
template <class fitnessT >
class eoString: public EO<fitnessT>, public std::string
{
public:
typedef char Type;
typedef char AtomType;
typedef std::string ContainerType;
/// Canonical part of the objects: several ctors, copy ctor, dtor and assignment operator
//@{
/// ctor
eoString( const std::string& _str ="" )
: std::string( _str ) {};
/// printing...
virtual void printOn(std::ostream& os) const
{
EO<fitnessT>::printOn(os);
os << ' ';
os << size() << ' ' << substr() << std::endl;
}
/** @name Methods from eoObject
readFrom and printOn are directly inherited from eo1d
*/
//@{
/** Inherited from eoObject
@see eoObject
*/
virtual std::string className() const {return "eoString";};
//@}
};
#endif

View file

@ -0,0 +1,2 @@
#include <other/eoExternalEO.h>
#include <other/eoExternalOpFunctions.h>