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.

594 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':…
6
votes
0 answers

How to fix "failed to initialize intent(inout|inplace|cache) array, input not an array" who appears after using fmin_l_bfgs_b?

I'm trying to use scipy.optimize.fmin_l_bfgs_b function in order to minimize my function evaluateFunc(params) which returns an error and the related error gradient. However, when I call the function fmin_l_bfgs_b with this function, it send me this…
5
votes
2 answers

Is there any quadratic programming function that can have both lower and upper bounds - Python

Normally I have been using GNU Octave to solve quadratic programming problems. I solve problems like x = 1/2x'Qx + c'x With subject to A*x <= b lb <= x <= ub Where lb and ub are lower bounds and upper bounds, e.g limits for x My Octave code looks…
4
votes
4 answers

No module named 'scipy.spatial.transform._rotation_groups after compile python script with pyinstaller

After days of looking for an answer on internet and, of course, in overflow I make this post. I hope someone could help me. I made a little program that fits some data that I got from chemistry experimentation with a math model using scipy.optimize.…
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,407
  • 2
  • 29
  • 52
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
  • 25
4
votes
1 answer

Nonlinear constrained optimization package for Python with direct support of matrix variables

I've been looking around for a nonlinear constrained optimization package for Python (to deal with problems that are NOT necessarily convex) that can directly handle matrix variables. More specifically, I'm dealing with optimization problems where…
4
votes
1 answer

scipy differential evolution setup issue

Below is a very stupid example which is basically a dumbing-down of my real world use case import pandas as pd from scipy.optimize import differential_evolution import time def optimizer_function(x, cost_name): print(cost_name) a =…
Chapo
  • 2,196
  • 2
  • 21
  • 46
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 =…
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): …
dimitris_ps
  • 5,391
  • 1
  • 21
  • 46
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
  • 633
  • 5
  • 19
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…
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…
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…
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
39 40