Skip to content
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

MWE not working #24

Open
MaAl13 opened this issue Jul 31, 2024 · 0 comments
Open

MWE not working #24

MaAl13 opened this issue Jul 31, 2024 · 0 comments

Comments

@MaAl13
Copy link

MaAl13 commented Jul 31, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant