Black box optimization part 1
Write a hillclimber to maximize the function double eval(int *vec) contained in each of the the two object files below. These are two black box functions and I want you to try maximize both. Black box means that you do not know what the function does -- all you know is that if you send it a (int *vec) , it will return a double, in the range 0 through 100. main.cpp contains a sample call and return from eval. The size of the integer vector is 100.
Not only do I want the maximum returned by the function, I also want the value of each element in vec when evaluating vec causes the function to reach its maximum.
A sample main.cpp and links to
You will need to use g++ for your compilation. You can use C or C++ to implement your algorithm but you must use the linux g++ compiler for compilation.
% g++ -o solver main.cpp eval.o
Should compile your hill climber in main.cpp with the eval function in eval.o
Assume that vec can only contain 0's or 1's, that is, it is a bit string. Going thru all 2^100 combinations of the 100 bit vector is not a viable option.
Answer the following questions:
General rules
You may talk strategies but no code sharing. You are, of course, free to
use the web or other resources to come up with implementations that
attack the problem below.
Good Luck