Questions tagged [scipy-optimize-minimize]
446 questions
22
votes
1 answer
Scipy.optimize Inequality Constraint - Which side of the inequality is considered?
I am using the scipy.optimize module to find optimal input weights that would minimize my output. From the examples I've seen, we define the constraint with a one-sided equation; then we create a variable that's of the type 'inequality'. My question…

trystuff
- 686
- 1
- 8
- 18
15
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':…

gehbiszumeis
- 3,525
- 4
- 24
- 41
14
votes
2 answers
Scipy.optimize minimize is taking too long
I am running a constrained optimization problem with about 1500 variables and it is taking over 30 minutes to run....
If I reduce the tolerance to 1 the minimization will complete in about five minutes, but that doesn't seem like a good way to speed…

RussellB.
- 346
- 1
- 3
- 9
12
votes
2 answers
How to choose proper method for scipy.optimize.minimize?
I was wondering how I can choose the best minimization method for scipy.optimize.minimize and how different the results may be?
I am trying to minimize the following expression (solve for g):
|a1.g.x + a2.g.x^3 - K|

Shannon
- 985
- 3
- 11
- 25
7
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…

Xiaodong
- 71
- 1
- 2
7
votes
1 answer
Want to do multi-variation minimize with sympy
I want to use minimization with scipy.optimize using Symbolized charactors
from scipy.optimize import minimize
from sympy.utilities.lambdify import lambdify
import sympy as sp
x1, x2, x3, x4 = sp.symbols('x1 x2 x3 x4')
FormulaMain =…

AmberK
- 73
- 1
- 4
6
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…

ouranos
- 301
- 4
- 17
6
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):
…

dimitris_ps
- 5,849
- 3
- 29
- 55
5
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…

merimursu
- 53
- 5
5
votes
0 answers
scipy.optimize minimize: Two output variables in objective function?
I am using the scipy minimize function to find the optimal value of some parameters, H and Q. My objective function, kalman, is evaluated on the variable log_likelihood. In a nutshell, I am trying to find the optimal values of H and Q that maximize…

natsuki_2002
- 24,239
- 21
- 46
- 50
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…

Lena_Cste
- 41
- 3
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…

Marco
- 465
- 2
- 7
- 12
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…

aaronsnoswell
- 6,051
- 5
- 47
- 69