/* ---------------------------------------------------------------------------- ex21.C mbwall 1jan96 Copyright (c) 1995-1996 Massachusetts Institute of Technology DESCRIPTION: This example illustrates various uses of the AlleleSet in concert with the ArrayAlleleGenome. In particular, we use the RealGenome to show how you can use the enumerated and bounded types of allele sets. You can define one allele set for an entire array, or you can define one allele set for each element in the array. The constructor that you use to create the array determines which behaviour you'll get. ---------------------------------------------------------------------------- */ #include #include #include #include #include float Objective1(GAGenome &); float Objective2(GAGenome &); float Objective3(GAGenome &); float Objective4(GAGenome &); int main(int argc, char** argv) { cout << "Example 21\n\n"; cout << "This example shows various uses of the allele set object\n"; cout << "in combination with the real number genome.\n\n"; cout.flush(); // See if we've been given a seed to use (for testing purposes). When you // specify a random seed, the evolution will be exactly the same each time // you use that seed number. unsigned int seed = 0; for(int ii=1; ii genome.gene(i-1)) value += 1.0; return value; } // This objective tries to maximize each element in the genome. float Objective4(GAGenome& g) { GARealGenome& genome = (GARealGenome&)g; float value=0.0; for(int i=0; i