Questions tagged [scipy-optimize-minimize]
255 questions
14
votes
2 answers
scipy.optimize.minimize(method=’trust-constr’) doesn't terminate on xtol condition
I have set up an optimization problem with linear equality constraints as follows
sol0 = minimize(objective, x0, args=mock_df, method='trust-constr',
bounds=bnds, constraints=cons,
options={'maxiter': 250, 'verbose':…
![](../../users/profiles/10309342.webp)
gehbiszumeis
- 2,788
- 4
- 19
- 33
5
votes
1 answer
Difference between scipy.optimize.fmin and scipy.optimize.minimize
I'm learning python to make models these days. I read the documentation of scipy.optimize.fmin. It also recommends scipy.optimize.minimize. It seems that scipy.optimize.minimize is a more advanced method. Real wonder what's the difference between…
![](../../users/profiles/9441299.webp)
Xiaodong
- 51
- 2
4
votes
1 answer
scipy.optimize.minimize with BFGS: Objective called twice with same parameter vector
I'm using scipy.optimize.minimize with method='bfgs' to train a convex objective.
Every time I run a minimization, the first two calls the BFGS optimizer makes to my objective function always have the same parameter vector. This seems unnecessary as…
![](../../users/profiles/885287.webp)
aaronsnoswell
- 5,652
- 5
- 41
- 65
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 =…
![](../../users/profiles/8957025.webp)
cvg
- 1,101
- 1
- 12
- 37
4
votes
0 answers
scipy.optimize minimize inconsistent results
I am getting some very weird results when running the minimize function from scipy optimize.
Here is the code
from scipy.optimize import minimize
def objective(x):
return - (0.05 * x[0] ** 0.64 + 0.4 * x[1] ** 0.36)
def constraint(x):
…
![](../../users/profiles/1930543.webp)
dimitris_ps
- 5,391
- 1
- 21
- 46
3
votes
0 answers
How to find optimum of a function with restriction to the sum of the input values in scipy?
I have a linear function for two input value according the following (params has been computed already):
def objective(x):
return x[0] * params[0] + x[1] * params[1] + params[2]
Now I want to calculate the optimum (minimum) of the function with…
![](../../users/profiles/4495790.webp)
Fredrik
- 241
- 2
- 9
3
votes
2 answers
How to use scipy's minimize within a class?
I'm new to python so this might be a stupid question, however I couldn't find an answer to this anywhere.
I'm trying to find the optimal reaction for a player given the action of another player. The situation is your typical Bertrand price…
![](../../users/profiles/14184284.webp)
merimursu
- 33
- 4
3
votes
1 answer
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…
![](../../users/profiles/14087348.webp)
MatthiasHerp
- 71
- 6
3
votes
0 answers
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…
![](../../users/profiles/13851431.webp)
Lena_Cste
- 31
- 2
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…
![](../../users/profiles/5982232.webp)
Ather Cheema
- 367
- 1
- 12
3
votes
0 answers
Tolerance for termination is ignored in scipy optimize minimize
I have a simple optimization problem that, with some specific data, makes scipy.optimize.minimize ignore the tol argument. From the documentation, tol determines the "tolerance for termination", that is, the maximum error accepted for the objective…
![](../../users/profiles/8083048.webp)
ouranos
- 271
- 2
- 11
3
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
3
votes
0 answers
How to speed-up basinhopping global optimization
I'm working on a program that should perform an optimization roughly 6750 times. Now, the problem is that one optimization has a duration of about 3 minutes. This doesn't seem much at first sight, but if I have to perform it 6750 times, I would be…
![](../../users/profiles/10797415.webp)
Frederik Vanclooster
- 273
- 4
- 16
3
votes
1 answer
ValueError: tnc: invalid gradient vector from minimized function
I'm learning ML by myself, and I have an error when I try to code Logistic Regression in python.This is from Standford online course. I've tried many times, including change grad to grad.ravel()/grad.fatten(), but none of them worked.
Input:
import…
![](../../users/profiles/11915721.webp)
Scarlett
- 41
- 3
2
votes
0 answers
Minimizing Least Squares Subject To Constraint
I am trying to rate NFL teams by minimizing the sum of squared errors subject to a constraint. My data looks like:
dat = {"Home_Team": ["KC Chiefs", "LA Chargers", "Baltimore Ravens"],
"Away_Team": ["Houston Texans", "Miami Dolphins", "KC…
![](../../users/profiles/6458110.webp)
Jake
- 257
- 2
- 9