/* ---------------------------------------------------------------------------- ex9.C mbwall 10apr95 Copyright 1995-1996 Massachusetts Institute of Technology DESCRIPTION: Sample program that illustrates how to use a GA to find the maximum value of a continuous function in two variables. This program uses a binary-to- decimal genome. ---------------------------------------------------------------------------- */ #include #include #include #include float objective(GAGenome &); int main(int argc, char **argv) { cout << "Example 9\n\n"; cout << "This program finds the maximum value in the function\n"; cout << " y = - x1^2 - x2^2\n"; cout << "with the constraints\n"; cout << " -5 <= x1 <= 5\n"; cout << " -5 <= x2 <= 5\n"; cout << "\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 i=1; i