*** empty log message ***
This commit is contained in:
parent
aec83a0014
commit
6afc695dce
9 changed files with 315 additions and 0 deletions
21
eo/tutorial/ParadisEO/Lesson2/Makefile
Normal file
21
eo/tutorial/ParadisEO/Lesson2/Makefile
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
ALL = MasterDistEvalBitEA SlaveDistEvalBitEA
|
||||
|
||||
lesson2 : MasterDistEvalBitEA SlaveDistEvalBitEA
|
||||
|
||||
all : $(ALL)
|
||||
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *~
|
||||
|
||||
MasterDistEvalBitEA : MasterDistEvalBitEA.o
|
||||
mpiCC -DPACKAGE=\"eo\" -o MasterDistEvalBitEA MasterDistEvalBitEA.o ../../../src/utils/libeoutils.a ../../../src/libeo.a
|
||||
|
||||
MasterDistEvalBitEA.o : MasterDistEvalBitEA.cpp binary_value.h
|
||||
mpiCC -DPACKAGE=\"eo\" -I. -I../../../src -c MasterDistEvalBitEA.cpp
|
||||
|
||||
SlaveDistEvalBitEA : SlaveDistEvalBitEA.o
|
||||
mpiCC -DPACKAGE=\"eo\" -o SlaveDistEvalBitEA SlaveDistEvalBitEA.o ../../../src/utils/libeoutils.a ../../../src/libeo.a
|
||||
|
||||
SlaveDistEvalBitEA.o : SlaveDistEvalBitEA.cpp binary_value.h
|
||||
mpiCC -DPACKAGE=\"eo\" -I. -I../../../src -c SlaveDistEvalBitEA.cpp
|
||||
|
||||
41
eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA.cpp
Normal file
41
eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <stdexcept> // runtime_error
|
||||
#include <iostream> // cout
|
||||
#include <strstream> // ostrstream, istrstream
|
||||
|
||||
#include <paradiseo>
|
||||
#include <ga.h>
|
||||
|
||||
typedef eoBit<double> Indi; // A bitstring with fitness double
|
||||
|
||||
#include "binary_value.h"
|
||||
|
||||
void main_function(int argc, char **argv) {
|
||||
|
||||
eoEvalFuncPtr <Indi, double, const vector <bool> & > eval (binary_value) ;
|
||||
|
||||
eoListener <Indi> listen (argc, argv) ;
|
||||
|
||||
eoEvaluator <Indi> evaluator ("Mars",
|
||||
listen,
|
||||
eval) ;
|
||||
|
||||
// Runs
|
||||
evaluator () ;
|
||||
}
|
||||
|
||||
// A main that catches the exceptions
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
17
eo/tutorial/ParadisEO/Lesson2/binary_value.h
Normal file
17
eo/tutorial/ParadisEO/Lesson2/binary_value.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <eo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
// INIT
|
||||
double binary_value(const vector<bool>& _chrom)
|
||||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _chrom.size(); i++)
|
||||
sum += _chrom[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
4
eo/tutorial/ParadisEO/Lesson2/paradiseo.config
Normal file
4
eo/tutorial/ParadisEO/Lesson2/paradiseo.config
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
127.0.0.1 0 ${HOME}/eo/tutorial/ParadisEO/Lesson2/MasterDistEvalBitEA
|
||||
127.0.0.1 1 ${HOME}/eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA
|
||||
127.0.0.1 1 ${HOME}/eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA
|
||||
127.0.0.1 1 ${HOME}/eo/tutorial/ParadisEO/Lesson2/SlaveDistEvalBitEA
|
||||
Reference in a new issue