Removing ParadisEO
This commit is contained in:
parent
c498de10e2
commit
e1cc2dd7f5
37 changed files with 4 additions and 2396 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
if USE_PARADISEO
|
#if USE_PARADISEO
|
||||||
SUBDIRS = Lesson1 Lesson2 Lesson3 Lesson4 Lesson5 ParadisEO
|
#SUBDIRS = Lesson1 Lesson2 Lesson3 Lesson4 Lesson5 ParadisEO
|
||||||
else
|
#else
|
||||||
SUBDIRS = Lesson1 Lesson2 Lesson3 Lesson4 Lesson5
|
SUBDIRS = Lesson1 Lesson2 Lesson3 Lesson4 Lesson5
|
||||||
endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,6 @@
|
||||||
#include <other/external_eo>
|
#include <other/external_eo>
|
||||||
#include <eoCounter.h>
|
#include <eoCounter.h>
|
||||||
|
|
||||||
// Cellular parallel evolutionary algorithm
|
|
||||||
#include <eoToricCellularEasyEA.h>
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// to be continued ...
|
// to be continued ...
|
||||||
|
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoToricCellularEasyEA.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoToricCellularEasyEA_h
|
|
||||||
#define eoToricCellularEasyEA_h
|
|
||||||
|
|
||||||
#include <eoCellularEasyEA.h>
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
template <class EOT> class eoToricCellularEasyEA : public eoCellularEasyEA <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
eoToricCellularEasyEA (eoContinue <EOT> & _cont,
|
|
||||||
eoEvalFunc <EOT> & _eval,
|
|
||||||
eoSelectOne <EOT> & _sel_neigh,
|
|
||||||
eoBinOp <EOT> & _cross,
|
|
||||||
eoMonOp <EOT> & _mut,
|
|
||||||
eoSelectOne <EOT> & _sel_repl
|
|
||||||
) :
|
|
||||||
eoCellularEasyEA <EOT> (_cont,
|
|
||||||
_eval,
|
|
||||||
_sel_neigh,
|
|
||||||
_cross,
|
|
||||||
_mut,
|
|
||||||
_sel_repl) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
eoToricCellularEasyEA (eoContinue <EOT> & _cont,
|
|
||||||
eoEvalFunc <EOT> & _eval,
|
|
||||||
eoSelectOne <EOT> & _sel_neigh,
|
|
||||||
eoQuadOp <EOT> & _cross,
|
|
||||||
eoMonOp <EOT> & _mut,
|
|
||||||
eoSelectOne <EOT> & _sel_child,
|
|
||||||
eoSelectOne <EOT> & _sel_repl
|
|
||||||
) :
|
|
||||||
eoCellularEasyEA <EOT> (_cont,
|
|
||||||
_eval,
|
|
||||||
_sel_neigh,
|
|
||||||
_cross,
|
|
||||||
_mut,
|
|
||||||
_sel_child,
|
|
||||||
_sel_repl) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Take care :-). The size of the population must be a square number ! (9, 16, ...)
|
|
||||||
|
|
||||||
virtual eoPop <EOT> neighbours (const eoPop <EOT> & pop, int rank) {
|
|
||||||
|
|
||||||
int dim2 = pop.size () ;
|
|
||||||
int dim = (int) std::sqrt ( (double) dim2) ;
|
|
||||||
int j = rank ;
|
|
||||||
|
|
||||||
eoPop <EOT> neigh ;
|
|
||||||
neigh.push_back (pop [j < dim ? dim2 - dim + j : j - dim]) ;
|
|
||||||
neigh.push_back (pop [(j + dim) % dim2]) ;
|
|
||||||
neigh.push_back (pop [(j + 1) % dim != 0 ? j + 1 : j + 1 - dim]) ;
|
|
||||||
neigh.push_back (pop [j % dim != 0 ? j - 1 : j + dim - 1]) ;
|
|
||||||
|
|
||||||
return neigh ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
SUBDIRS = comm eval island
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoPopAgent.h eoSolAgent.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
SUBDIRS = messages
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoListener.h eoLocalListener.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,148 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoListener.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoListener_h
|
|
||||||
#define eoListener_h
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <paradisEO/comm/eoLocalListener.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoPublishMessTo.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoKillMessTo.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Necessary for any use of a distributed model.
|
|
||||||
It makes it possible to have a total state of
|
|
||||||
that one.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// In the near future ... Enabling different kinds of EO to send/receive ..
|
|
||||||
|
|
||||||
template <class EOT> class eoListener : public std::vector <eoLocalListener <EOT> > {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoListener (int argc, char ** argv) : comm (MPI :: COMM_WORLD) {
|
|
||||||
|
|
||||||
// Mpi requires it !
|
|
||||||
MPI :: Init (argc, argv) ;
|
|
||||||
|
|
||||||
// Who and how many ?
|
|
||||||
rank = MPI :: COMM_WORLD.Get_rank () ;
|
|
||||||
len = MPI :: COMM_WORLD.Get_size () ;
|
|
||||||
|
|
||||||
// To build local listeners algorithms
|
|
||||||
for (int i = 0 ; i < len ; i ++) {
|
|
||||||
eoLocalListener <EOT> loc_listen (i) ;
|
|
||||||
push_back (loc_listen) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Destructor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
~ eoListener () {
|
|
||||||
|
|
||||||
MPI :: Finalize () ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
A reference to the current listener
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoLocalListener <EOT> & here () {
|
|
||||||
|
|
||||||
return operator [] (rank) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
To import messages ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
void update () {
|
|
||||||
|
|
||||||
for (int i = 0 ; i < size () ; i ++)
|
|
||||||
operator [] (i).update () ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
To broadcast the std::string identifier of the local process to the
|
|
||||||
whole neighbouring ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
void publish (std::string label) {
|
|
||||||
|
|
||||||
eoPublishMessTo <EOT> mess (label) ;
|
|
||||||
for (int i = 0 ; i < size () ; i ++)
|
|
||||||
if (i != rank)
|
|
||||||
mess (operator [] (i)) ;
|
|
||||||
here ().label () = label ; // Nothing to send !
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Blocking. Waits for at least one 'eoLocalListener' to
|
|
||||||
receive any eoPop ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
void wait () {
|
|
||||||
|
|
||||||
bool b = false ;
|
|
||||||
|
|
||||||
do {
|
|
||||||
comm.Probe (MPI :: ANY_SOURCE, 0) ;
|
|
||||||
update () ;
|
|
||||||
for (int i = 0 ; i < size () ; i ++)
|
|
||||||
if (! operator [] (i).empty ())
|
|
||||||
b = true ;
|
|
||||||
|
|
||||||
} while (! b) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroy (std::string label) {
|
|
||||||
|
|
||||||
eoKillMessTo <EOT> mess ;
|
|
||||||
for (int i = 0 ; i < len ; i ++) {
|
|
||||||
if (operator [] (i).label () == label)
|
|
||||||
mess (operator [] (i)) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
int rank, len ; // Rank of current process, and number of distributed processes
|
|
||||||
|
|
||||||
MPI :: Comm & comm ; // Communicator
|
|
||||||
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,170 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoLocalListener.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoLocalListener_h
|
|
||||||
#define eoLocalListener_h
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <queue>
|
|
||||||
#include <string>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <paradisEO/comm/messages/from/eoHeaderMessFrom.h>
|
|
||||||
#include <paradisEO/comm/messages/from/eoEOReceiveMessFrom.h>
|
|
||||||
#include <paradisEO/comm/messages/from/eoEOSendMessFrom.h>
|
|
||||||
#include <paradisEO/comm/messages/from/eoPublishMessFrom.h>
|
|
||||||
#include <paradisEO/comm/messages/from/eoKillMessFrom.h>
|
|
||||||
#include <eoPop.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
A local listener to pack any coming message or, on contrary, to
|
|
||||||
send any data to another distributed process.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Well, not very nice, but necessary for multiples header inclusions :-/
|
|
||||||
|
|
||||||
template <class EOT> class eoHeaderMessFrom ;
|
|
||||||
template <class EOT> class eoMessFrom ;
|
|
||||||
template <class EOT> class eoMessTo ;
|
|
||||||
template <class EOT> class eoEOReceiveMessFrom ;
|
|
||||||
template <class EOT> class eoEOSendMessFrom ;
|
|
||||||
template <class EOT> class eoPublishMessFrom ;
|
|
||||||
template <class EOT> class eoKillMessFrom ;
|
|
||||||
|
|
||||||
template <class EOT> class eoLocalListener : public std::queue <eoPop <EOT> > {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoLocalListener (int _num_id) :
|
|
||||||
|
|
||||||
num_id (_num_id),
|
|
||||||
comm (& MPI :: COMM_WORLD), // Shared communicator ...
|
|
||||||
req_EO (false) {
|
|
||||||
|
|
||||||
gethostname (host_name, 255) ; // Host ?
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Any distributed algorithm or agent has its own integer
|
|
||||||
identifiant, which lets us to distinguish them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool operator == (eoLocalListener <EOT> & loc_listen) {
|
|
||||||
|
|
||||||
return loc_listen.num_id == num_id ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
To import awaiting messages from other algorithms.
|
|
||||||
For each one, an action may be performed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void update () {
|
|
||||||
|
|
||||||
while (comm -> Iprobe (num_id, 0)) {
|
|
||||||
// While any more messages
|
|
||||||
|
|
||||||
eoHeaderMessFrom <EOT> header (* this) ;
|
|
||||||
eoMessFrom <EOT> * mess ;
|
|
||||||
|
|
||||||
/* The header identifies the kind of messages.
|
|
||||||
Currently, only four are necessary and so defined */
|
|
||||||
|
|
||||||
if (header == "eoEOReceiveMessTo")
|
|
||||||
mess = new eoEOReceiveMessFrom <EOT> (* this) ;
|
|
||||||
else if (header == "eoEOSendMessTo")
|
|
||||||
mess = new eoEOSendMessFrom <EOT> (* this) ;
|
|
||||||
else if (header == "eoPublishMessTo")
|
|
||||||
mess = new eoPublishMessFrom <EOT> (* this) ;
|
|
||||||
else {
|
|
||||||
mess = new eoKillMessFrom <EOT> (* this) ;
|
|
||||||
}
|
|
||||||
// Any side effects ?
|
|
||||||
mess -> operator () () ;
|
|
||||||
delete mess ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wait () {
|
|
||||||
|
|
||||||
bool b = false ;
|
|
||||||
|
|
||||||
do {
|
|
||||||
comm -> Probe (num_id, 0) ;
|
|
||||||
update () ;
|
|
||||||
if (! empty ())
|
|
||||||
b = true ;
|
|
||||||
|
|
||||||
} while (! b) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
String identifier of this algo/agent ?
|
|
||||||
*/
|
|
||||||
|
|
||||||
std::string & label () {
|
|
||||||
|
|
||||||
return name_id ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool & need_immigration () {
|
|
||||||
|
|
||||||
return req_EO ;
|
|
||||||
}
|
|
||||||
|
|
||||||
int number () {
|
|
||||||
|
|
||||||
return num_id ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroy () {
|
|
||||||
|
|
||||||
std::cout << "Agent [" << name_id << "] stopped ..." << std::endl ;
|
|
||||||
MPI :: Finalize () ;
|
|
||||||
exit (0) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
char host_name [255] ; // Host std::string identifier
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
MPI :: Comm * comm ; // MPI Communicator
|
|
||||||
|
|
||||||
std::string name_id ; // String id.
|
|
||||||
int num_id ; // MPI id.
|
|
||||||
bool req_EO ;
|
|
||||||
|
|
||||||
// Friendly classes
|
|
||||||
friend class eoMessFrom <EOT> ;
|
|
||||||
friend class eoMessTo <EOT> ;
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
SUBDIRS = from to
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoMessFrom.h eoMessTo.h
|
|
||||||
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoMessFrom.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoMessFrom_h
|
|
||||||
#define eoMessFrom_h
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
An abstract class for any kind of coming message.
|
|
||||||
Common features are declared.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoLocalListener ;
|
|
||||||
|
|
||||||
template <class EOT> class eoMessFrom {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoMessFrom (eoLocalListener <EOT> & _loc_listen) :
|
|
||||||
loc_listen (_loc_listen),
|
|
||||||
comm (MPI :: COMM_WORLD) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Well ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual void operator () () = 0 ;
|
|
||||||
|
|
||||||
protected :
|
|
||||||
|
|
||||||
MPI :: Comm & comm ; // Communicator
|
|
||||||
eoLocalListener <EOT> & loc_listen ; // Transmitter
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoMessTo.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoMessTo_h
|
|
||||||
#define eoMessTo_h
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoHeaderMessTo.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
An abstract class for any sending message.
|
|
||||||
Common features are declared.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoLocalListener ;
|
|
||||||
|
|
||||||
template <class EOT> class eoMessTo {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor. A std::string identifier, being defined in subclasses
|
|
||||||
is given for any kind of messages.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoMessTo (std::string _label) :
|
|
||||||
|
|
||||||
label (_label),
|
|
||||||
comm (MPI :: COMM_WORLD) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Must be called in sub-classes ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
void operator () (eoLocalListener <EOT> & loc_listen) {
|
|
||||||
|
|
||||||
eoHeaderMessTo <EOT> header (label) ;
|
|
||||||
header (loc_listen) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected :
|
|
||||||
|
|
||||||
MPI :: Comm & comm ; // MPI Communicator
|
|
||||||
|
|
||||||
std::string label ; // String identifier of the message
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoEOReceiveMessFrom.h \
|
|
||||||
eoEOSendMessFrom.h \
|
|
||||||
eoHeaderMessFrom.h \
|
|
||||||
eoKillMessFrom.h \
|
|
||||||
eoPublishMessFrom.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoEOReceiveMessFrom.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoEOReceiveMessFrom_h
|
|
||||||
#define eoEOReceiveMessFrom_h
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessFrom.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
A message expressing the need of immigration of EO ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoEOReceiveMessFrom : public eoMessFrom <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoEOReceiveMessFrom (eoLocalListener <EOT> & _loc_listen) :
|
|
||||||
eoMessFrom <EOT> (_loc_listen) {
|
|
||||||
|
|
||||||
// Nothing else to receive :-)
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () () {
|
|
||||||
|
|
||||||
loc_listen.need_immigration () = true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoEOSendMessFrom.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoEOSendMessFrom_h
|
|
||||||
#define eoEOSendMessFrom_h
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#ifdef HAVE_SSTREAM
|
|
||||||
#include <sstream>
|
|
||||||
#else
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <paradisEO/comm/messages/eoMessFrom.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
A message embeding a set of immigrants ...
|
|
||||||
*/
|
|
||||||
template <class EOT> class eoEOSendMessFrom : public eoMessFrom <EOT>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
eoEOSendMessFrom (eoLocalListener <EOT> & _loc_listen)
|
|
||||||
: eoMessFrom <EOT> (_loc_listen) {
|
|
||||||
MPI :: Status stat ;
|
|
||||||
comm.Probe (loc_listen.number (), 0, stat) ;
|
|
||||||
int len = stat.Get_count (MPI :: CHAR) ;
|
|
||||||
char buff [len] ;
|
|
||||||
comm.Recv(buff, len, MPI::CHAR, loc_listen.number (), 0) ;
|
|
||||||
#ifdef HAVE_SSTREAM
|
|
||||||
std::istringstream f(buff);
|
|
||||||
#else
|
|
||||||
istrstream f(buff);
|
|
||||||
#endif
|
|
||||||
_pop.readFrom(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void operator() () {
|
|
||||||
loc_listen.push (_pop) ;
|
|
||||||
// std::cout << "Reception de " << pop.size () << "individus " << std::endl ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
eoPop <EOT> _pop ; // New immigrants !
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoHeaderMessFrom.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoHeaderMessFrom_h
|
|
||||||
#define eoHeaderMessFrom_h
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <mpi.h>
|
|
||||||
|
|
||||||
template <class EOT> class eoLocalListener ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
A header is an identifier for the kind of
|
|
||||||
message to be then received ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoHeaderMessFrom : public std::string {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Second constructor. On contrary, the header is
|
|
||||||
waited for and built from the local listener.
|
|
||||||
It comes before a message.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoHeaderMessFrom (eoLocalListener <EOT> & loc_listen) :
|
|
||||||
comm (MPI :: COMM_WORLD) {
|
|
||||||
|
|
||||||
MPI :: Status stat ;
|
|
||||||
comm.Probe (loc_listen.number (), 0, stat) ; // Blocking
|
|
||||||
int len = stat.Get_count (MPI :: CHAR) ;
|
|
||||||
char buff [len] ; // Temp. buffer
|
|
||||||
comm.Recv (buff, len, MPI :: CHAR, loc_listen.number (), 0) ;
|
|
||||||
assign (buff) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
MPI :: Comm & comm ; // Communicator
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoKillMessFrom.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoKillMessFrom_h
|
|
||||||
#define eoKillMessFrom_h
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessFrom.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
To destroy current process ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoKillMessFrom : public eoMessFrom <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoKillMessFrom (eoLocalListener <EOT> & _loc_listen) :
|
|
||||||
eoMessFrom <EOT> (_loc_listen) {
|
|
||||||
|
|
||||||
// Nothing else to receive :-)
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () () {
|
|
||||||
|
|
||||||
loc_listen.destroy () ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoPublishMessFrom.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoPublishMessFrom_h
|
|
||||||
#define eoPublishMessFrom_h
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessFrom.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
To be notified of the lauch of a new kind of process somewhere ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoPublishMessFrom : public eoMessFrom <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoPublishMessFrom (eoLocalListener <EOT> & _loc_listen) :
|
|
||||||
eoMessFrom <EOT> (_loc_listen) {
|
|
||||||
|
|
||||||
MPI :: Status stat ;
|
|
||||||
comm.Probe (loc_listen.number (), 0, stat) ;
|
|
||||||
int len = stat.Get_count (MPI :: CHAR) ;
|
|
||||||
char buff [len] ;
|
|
||||||
comm.Recv (buff, len, MPI :: CHAR, loc_listen.number (), 0) ;
|
|
||||||
label.assign (buff) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () () {
|
|
||||||
|
|
||||||
loc_listen.label () = label ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
std::string label ; // String identifier ...
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoEOReceiveMessTo.h \
|
|
||||||
eoEOSendMessTo.h \
|
|
||||||
eoHeaderMessTo.h \
|
|
||||||
eoKillMessTo.h \
|
|
||||||
eoPublishMessTo.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoEOReceiveMessTo.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
A message expressing an immigration need.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoEOReceiveMessTo_h
|
|
||||||
#define eoEOReceiveMessTo_h
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessTo.h>
|
|
||||||
|
|
||||||
template <class EOT> class eoEOReceiveMessTo : public eoMessTo <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoEOReceiveMessTo () : eoMessTo <EOT> ("eoEOReceiveMessTo") {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nothing else ! :-)
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoEOSendMessTo.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef eoEOSendMessTo_h
|
|
||||||
#define eoEOSendMessTo_h
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#ifdef HAVE_SSTREAM
|
|
||||||
#include <sstream>
|
|
||||||
#else
|
|
||||||
#include <strstream.h>
|
|
||||||
#endif
|
|
||||||
#include <eoPop.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessTo.h>
|
|
||||||
|
|
||||||
|
|
||||||
/** A message embeding immigrants to send to ... */
|
|
||||||
template <class EOT> class eoEOSendMessTo : public eoMessTo <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoEOSendMessTo (eoPop <EOT> & _pop )
|
|
||||||
: eoMessTo <EOT> ("eoEOSendMessTo"),
|
|
||||||
pop (_pop)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/**
|
|
||||||
To send the given population ...
|
|
||||||
*/
|
|
||||||
void operator () (eoLocalListener <EOT> & loc_listen) {
|
|
||||||
eoMessTo <EOT> :: operator () (loc_listen) ;
|
|
||||||
#ifdef HAVE_SSTREAM
|
|
||||||
std::ostringstream f;
|
|
||||||
pop.printOn(f);
|
|
||||||
comm.Send(f.str().c_str(), f.str().size(), MPI::CHAR, loc_listen.number(), 0);
|
|
||||||
#else
|
|
||||||
std::ostrstream f;
|
|
||||||
pop.printOn (f);
|
|
||||||
comm.Send (f.str(), f.pcount(), MPI::CHAR, loc_listen.number(), 0);
|
|
||||||
#endif
|
|
||||||
loc_listen.need_immigration () = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
eoPop <EOT> & pop ; // The set of EO to send.
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoHeaderMessTo.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoHeaderMessTo_h
|
|
||||||
#define eoHeaderMessTo_h
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
|
|
||||||
template <class EOT> class eoLocalListener ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
A header is an identifier for the kind of
|
|
||||||
message to be then sent ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoHeaderMessTo : public std::string {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor.
|
|
||||||
The std::string identifiant id given in parameter.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoHeaderMessTo (std::string label) :
|
|
||||||
|
|
||||||
std::string (label),
|
|
||||||
comm (MPI :: COMM_WORLD) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Emission of the header to the next process. The body message
|
|
||||||
should then follow ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
void operator () (eoLocalListener <EOT> & loc_listen) {
|
|
||||||
|
|
||||||
comm.Send (c_str (), size () + 1, MPI :: CHAR, loc_listen.number (), 0) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
MPI :: Comm & comm ; // Communicator
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoKillMessTo.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
To destroy a distant agent ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoKillMessTo_h
|
|
||||||
#define eoKillMessTo_h
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessTo.h>
|
|
||||||
|
|
||||||
template <class EOT> class eoKillMessTo : public eoMessTo <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoKillMessTo () : eoMessTo <EOT> ("eoKillMessTo") {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nothing else ! :-)
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoPublishMessTo.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
To let know from distributed algos the std::string identifier
|
|
||||||
of the home process ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoPublishMessTo_h
|
|
||||||
#define eoPublishMessTo_h
|
|
||||||
|
|
||||||
#include <mpi.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <paradisEO/comm/messages/eoMessTo.h>
|
|
||||||
#include <paradisEO/comm/eoLocalListener.h>
|
|
||||||
|
|
||||||
template <class EOT> class eoPublishMessTo : public eoMessTo <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoPublishMessTo (std::string & _label
|
|
||||||
) :
|
|
||||||
eoMessTo <EOT> ("eoPublishMessTo"),
|
|
||||||
label (_label) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () (eoLocalListener <EOT> & loc_listen) {
|
|
||||||
|
|
||||||
eoMessTo <EOT> :: operator () (loc_listen) ;
|
|
||||||
comm.Send (label.c_str (), label.size () + 1, MPI :: CHAR, loc_listen.number (), 0) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
std::string label ; // String identifier to send ...
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoPopAgent.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoPopAgent_h
|
|
||||||
#define eoPopAgent_h
|
|
||||||
|
|
||||||
#include <eoPopAlgo.h>
|
|
||||||
#include <paradisEO/comm/eoListener.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoEOSendMessTo.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
/**
|
|
||||||
A popAgent is waiting for any populations that are queued.
|
|
||||||
For each one, a processing is performed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoPopAgent {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoPopAgent (std::string _label,
|
|
||||||
eoListener <EOT> & _listen,
|
|
||||||
eoPopAlgo <EOT> & _algo
|
|
||||||
) :
|
|
||||||
label (_label),
|
|
||||||
listen (_listen),
|
|
||||||
algo (_algo) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Waiting for eoPop reception and then ...
|
|
||||||
|
|
||||||
void operator () () {
|
|
||||||
|
|
||||||
listen.publish (label) ; // To be known by everyone ...
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
|
|
||||||
listen.wait () ; // While no neighbour sends any eoPop ...
|
|
||||||
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++) {
|
|
||||||
|
|
||||||
while (! listen [i].empty ()) {
|
|
||||||
|
|
||||||
eoPop <EOT> & pop = listen [i].front () ;
|
|
||||||
std::cout << "Agent [" << label << "] on " << listen.here ().host_name << " : Receiving " << pop.size () << " individuals ..." << std::endl ;
|
|
||||||
algo (pop) ;
|
|
||||||
eoEOSendMessTo <EOT> mess (pop) ;
|
|
||||||
mess (listen [i]) ; // Coming back ...
|
|
||||||
listen [i].pop () ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
std::string label ; // std::string identifier
|
|
||||||
eoListener <EOT> & listen ; // EO's listener
|
|
||||||
eoPopAlgo <EOT> & algo ; // Local supplied algo
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoSolAgent.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoSolAgent_h
|
|
||||||
#define eoSolAgent_h
|
|
||||||
|
|
||||||
#include <eoSolAlgo.h>
|
|
||||||
#include <paradisEO/comm/eoListener.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoEOSendMessTo.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
/**
|
|
||||||
A solAgent is waiting for any solutions that are queued.
|
|
||||||
For each one, a processing is performed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoSolAgent {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoSolAgent (std::string _label,
|
|
||||||
eoListener <EOT> & _listen,
|
|
||||||
eoSolAlgo <EOT> & _algo
|
|
||||||
) :
|
|
||||||
label (_label),
|
|
||||||
listen (_listen),
|
|
||||||
algo (_algo) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Waiting for eoPop reception and then ...
|
|
||||||
|
|
||||||
void operator () () {
|
|
||||||
|
|
||||||
listen.publish (label) ; // To be known by everyone ...
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
|
|
||||||
listen.wait () ; // While no neighbour sends any eoPop ...
|
|
||||||
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++) {
|
|
||||||
|
|
||||||
while (! listen [i].empty ()) {
|
|
||||||
|
|
||||||
EOT & sol = listen [i].front () ;
|
|
||||||
std::cout << "Agent [" << label << "] on " << listen.here ().host_name << " : Receiving one individual ..." << std::endl ;
|
|
||||||
algo (sol) ;
|
|
||||||
eoPop <EOT> pop ;
|
|
||||||
pop.push_back (sol) ;
|
|
||||||
eoEOSendMessTo <EOT> mess (pop) ;
|
|
||||||
mess (listen [i]) ; // Coming back ...
|
|
||||||
listen [i].pop () ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
std::string label ; // std::string identifier
|
|
||||||
eoListener <EOT> & listen ; // EO's listener
|
|
||||||
eoSolAlgo <EOT> & algo ; // Local supplied algo
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoDistEvalEasyEA.h \
|
|
||||||
eoDistEvalEasyEA.h \
|
|
||||||
eoDistPopEvalFunc.h \
|
|
||||||
eoEvaluator.h \
|
|
||||||
eoPopEval.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoDistEvalEasyEA.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoDistEvalEasyEA_h
|
|
||||||
#define eoDistEvalEasyEA_h
|
|
||||||
|
|
||||||
#include <eoEasyEA.h>
|
|
||||||
#include <paradisEO/comm/eoListener.h>
|
|
||||||
#include <paradisEO/eval/eoDistPopEvalFunc.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Intended for evaluation CPU cost evolutionnary algorithm ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoDistEvalEasyEA : public eoEasyEA <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor. Caution ! The provided label is the one
|
|
||||||
of distributed evaluators to search for and not those of
|
|
||||||
the master program, which is isn't necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoDistEvalEasyEA (eoListener <EOT> & _listen,
|
|
||||||
eoEasyEA <EOT> & _ea,
|
|
||||||
std::string _label
|
|
||||||
) :
|
|
||||||
pop_eval (eoDistPopEvalFunc <EOT> (_listen, _label, _ea.eval)),
|
|
||||||
eoEasyEA <EOT> (_ea.continuator,
|
|
||||||
pop_eval,
|
|
||||||
_ea.breed,
|
|
||||||
_ea.replace
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
eoDistPopEvalFunc <EOT> pop_eval ;
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoDistPopEvalFunc.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoDistPopEvalFunc_h
|
|
||||||
#define eoDistPopEvalFunc_h
|
|
||||||
|
|
||||||
#include <eoPopEvalFunc.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoEOSendMessTo.h>
|
|
||||||
|
|
||||||
template <class EOT> class eoDistPopEvalFunc : public eoPopEvalFunc <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoDistPopEvalFunc (eoListener <EOT> & _listen,
|
|
||||||
std::string & _label,
|
|
||||||
eoEvalFunc <EOT> & _eval
|
|
||||||
) :
|
|
||||||
listen (_listen),
|
|
||||||
label (_label),
|
|
||||||
eval (_eval) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () (eoPop <EOT> & _parents, eoPop <EOT> & _offspring) {
|
|
||||||
|
|
||||||
int num_eval = 0 ; // How many distributed evaluators ?
|
|
||||||
int old_size = _offspring.size () ;
|
|
||||||
|
|
||||||
do {
|
|
||||||
listen.update () ;
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++) {
|
|
||||||
if (listen [i].label () == label)
|
|
||||||
num_eval ++ ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_eval == 0) {
|
|
||||||
std::cout << "No [" << label << "] available ..." << std::endl ;
|
|
||||||
std::cout << "Waiting for a few seconds ..." << std::endl ;
|
|
||||||
sleep (2) ;
|
|
||||||
}
|
|
||||||
} while (num_eval == 0) ;
|
|
||||||
|
|
||||||
|
|
||||||
// Partitioning ...
|
|
||||||
|
|
||||||
int j = 0, l = 0 ;
|
|
||||||
|
|
||||||
bool t [listen.size ()] ;
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++)
|
|
||||||
t [i] = false ;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < num_eval ; i ++) {
|
|
||||||
|
|
||||||
eoPop <EOT> pop ;
|
|
||||||
for (int k = 0 ; k < old_size / num_eval ; k ++)
|
|
||||||
pop.push_back (_offspring [j ++]) ;
|
|
||||||
|
|
||||||
if (i < old_size % num_eval)
|
|
||||||
pop.push_back (_offspring [j ++]) ;
|
|
||||||
|
|
||||||
// Next evaluator ...
|
|
||||||
while (listen [l].label () != label) {
|
|
||||||
|
|
||||||
l ++ ;
|
|
||||||
}
|
|
||||||
|
|
||||||
eoEOSendMessTo <EOT> mess (pop) ;
|
|
||||||
mess (listen [l]) ;
|
|
||||||
t [l ++] = true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On standby of the returns
|
|
||||||
_offspring.clear () ;
|
|
||||||
|
|
||||||
// while (_offspring.size () != old_size) {
|
|
||||||
|
|
||||||
// listen.wait () ;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++)
|
|
||||||
if (t [i]) {
|
|
||||||
listen [i].wait () ;
|
|
||||||
//while (! listen [i].empty ()) {
|
|
||||||
|
|
||||||
eoPop <EOT> & pop = listen [i].front () ;
|
|
||||||
|
|
||||||
for (int m = 0 ; m < pop.size () ; m ++)
|
|
||||||
_offspring.push_back (pop [m]) ;
|
|
||||||
|
|
||||||
listen [i].pop () ;
|
|
||||||
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
eoListener <EOT> & listen ;
|
|
||||||
std::string label ; // String identifier of evaluators
|
|
||||||
eoEvalFunc <EOT> & eval ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoEvaluator.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoEvaluator_h
|
|
||||||
#define eoEvaluator_h
|
|
||||||
|
|
||||||
#include <paradisEO/eoPopAgent.h>
|
|
||||||
#include <paradisEO/eval/eoPopEval.h>
|
|
||||||
#include <eoEvalFunc.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
/**
|
|
||||||
A special pop. based agent, applied to eval sub_populations.
|
|
||||||
Rather intended for evolutionnary algorithms, with evaluations
|
|
||||||
performed remotely.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoEvaluator : public eoPopAgent <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoEvaluator (std::string _label,
|
|
||||||
eoListener <EOT> & _listen,
|
|
||||||
eoEvalFunc <EOT> & _eval
|
|
||||||
) :
|
|
||||||
pop_eval (_eval),
|
|
||||||
eoPopAgent <EOT> (_label,
|
|
||||||
_listen,
|
|
||||||
pop_eval) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
eoPopEval <EOT> pop_eval ;
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoPopEval.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoPopEval_h
|
|
||||||
#define eoPopEval_h
|
|
||||||
|
|
||||||
#include <eoEvalFunc.h>
|
|
||||||
#include <apply.h>
|
|
||||||
#include <eoPopAlgo.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
An evaluator which computes fitnesses of a given population in a
|
|
||||||
sequentially manner.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoPopEval : public eoPopAlgo <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoPopEval (eoEvalFunc <EOT> & _eval) : eval(_eval) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Values sequentially each EO from the pop. given in parameter.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void operator () (eoPop <EOT> & _pop) {
|
|
||||||
|
|
||||||
for (unsigned i = 0 ; i < _pop.size () ; i ++)
|
|
||||||
_pop [i].invalidate () ;
|
|
||||||
|
|
||||||
apply <EOT> (eval, _pop) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
eoEvalFunc <EOT> & eval ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
SUBDIRS = topologies
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoConnectivity.h \
|
|
||||||
eoCyclicGenContinue.h \
|
|
||||||
eoIslandsEasyEA.h \
|
|
||||||
eoMigUpdater.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoConnectivity.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef eoConnectivity_h
|
|
||||||
#define eoConnectivity_h
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <paradisEO/comm/eoLocalListener.h>
|
|
||||||
#include <paradisEO/comm/eoListener.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
It defines the entering and outgoing channels of communication
|
|
||||||
towards the other considered agents.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoConnectivity {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor. Names of others processes to consider in the topology are given
|
|
||||||
in parameter.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoConnectivity (eoListener <EOT> & _listen,
|
|
||||||
std::vector <std::string> & _sel_neigh
|
|
||||||
) :
|
|
||||||
listen (_listen),
|
|
||||||
sel_neigh (_sel_neigh) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Computes the subset of neighbours to receive
|
|
||||||
immigrants from ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual std::vector <eoLocalListener <EOT> *> from () = 0 ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Computes the subset of neighbours to send
|
|
||||||
emigrants to ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual std::vector <eoLocalListener <EOT> *> to () = 0 ;
|
|
||||||
|
|
||||||
protected :
|
|
||||||
|
|
||||||
eoListener <EOT> & listen ;
|
|
||||||
|
|
||||||
std::vector <std::string> sel_neigh ;
|
|
||||||
|
|
||||||
bool selected (std::string & id) {
|
|
||||||
|
|
||||||
for (int i = 0 ; i < sel_neigh.size () ; i ++)
|
|
||||||
if (sel_neigh [i] == id)
|
|
||||||
return true ;
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoCyclicGenContinue.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoCyclicGenContinue_h
|
|
||||||
#define eoCyclicGenContinue_h
|
|
||||||
|
|
||||||
#include <eoContinue.h>
|
|
||||||
#include <eoPop.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
This continuator returns false in a periodic way during generations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoCyclicGenContinue: public eoContinue <EOT> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor. The frequency is given in parameter.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoCyclicGenContinue (unsigned _freq,
|
|
||||||
unsigned init_count = 0) :
|
|
||||||
freq (_freq),
|
|
||||||
count (init_count) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return true only if the current number of performed generations
|
|
||||||
modulo the frequency equals none.
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual bool operator () (const eoPop <EOT> & pop) {
|
|
||||||
|
|
||||||
count ++ ;
|
|
||||||
return (count % freq) != 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
unsigned count, freq ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoIslandsEasyEA"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoIslandsEasyEA_h
|
|
||||||
#define eoIslandsEasyEA_h
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <paradisEO/comm/eoListener.h>
|
|
||||||
#include <paradisEO/island/eoConnectivity.h>
|
|
||||||
#include <paradisEO/island/eoMigUpdater.h>
|
|
||||||
#include <eoContinue.h>
|
|
||||||
#include <eoSelect.h>
|
|
||||||
#include <eoReplacement.h>
|
|
||||||
#include <utils/eoCheckPoint.h>
|
|
||||||
#include <utils/eoUpdater.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
An island distributed easy evolutionary algorithm.
|
|
||||||
It embeds an instance of easyEA. The behavior of this
|
|
||||||
last one isn't modified. However, exchanges of individuals
|
|
||||||
are performed with other EAs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoIslandsEasyEA : public eoEasyEA <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoIslandsEasyEA (std::string _id,
|
|
||||||
eoListener <EOT> & _listen,
|
|
||||||
eoConnectivity <EOT> & _conn,
|
|
||||||
eoEasyEA <EOT> & _ea,
|
|
||||||
eoContinue <EOT> & _cont,
|
|
||||||
eoSelect <EOT> & _select,
|
|
||||||
eoReplacement <EOT> & _replace
|
|
||||||
) :
|
|
||||||
id (_id),
|
|
||||||
listen (_listen),
|
|
||||||
conn (_conn),
|
|
||||||
chkp (_ea.continuator),
|
|
||||||
mig_upd (_listen,
|
|
||||||
_conn,
|
|
||||||
_cont,
|
|
||||||
_select,
|
|
||||||
_replace),
|
|
||||||
eoEasyEA <EOT> (chkp,
|
|
||||||
_ea.eval,
|
|
||||||
_ea.breed,
|
|
||||||
_ea.replace
|
|
||||||
) {
|
|
||||||
chkp.add (mig_upd) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void operator () (eoPop <EOT> & pop) {
|
|
||||||
|
|
||||||
mig_upd (pop) ; // Sets pop. to send/receive EO
|
|
||||||
listen.publish (id) ;
|
|
||||||
eoEasyEA <EOT> :: operator () (pop) ;
|
|
||||||
listen.publish ("_") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
// Internal components
|
|
||||||
|
|
||||||
std::string id ; // String identifiant of this algorithm
|
|
||||||
eoListener <EOT> & listen ; // The neighbouring of concurrent algos
|
|
||||||
eoConnectivity <EOT> & conn ; // Communication topology
|
|
||||||
eoCheckPoint <EOT> chkp ;
|
|
||||||
eoMigUpdater <EOT> mig_upd ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoMigUpdater.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoMigUpdater_h
|
|
||||||
#define eoMigUpdater_h
|
|
||||||
|
|
||||||
#include <eoPop.h>
|
|
||||||
#include <eoSelect.h>
|
|
||||||
#include <eoReplacement.h>
|
|
||||||
#include <eoContinue.h>
|
|
||||||
#include <utils/eoUpdater.h>
|
|
||||||
#include <paradisEO/island/eoConnectivity.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoEOSendMessTo.h>
|
|
||||||
#include <paradisEO/comm/messages/to/eoEOReceiveMessTo.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
An updater. After any evolution of an evolutionnary algorithm, it
|
|
||||||
moves some EO from/into the current population from/to a subset
|
|
||||||
of the neighbouring algos.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoMigUpdater : public eoUpdater {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor. Some features which should be specified.
|
|
||||||
- The neighbouring interface,
|
|
||||||
- The communication topology,
|
|
||||||
- Which EO instancies from the given population should be sent ?
|
|
||||||
- How integrate new immigrants ?
|
|
||||||
- Then, an event to determine the time to ask neighbouring sources
|
|
||||||
for sending sets of EO.
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoMigUpdater (eoListener <EOT> & _listen,
|
|
||||||
eoConnectivity <EOT> & _conn,
|
|
||||||
eoContinue <EOT> & _cont,
|
|
||||||
eoSelect <EOT> & _select,
|
|
||||||
eoReplacement <EOT> & _replace) :
|
|
||||||
listen (_listen),
|
|
||||||
conn (_conn),
|
|
||||||
cont (_cont),
|
|
||||||
select (_select),
|
|
||||||
replace (_replace) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Sets the given population to be the one to receive and/or send EO
|
|
||||||
*/
|
|
||||||
|
|
||||||
void operator () (eoPop <EOT> & _pop) {
|
|
||||||
|
|
||||||
pop = & _pop ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Should be often called. (after each local evolution ?)
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual void operator () () {
|
|
||||||
|
|
||||||
listen.update () ;
|
|
||||||
// listen.display () ;
|
|
||||||
|
|
||||||
std::vector <eoLocalListener <EOT> *> src = conn.from (), dest = conn.to () ;
|
|
||||||
|
|
||||||
// Any coming immigrants ?
|
|
||||||
for (int i = 0 ; i < src.size () ; i ++) {
|
|
||||||
src [i] -> update () ;
|
|
||||||
while (! src [i] -> empty ()) {
|
|
||||||
replace (* pop, src [i] -> front ()) ;
|
|
||||||
std::cout << "[" << listen.here ().host_name << "] Arrival of " << src [i] -> front ().size () << " individuals ..." << std::endl ;
|
|
||||||
src [i] -> pop () ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Any request ?
|
|
||||||
for (int i = 0 ; i < dest.size () ; i ++)
|
|
||||||
if (dest [i] -> need_immigration ()) {
|
|
||||||
eoPop <EOT> emm ; // Emmigrants
|
|
||||||
select (* pop, emm) ;
|
|
||||||
eoEOSendMessTo <EOT> mess (emm) ;
|
|
||||||
mess (* (dest [i])) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Any request to submit ?
|
|
||||||
if (! cont (* pop))
|
|
||||||
for (int i = 0 ; i < src.size () ; i ++) {
|
|
||||||
eoEOReceiveMessTo <EOT> mess ;
|
|
||||||
mess (* (src [i])) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
|
||||||
|
|
||||||
eoConnectivity <EOT> & conn ; // The used topology
|
|
||||||
|
|
||||||
eoContinue <EOT> & cont ; /* The 'event' which determines
|
|
||||||
need of immigration */
|
|
||||||
|
|
||||||
eoSelect <EOT> & select ; /* In order to select emmigrants
|
|
||||||
from the current population */
|
|
||||||
|
|
||||||
eoReplacement <EOT> & replace ; // The replacement procedure
|
|
||||||
|
|
||||||
eoPop <EOT> * pop ; // The population considered
|
|
||||||
|
|
||||||
eoListener <EOT> & listen ; // A reference to the neighbouring
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
# Copyright (C) 2004 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
|
||||||
|
|
||||||
pkginclude_HEADERS = eoFullConnectivity.h\
|
|
||||||
eoRingConnectivity.h
|
|
||||||
|
|
||||||
### Makefile.am ends here
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoFullConnectivity.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoFullConnectivity_h
|
|
||||||
#define eoFullConnectivity_h
|
|
||||||
|
|
||||||
#include <paradisEO/island/eoConnectivity.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Each algorithm is also connected to the whole neighbouring ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoFullConnectivity : public eoConnectivity <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoFullConnectivity (eoListener <EOT> & _listen,
|
|
||||||
std::vector <std::string> & _sel_neigh
|
|
||||||
) : eoConnectivity <EOT> (_listen, _sel_neigh) {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::vector <eoLocalListener <EOT> *> from () {
|
|
||||||
|
|
||||||
listen.update () ;
|
|
||||||
|
|
||||||
std::vector <eoLocalListener <EOT> *> v ;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++)
|
|
||||||
if (i != listen.here ().number () && selected (listen [i].label ()))
|
|
||||||
v.push_back (& listen [i]) ;
|
|
||||||
|
|
||||||
return v ;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::vector <eoLocalListener <EOT> *> to () {
|
|
||||||
|
|
||||||
listen.update () ;
|
|
||||||
|
|
||||||
std::vector <eoLocalListener <EOT> *> v ;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < listen.size () ; i ++)
|
|
||||||
if (i != listen.here ().number () && selected (listen [i].label ()))
|
|
||||||
v.push_back (& listen [i]) ;
|
|
||||||
|
|
||||||
return v ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
// "eoRingConnectivity.h"
|
|
||||||
|
|
||||||
// (c) OPAC Team, LIFL, 2002
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
Cont act: cahon@lifl.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef eoRingConnectivity_h
|
|
||||||
#define eoRingConnectivity_h
|
|
||||||
|
|
||||||
#include <paradisEO/island/eoConnectivity.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Each algorithm has a single std::pair of entering and outgoing
|
|
||||||
neighbours, so that the unit constitutes a circular topology.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class EOT> class eoRingConnectivity : public eoConnectivity <EOT> {
|
|
||||||
|
|
||||||
public :
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
eoRingConnectivity (eoListener <EOT> & _listen,
|
|
||||||
std::vector <std::string> & _sel_neigh
|
|
||||||
) : eoConnectivity <EOT> (_listen, _sel_neigh) {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::vector <eoLocalListener <EOT> *> from () {
|
|
||||||
|
|
||||||
listen.update () ;
|
|
||||||
|
|
||||||
std::vector <eoLocalListener <EOT> *> v ;
|
|
||||||
int i, k = listen.size () ;
|
|
||||||
|
|
||||||
for (i = 0 ; i < k ; i ++) {
|
|
||||||
if (listen [i] == listen.here ())
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = (i - 1 + k) % k ; j != i ; j = (j - 1 + k) % k)
|
|
||||||
if (selected (listen [j].label ())) {
|
|
||||||
v.push_back (& listen [j]) ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return v ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual std::vector <eoLocalListener <EOT> *> to () {
|
|
||||||
|
|
||||||
listen.update () ;
|
|
||||||
|
|
||||||
std::vector <eoLocalListener <EOT> *> v ;
|
|
||||||
int i, k = listen.size () ;
|
|
||||||
|
|
||||||
for (i = 0 ; i < k ; i ++)
|
|
||||||
if (listen [i] == listen.here ())
|
|
||||||
break ;
|
|
||||||
|
|
||||||
for (int j = (i + 1) % k ; j != i ; j = (j + 1) % k)
|
|
||||||
if (selected (listen [j].label ())) {
|
|
||||||
v.push_back (& listen [j]) ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return v ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in a new issue