Adding sharing - needed to modify quite a few files, like eoDistance.h
make_algo_scalar.h and all related files, and the like
This commit is contained in:
parent
13c7062858
commit
795f63b7fe
14 changed files with 244 additions and 93 deletions
|
|
@ -10,7 +10,7 @@
|
|||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -30,13 +30,17 @@ int main(int argc, char* argv[])
|
|||
|
||||
// EVAL
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
eoEvalFuncPtr<EOT, float> mainEval( binary_value<EOT> );
|
||||
eoEvalFuncPtr<EOT, double> mainEval( binary_value<EOT> );
|
||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// REPRESENTATION
|
||||
// the genotype - through a genotype initializer
|
||||
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
||||
|
||||
// if you want to do sharing, you'll need a distance.
|
||||
// here Hamming distance
|
||||
eoHammingDistance<EOT> dist;
|
||||
|
||||
// OPERATORS
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||
|
|
@ -56,7 +60,7 @@ int main(int argc, char* argv[])
|
|||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
// GENERATION
|
||||
// algorithm (need the operator!)
|
||||
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op, &dist);
|
||||
|
||||
///// End of construction of the algorith
|
||||
/////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
@param _chrom A binary chromosome
|
||||
*/
|
||||
|
||||
template <class Chrom> float binary_value(const Chrom& _chrom)
|
||||
template <class Chrom> double binary_value(const Chrom& _chrom)
|
||||
{
|
||||
float sum = 0;
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _chrom.size(); i++)
|
||||
if (_chrom[i])
|
||||
sum += _chrom[i];
|
||||
|
|
|
|||
Reference in a new issue