cmaes icon indicating copy to clipboard operation
cmaes copied to clipboard

Mutable mean vector

Open Josef-Hlink opened this issue 2 years ago • 0 comments

mean is mutable

I know this might technically not be a bug, more so than a slight inconvenience.

Expected Behavior

For a school project, I want to benchmark the CMA-ES, so I tried to do some repetitions with the same initial vector. To my surprise, the optimiser seemed to "remember" the last optimal solution.

Current Behavior and Steps to Reproduce


import SomePlot from .myplotscript

repetitions = 10
fmins = np.zeros(shape=(repetitions, pop_size))

X0 = np.arange(0, 100)

gen = 0
for rep in range(repetitions):
    optimizer = CMA(mean=X0)
    terminate = False
    while not terminate:
        # dosomestuff
        best_fmin = ...
    fmins[rep][gen] = best_fmin
    gen += 1

SomePlot(fmins)

Context

I know that there is a very easy workaround, just changing mean=X0 to mean=X0.copy() does the trick. I find this quite ugly though, and it might clear some confusion for other users if the copying would be done behind the screens. It is not a pressing issue whatsoever, I just really like this project and I hope that me pointing out this issue might make the experience working with it even more enjoyable.

Josef-Hlink avatar Jun 20 '22 05:06 Josef-Hlink