-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement Sofomore.active(kernel)
method
#4
Comments
Another question: why don't we activate the kernel unconditionally? |
Tentative code: def activate(self, kernel, reset_termination=True, reset_stagnation=False):
if reset_termination:
kernel._stopdict.clear()
if reset_stagnation:
kernel.fit.histbest.clear() # reset opts['tolstagnation']
kernel.fit.histmedian.clear() # ditto
ikernel = self.kernels.index(kernel) # kernel must be in self.kernels
if ikernel in self._active_indices:
return
self._active_indices += [ikernel]
# remove "turned off" status
if kernel.opts['termination_callback']:
kernel.opts['termination_callback'] = [c for c in kernel.opts['termination_callback']
if c(kernel) != 'kernel turned off'] |
Yes it was meant to read |
The tentative code was meant to activate a kernel that we inactivated beforehand, mainly for budget allocation. When we do: import cma
es = cma.CMAEvolutionStrategy(10 * [1], 0.2)
es.optimize(cma.ff.sphere) The optimization is done in ~ 2000 function evaluations with a es.optimize(lambda x: cma.ff.sphere(x - 1)) The step-size of The idea was to avoid this adaptive phase that costs 1000 function evaluations when activating a kernel that we did not turn off on purpose (mainly for budget allocation) during the optimization of a changing fitness. |
Maybe we want a method that checks for deactivation status, like def inactivated(self, kernel):
"""return `True` if kernel was deactivated with `Sofomore.inactivate`, else `False`
"""
try:
for c in kernel.opts['termination_callback']:
if c(kernel) == 'kernel turned off':
return True
except TypeError: # termination callback options were not iterable
pass
return False
# or:
def inactivated(self, kernel):
s = kernel.stop(check=False)
for k in s:
if k == 'callback' and 'kernel turned off' in s[k]:
return True
return False which would allow to write moes.activate(kernel) if moes.inactivated(kernel) else None to activate the kernel only when it was inactivated before. |
The
Sofomore.activate
method should be implemented, in order to be able to refine a kernel.kernel._stopdict.clear()
during activation==
mean to read!=
such that theturned off
termination is removed?The text was updated successfully, but these errors were encountered: