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,11 @@
2006-12-02 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* contrib/MGE/VirusOp.h (VirusShiftMutation::operator()): Fix test for
i>1. This makes t-MGE1bit pass on x86_64 using GCC.
* Local Variables:
* coding: iso-8859-1
* mode: flyspell
* fill-column: 80
* End:

View file

@ -0,0 +1,145 @@
/*
ViruOp.h
(c) GeNeura Team 2001, Marc Schoenauer 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: eodev-main@lists.sourceforge.net
old contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
*/
#ifndef VirusOp_h
#define VirusOp_h
//-----------------------------------------------------------------------------
#include <iostream> // ostream, istream
#include <functional> // bind2nd
#include <string> // std::string
#include <utils/eoRNG.h>
#include "eoVirus.h"
/** VirusBitFlip --> changes 1 bit
*/
template<class FitT>
class VirusBitFlip: public eoMonOp<eoVirus<FitT> > {
public:
/// The class name.
virtual std::string className() const { return "VirusBitFlip"; };
/** Change one bit.
@param chrom The cromosome which one bit is going to be changed.
*/
bool operator()(eoVirus<FitT>& _chrom) {
unsigned i = eo::rng.random(_chrom.size());
_chrom.virusBitSet(i, _chrom.virusBit(i) ? false : true );
return true;
}
};
template<class FitT>
class VirusMutation: public eoMonOp<eoVirus<FitT> > {
public:
/// The class name.
virtual std::string className() const { return "VirusMutation"; };
/** Change one bit.
@param chrom The cromosome which one bit is going to be changed.
*/
bool operator()(eoVirus<FitT>& _chrom) {
// Search for virus bits
std::vector<unsigned> bitsSet;
for ( unsigned i = 0; i < _chrom.size(); i ++ ) {
if ( _chrom.virusBit(i) ) {
bitsSet.push_back( i );
}
}
if ( !bitsSet.size() ) {
return false;
}
unsigned flipSite = eo::rng.random(bitsSet.size());
unsigned flipValue = bitsSet[ flipSite ];
_chrom[flipValue] = _chrom[flipValue] ? false : true;
return true;
}
};
/// Works for 1-bit virus; shifts the one to the right or left
template<class FitT>
class VirusShiftMutation: public eoMonOp<eoVirus<FitT> >
{
public:
/// Ctor
VirusShiftMutation( ) {};
/// The class name.
virtual std::string className() const { return "VirusShiftMutation"; };
/** Change one bit.
@param chrom The cromosome which one bit is going to be changed.
*/
bool operator()(eoVirus<FitT>& _chrom) {
// Search for virus bits
eoBooleanGenerator gen;
for ( unsigned i = 0; i < _chrom.size(); i ++ ) {
if ( _chrom.virusBit(i) ) {
if ( gen() ) {
if ( i + 1 < _chrom.size() ) {
_chrom.virusBitSet(i+1,true);
_chrom.virusBitSet(i, false);
}
} else {
if ( i > 1 ) {
_chrom.virusBitSet(i-1,true);
_chrom.virusBitSet(i, false);
}
}
}
}
return true;
}
};
template<class FitT>
class VirusTransmission: public eoBinOp<eoVirus<FitT> > {
public:
/// The class name.
virtual std::string className() const { return "VirusTransmission"; };
/**
* Change one bit.
* @param _chrom The "receptor" chromosome
* @param _chrom2 The "donor" chromosome
*/
bool operator()(eoVirus<FitT>& _chrom,const eoVirus<FitT>& _chrom2) {
// Search for virus bits
for ( unsigned i = 0; i < _chrom.size(); i ++ ) {
_chrom.virusBitSet(i, _chrom2.virusBit(i) );
}
return true;
}
};
#endif //VirusOp_h

View file

