Brute force search for the maximum using MonteCarlo
Then using a set of random inputs $x_i$, I try and find the maximum of the function in C# using the Parallel For in the range of $ x_i \in [0..100]$
In this case, I fixed the seed of the secret function to keep it consistent from run to run, so I can check the values.
Issues encountered and resolved:
Random is not thread safe => Create a multi-threaded random
Parallel For: I keep a thread local maximum and update the final maximum at the end with a lock to avoid multi-threaded updates to the max value
Hill climb algorithm
From a starting position in the middle of the space, take a step of 1 unit in the positive and negative direction of each $i$ dimension and obtain the results for each of these possible steps, take the best step and continue with the next step. Exiting when with the gain is too small so as not to loop endlessly due to large step. In case the gain becomes too small, it would be possible to reduce the step sucessively to get closer to the optimal solution.
Parallel version of hill climb
Call the hill climber in parallel using random starting positions.
To run:
dotnet build -c Release
dotnet run .\bin\Release\net6.0\multi-function-estimator.dll