fast-cma-es
fast-cma-es copied to clipboard
MWE not working
Helo, i am trying to run your optimization on a very simple Rosenbrock function problem, but it fails.Can you tell me what is wrong with my code?
import numpy as np
from scipy.optimize import Bounds
from fcmaes.optimizer import De_cpp
from fcmaes import retry
def test_fun(params):
return np.sum(100.0 * ((params[1:]+1) - (params[:-1]+1)**2.0)**2.0 + (1 - (params[:-1]+1))**2.0)
# Main optimization function
def optimize_model():
lb = np.ones(10) * -5 # Lower bound set to -5
ub = np.ones(10) * 10 # Upper bound set to 10
bounds = Bounds(lb, ub)
result = retry.minimize(test_fun, bounds, num_retries=1, optimizer=De_cpp(1000))
return result
# Run the optimization
if __name__ == "__main__":
result = optimize_model()
print(result)
print(result.x)
print(result.fun)
Returns: 'NoneType' object is not subscriptable 2024-07-31 14:14:28.382 | DEBUG | fcmaes.retry:dump:388 - 0.07 0 1 0 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 0.00 0.00 [] [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] success: True fun: 1.7976931348623157e+308 x: [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00] nfev: 0 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] 1.7976931348623157e+308