@ -0,0 +1,86 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoInit.h
// (c) Maarten Keijzer 2000, GeNeura Team, 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
Marc.Schoenauer@polytechnique.fr
mak@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef _eoInitVirus_H
#define _eoInitVirus_H
#include <algorithm>
#include <eoOp.h>
#include <eoSTLFunctor.h>
#include <utils/eoRndGenerators.h>
#include <eoInit.h>
/**
Initializer for binary chromosome with MGE
*/
template <class FitT>
class eoInitVirus: public eoInit< eoVirus<FitT> > {
public:
eoInitVirus(unsigned _combien, eoRndGenerator<bool>& _generator )
: combien(_combien), generator(_generator) {}
virtual void operator()( eoVirus<FitT>& chrom)
{
chrom.resize(combien);
chrom.virResize(combien);
std::generate(chrom.begin(), chrom.end(), generator);
for ( unsigned i = 0; i < combien; i ++ ) {
chrom.virusBitSet(i, generator() );
}
chrom.invalidate();
}
private :
unsigned combien;
/// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics
eoSTLF<bool> generator;
};
/// Inits the virus with one bit to the left set to one
template <class FitT>
class eoInitVirus1bit: public eoInit< eoVirus<FitT> > {
public:
eoInitVirus1bit(unsigned _combien, eoRndGenerator<bool>& _generator )
: combien(_combien), generator(_generator) {}
virtual void operator()( eoVirus<FitT>& chrom)
{
chrom.resize(combien);
chrom.virResize(combien);
std::generate(chrom.begin(), chrom.end(), generator);
chrom.virusBitSet(0, true );
chrom.invalidate();
}
private :
unsigned combien;
/// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics
eoSTLF<bool> generator;
};
#endif

View file

@ -0,0 +1,130 @@
/* eoVirus.h
(c) GeNeura Team 2001, Marc Schoenauer 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
Marc.Schoenauer@polytechnique.fr
*/
#ifndef eoVirus_h
#define eoVirus_h
#include <iostream>
#include <functional>
#include <string>
#include <vector>
#include "ga/eoBit.h"
/**
\defgroup bitstring
Various functions for a bitstring representation
*/
/** Implementation of bitstring chromosome.
@class eoBit eoBit.h ga/eoBit.h
@ingroup bitstring
Based on STL's vector<bool> specialization.
*/
template <class FitT>
class eoVirus : public eoBit<FitT>
{
public:
using eoBit<FitT>::begin;
using eoBit<FitT>::end;
using eoBit<FitT>::size;
/** (Default) Constructor
@param size Size of the binary std::string.
*/
eoVirus(unsigned _size = 0, bool _value = false, bool _virValue = false):
eoBit<FitT>(_size, _value), virus( _size, _virValue) {}
/// My class name
virtual std::string className() const {
return "eoVirus";
}
/// Access to virus features
void virResize( unsigned _i ) {
virus.resize(_i );
}
/// Access to virus features
bool virusBit( unsigned _i ) const {
return virus[_i];
}
/// Change virus features
void virusBitSet( unsigned _i, bool _bit ) {
virus[_i ] = _bit;
}
/** To print me on a stream.
@param os The ostream.
*/
virtual void printOn(std::ostream& os) const {
EO<FitT>::printOn(os);
os << ' ';
os << size() << ' ';
std::copy(begin(), end(), std::ostream_iterator<bool>(os));
std::cout << std::endl;
std::copy(virus.begin(), virus.end(), std::ostream_iterator<bool>(os));
}
/** To read me from a stream.
@param is The istream.
*/
virtual void readFrom(std::istream& is){
eoBit<FitT>::readFrom(is);
unsigned s;
is >> s;
std::string bits;
is >> bits;
if (is) {
virus.resize(bits.size());
std::transform(bits.begin(), bits.end(), virus.begin(),
std::bind2nd(std::equal_to<char>(), '1'));
}
}
private:
std::vector<bool> virus;
};
//-----------------------------------------------------------------------------
#endif //eoBit_h
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-style: "Stroustrup"
// End: