20 #include "genotypes/realgenotype.h"
21 #include "randomgenerator.h"
23 #include "configurationparameters.h"
29 genes = (
float*)(
data );
38 genes = (
float*)(
data );
47 genes = (
float*)(
data );
54 "RealGenotype::configure",
55 "The ngenes must be present in the config file and its value must be greater than zero" );
56 minv = params.
getValue( prefix + QString(
"minValue" ) ).toDouble();
57 maxv = params.
getValue( prefix + QString(
"maxValue" ) ).toDouble();
59 "RealGenotype::configure",
60 "The minValue and maxValue must be different!! Check you config file" );
62 QString zipdata = params.
getValue( prefix + QString(
"data" ) );
63 if ( !zipdata.isNull() ) {
66 genes = (
float*)(
data );
67 QStringList valuesList = params.
getValue( prefix + QString(
"fitness" ) )
68 .split( QRegExp(
"\\s+"), QString::SkipEmptyParts );
69 if ( valuesList.size() > 0 ) {
72 foreach( QString avalue, valuesList ) {
80 rankv = params.
getValue( prefix + QString(
"rank" ) ).toDouble();
91 fitstring.append( QString(
"%1 ").arg(avalue) );
104 d.
describeReal(
"fitness" ).
props(
IsList ).
help(
"The fitness of the Genotype",
"The fitness of a Genotype support multi objective fitness; if you specify a vector of values they are considered different objectives of the fitness" );
105 d.
describeString(
"data" ).
help(
"The bits composing the Genotype stored in a compressed string" );
106 d.
describeReal(
"rank" ).
def( 0 ).
help(
"The rank indicate who is more fitted that others and how much; the values are dependent on the kind of GeneticAlgo used" );
110 Q_ASSERT_X( (i+1)*32 <=
size(),
112 "The value requested is beyond the dimension of this Genotype" );
113 return (
double) ( genes[i] );
117 Q_ASSERT_X( (i+1)*32 <=
size(),
119 "The value to be set is beyond the dimension of this Genotype" );
120 genes[i] = (float) ( value );
125 for(
unsigned int i=0; i<
numgenes; i++ ) {