I am trying to use linear constraints with shgo. Here is a simple MWE:
from scipy.optimize import shgo, rosen
# Set up the constraints list
constraints = [{'type': 'ineq', 'fun': lambda x, i=i: x[i+1] - x[i] - 0.1} for i in range(2)]
# Define the variable bounds
bounds = [(0, 20)]*3
# Call the shgo function with constraints
result = shgo(rosen, bounds, constraints=constraints)
# Print the optimal solution
print("Optimal solution:", result.x)
print("Optimal value:", result.fun)
An example solution satisfying these constraints is:
rosen((0.1, 0.21, 0.32))
13.046181
But if you run the code you get:
Optimal solution: None
Optimal value: None
It doesn't find a feasible solution at all! Is this a bug?
from Why does this shgo minimization fail?
No comments:
Post a Comment