A mixing desk hums. It has dim sliders, each set between 0 and 10, and the sound engineer knows
one thing about the hum: every slider adds its own hum, independently of the others. Each
slider's hum is smallest at one hidden position and grows smoothly (not always symmetrically) the
further you move it from there. You cannot see the desk; you can only set the sliders and listen.
Write set_sliders(f, dim, bounds, budget) that returns the quietest setting you can find, as a
list of dim numbers.
f(x)returns the total hum of settingx(lower is better, 0 is silence). Every call counts.boundsis[(0.0, 10.0)] * dim; values outside are pulled back to the edge.- You may call
fat mostbudgettimes. One more call raisesBudgetExceeded.
The tests run sound_check(set_sliders, dim, budget, seed), which hides a desk and reports the hum
at the setting you return. Try it with Run: print(sound_check(set_sliders, 3, 45, 1)).
How this problem is scored
A setting passes if it is at least as quiet as the best of budget random settings (the judge
draws them itself). Its quality (0 to 100) measures, on a logarithmic scale, how much closer
to silence you get than that random search: every factor of ten counts the same, and a hum of
1e-8 or less scores 100.
Examples
Input: sound_check(set_sliders, 3, 45, 1)
Output: {"value": ..., "evaluations": ..., "random_search": 0.0862...}
passes when value <= random_search
Input: sound_check(lambda f, dim, bounds, budget: [5.0] * dim, 3, 45, 1)
Output: fails: every slider in the middle is louder than random search
Constraints
3 <= dim <= 8,14 * dim <= budget <= 18 * dim- Use
randomfor any randomness (the tests seed it) and bound loops by evaluations, never by the clock.
Goals
- Exploit a known structure of a hidden function
- Minimise a function of one variable with few evaluations
- Share an evaluation budget fairly between sub-problems