-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.optimize
Milestone
Description
Describe your issue.
When minimizing with scipy.optimize.minimize
it crashes python (kernel), with a corruption error.
This only happens when constraints are active with SLSQP
.
I also tried scipy 1.7-1.6, but it has the same issue. Also found this issue which might be related: #14159
Reproducing Code Example
import numpy as np
import scipy.optimize as sco
x = np.random.rand(22,365)
target = np.linspace(0.9, 4.0, 50)
def metric(v, weights):
return [[0, 0],[1, 1]]
def efficient_metric(v, target):
def metric_a(weights):
return metric(v, weights)[1][0]
def metric_b(weights, v):
return metric(v, weights)[0][0]
constraints = ({'type': 'eq', 'fun': lambda x: metric_a(x) - target},
{'type': 'eq', 'fun': lambda x: np.sum(x) - 1})
weights = np.array([len(v)*[1./len(v)]])
result = sco.minimize(metric_b, weights, args=(v,),
method='SLSQP', constraints=constraints)
return result
efficient_metric(x, target)
Error message
corrupted size vs. prev_size
OR
corrupted double-linked list
OR
double free or corruption (!prev)
SciPy/NumPy/Python version information
1.7.1 1.21.3 sys.version_info(major=3, minor=9, micro=2, releaselevel='final', serial=0)
Metadata
Metadata
Assignees
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.optimize