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
3
votes
1 answer

3D array minimization (optimization)

Suppose I have the following 5x5x5 3D array, consisting of binary values: space = [ [[0,1,0,0,1], [1,0,0,1,0], [0,1,0,1,1], [0,0,0,1,1], [0,1,1,0,1]], [[1,1,1,0,1], [0,0,0,1,0], [0,0,1,1,1], [0,0,0,1,1], [0,1,0,0,0]], [[0,1,0,1,0], [1,1,0,0,0],…
Coto TheArcher
  • 367
  • 3
  • 13
3
votes
0 answers

How do I resove the ImportError encountered while using the fssa package in python?

I am using python from a anaconda installation and using the python notebook. From the jupyer notebook (ipython) I import fssa like: import fssa I get the following error message (see below). Any help from you will be appreciated. I have tried…
3
votes
1 answer

scipy.optimize.newton - tolerance argument tol does not refer to the results of the function but to the tolerance of the input?

I wanted to solve a function being close to 0. I tried using the newton function in the Scipy package, but the tolerance seems to apply to the input and not the function of the input: from scipy.optimise import newton fn = lambda x: x*x-60 res =…
BlueTrin
  • 9,610
  • 12
  • 49
  • 78
3
votes
1 answer

Why are the errors so large?

I am trying to fit a power law of the form a*x**b+c to some data points, using curve_fit from scripy.optimize. Here's the MWE: import numpy as np from scipy.optimize import curve_fit import matplotlib.pyplot as plt def func_powerlaw(x, m, c, c0): …
George
  • 451
  • 1
  • 6
  • 17
3
votes
1 answer

Faster method to numerously solve for multiple parameters governed by multiple nonlinear equations with multiple variable arguments?

I am looking for a tweak that I could apply to the code shown later or an alternate method that would lead to faster run time. In general, I want to find the values of two parameters that are governed by a set of multiple nonlinear equations. These…
yousef
  • 33
  • 3
3
votes
1 answer

How to hide `delta_grad == 0.0` warning in scipy.optimize.minimize?

I have a loop that executes several hundred optimizations using scipy.optimize.minimize. Unfortunately, I keep getting this annoying warning: C:\Users\Leonidas\Anaconda3\lib\site-packages\scipy\optimize\_hessian_update_strategy.py:186: UserWarning:…
3
votes
1 answer

Scipy optimize unable to find the correct results

I am trying to use scipy.optimize.minimize to fit parameters for a multivariate function, however, regardless of how many noise free data points I am providing to the optimizer, the optimizer could not converge to a correct (or close) answer. I…
Susie
  • 287
  • 1
  • 13
3
votes
2 answers

How to reuse Jacobian and Inverse Hessian with SciPy minimize

I am currently using the minimize(BFGS) function from SciPy.optimize to calibrate my model. Once calibrated the parameters will be just slightly perturbed from time to time and I would like to reuse the Jacobian and IHessian from the previous…
Dave
  • 1,835
  • 4
  • 26
  • 44
3
votes
1 answer

Scipy minimize returns a higher value than minimum

As a part of multi-start optimization, I am running differential evolution (DE), the output of which I feed as initial values to scipy minimization with SLSQP (I need constraints). I am testing testing the procedure on the Ackley function. Even in…
3
votes
0 answers

How to save scipy.optimize.OptimizeResult result object to a file in a pythonic way for easy access later?

What is the best way to save the result object from scipy.optimize.OptimizeResult, so that its parameters can be easily accesses from the saved file? I am currently saving the result as a string. But this way, when I need to refer to it again, I…
Shruti
  • 159
  • 1
  • 15
3
votes
2 answers

TypeError: Improper input: N=3 must not exceed M=1, not sure what's wrong with my dimensions?

I'm trying to fit a lorentzian to one of the peaks in my dataset. We were given the fit for a gaussian, and aside from the actual fit equation, the code is very similar, so I'm not sure where I am going wrong. I don't see why there is an issue with…
newbiecode
  • 31
  • 1
  • 4
3
votes
1 answer

Differential Evolution in Scipy with Data

I have two dataframes (df_1, df_2): df_1 = pd.DataFrame({'O' : [1,2,3], 'M' : [2,8,3]}) df_2 = pd.DataFrame({'O' : [1,1,1, 2,2,2, 3,3,3], 'M' : [9,2,4, 6,7,8, 5,3,4], 'X' : [2,4,6, 4,8,7, 3,1,9], …
R. Cox
  • 819
  • 8
  • 25
3
votes
2 answers

Python scipy.minimize: overflow encountered in double_scalars and invalid value encountered in double_scalars

I built a custom EST (Exponential Smoothing) Model. First I define a function which includes the Parameter definitions which are passed to a second function doing the computation and returning the forecasting Errors. These are then squared and…
3
votes
1 answer

SciPy Optimizer gives result that do not satisfy constraints

I am using scipy.optimize.minimize to solve a problem, but the result given by the package violates the constraint. The case is mad simple where only one objective function and only one constraint are given. Here is the code: import math …
Wilson
  • 125
  • 8
3
votes
0 answers

scipy minimize not exploring all sample space during optimization

I want to optimize only two parameters alpha and beta of a function and I am using scipy.optimize.minimize function with TNC algorithm. The objective function is mean square error of observed versus predicted. Both alpha and beta can vary between…
1 2
3
67 68