Questions tagged [scipy-optimize]

Tag used for questions regarding minimizing or maximizing objective functions with python module `scipy.optimize`. Also add more generic tags to your question (`python`, `scipy`)

Module SciPy optimize is used for minimizing (or maximizing) objective functions. It includes solvers for nonlinear problems, linear programming, constrained and nonlinear least-squares, root finding and curve fitting.

1017 questions
5
votes
1 answer

defining the Hessian as zero

While using scipy.optimize.minimize with the trust-constr method I got this UserWarning: scipy\optimize\_hessian_update_strategy.py:187: UserWarning: delta_grad == 0.0. Check if the approximated function is linear. If the function is linear better…
theother
  • 307
  • 2
  • 16
4
votes
0 answers

How to give the initial guess step length for the line search

I found that the initial guess step length for the line search in NLCG and L-BFGS is determined by "old_old_fval = old_fval + np.linalg.norm(gfk) / 2", (line 1621 in https://github.com/scipy/scipy/blob/master/scipy/optimize/_optimize.py). And the…
Lian
  • 41
  • 1
4
votes
2 answers

Heuristic to choose five column arrays that maximise the dot product

I have a sparse 60000x10000 matrix M where each element is either a 1 or 0. Each column in the matrix is a different combination of signals (ie. 1s and 0s). I want to choose five column vectors from M and take the Hadamard (ie. element-wise) product…
Alex Pharaon
  • 121
  • 1
  • 7
4
votes
1 answer

2D local maxima and minima in Python

I have a data frame, df, representing a correlation matrix, with this heatmap with example extrema. Every point has, obviously, (x,y,value): I am looking into getting the local extrema. I looked into argrelextrema, I tried it on individual rows and…
Adam
  • 3,872
  • 6
  • 36
  • 66
4
votes
1 answer

How to set proper direction vectors for Powell's method on scipy.optimize.minimize?

I am building some spring networks in order to build a model for rubber traction tests. I impose a displacement on some of my network's nodes, and I lock some others, then I run a minimization function on the system's energy in order to get the…
4
votes
1 answer

python scipy linprog simplex example v 1.5

All the scipy examples are using the older versions and I'm looking for an example on how to use the newer version. https://docs.scipy.org/doc/scipy/reference/optimize.linprog-simplex.html I created a super simple code and it prints that the problem…
Thirlan
  • 712
  • 1
  • 8
  • 26
4
votes
2 answers

python SciPy curve_fit with np.exp returns with pcov = inf

I'm trying to optimize a exponential fitting with scipy.optimize.curve_fit. But the result is no good . My code is : def func(x, a, b, c): return a * np.exp(-b * x) + c # xdata and data is obtain from another dataframe and their type is…
Wenjing Li
  • 105
  • 6
4
votes
0 answers

How to create callable jacobian function for scipy minimize routine?

I can use scipy to perform minimization without using a callable jacobian. I would like to use the callable jacobian, but cannot figure out the correct structure of the output of such a function. I have checked online for examples; the similar…
user10121139
4
votes
1 answer

Scipy optimize minimize always returns initial guess (SLSQP)

Like the title explains, my program always returns the initial guess. For context, the program is trying to find the best way to allocate some product across multiple stores. Each stores has a forecast of what they are expected to sell in the…
Marco
  • 465
  • 2
  • 7
  • 12
4
votes
1 answer

scipy.optmize.minimize: Iteration limit exceeded

I started using scipy.optimize.minimize for a work project in which I try to optimize the allocation of product across stores given historical sales data for each store. I obtain data for ~300 stores from an excel sheet and store it in a Store…
4
votes
1 answer

Scipy.optimize.minimize is not giving the minimum value even though it sees that value

I am using scipy.optimize.minimize to find optimal parameters for my objective function. My code : import numpy as np from scipy.optimize import minimize from scipy.optimize import Bounds bounds =…
chink
  • 1,505
  • 3
  • 28
  • 70
3
votes
1 answer

What function would best fit the data I have from a galaxy?

I have the following set of data: surface_brightnesses_o2 = [12076.0616666451, 11850.730704516911, 10265.598145816548, 9120.859898168235, 7070.26133100111, 5636.138833975608, 3968.1608109082404, 2923.2839406153525, 1963.9315683870766,…
3
votes
0 answers

The most effective way to find global maximum of a function with a lot of parameters? (500+)

I'm trying to find global maximum of a Python function with a lot of parameters (500+). Unfortunately I'm unable to make a derivative of this function - what the function does is basically it loops several times over np.array of shape ~ (150000,50)…
3
votes
1 answer

scipy curve_fi returns initial parameters estimates

I am triyng to use scipy curve_fit function to fit a gaussian function to my data to estimate a theoretical power spectrum density. While doing so, the curve_fit function always return the initial parameters (p0=[1,1,1]) , thus telling me that the…
Sonya N.
  • 31
  • 3
3
votes
2 answers

SciPy: Issue passing arguments to optimize.shgo function

I am trying to use the SHGO algorithm implemented in SciPy, but I have trouble when the objective function takes more than one argument. If I understand the error correctly, I am not passing the additional arguments (parameters) to the objective…
AB8
  • 51
  • 6
1
2
3
67 68