Questions tagged [scipy-optimize-minimize]

446 questions
3
votes
1 answer

Nelder-Mead optimization in python with constraints

Currently, I am looking for a Nelder-Mead optimizer in python that also accepts bounds and constraints for the variables. Scipy has a Nelder-Mead optimizer, but it does not allow any constraints. During my search I came across the package…
Emma
  • 439
  • 5
  • 17
3
votes
2 answers

How to solve nonlinear programming problem in Python

I want to solve a nonlinear programming problem. The objective function is nonlinear and the constraints are linear. Given a vector α(dim is n*1), I want to find another vector θ( dim also is n*1) make cos(α, θ) minimize. Meanwhile the θ has some…
3
votes
1 answer

Is it possible to pass a scalar value to a Pandas UDF Function along with Pandas Series

I'm trying to use scipy.optimize.minimize function on two columns of pyspark dataframe. while passing x0 parameter as array to the Pandas UDF function, i am getting following error: TypeError: Invalid argument, not a string or column: [0.9 0.5 2.5…
Vaibhav Rathi
  • 340
  • 1
  • 4
  • 16
3
votes
1 answer

How to scipy-optimize with a categorical variable

Consider the following problem: import numpy import scipy.optimize def f(x): return (x[0] == 1)*(x[1] + 2)**2 - (x[0] == 0)*(x[1] + 1)**2 kwargs = { 'method': 'trust-constr', 'jac': False, 'bounds': [(0, 1), (0, 1)], …
Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121
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…
3
votes
1 answer

print chosen method of scipy.optimize.minimize

This is a short question, but google points me every time to the documentation where I can't find the answer. I am using scipy.optimize.minimize. It works pretty good, all things are fine. I can define a method to use, but it works even if I don't…
theother
  • 307
  • 2
  • 16
2
votes
2 answers

How to do the optimization for a mean squares error in a Python code faster

(I'm new to stack overflow, but I will try to write my problem the best way I can) For my thesis, I need to do the optimization for a mean squares error problem as fast as possible. For this problem, I used to use the scipy.optimize.minimize method…
2
votes
2 answers

Curve fitting: How to optimize x_value model for curve fitting in python

I am trying to fit an exponential curve into my data. However, I am having some trouble defining the x_value model properly in order to have a representative curve-fit to the data. I would think that the approach I used in preparing the DataFrame…
2
votes
0 answers

Fit line segments to shape

Suppose I have a binary image as shown below. The white colour indicates the shape of interest. Task: I want to fit two connected line segment that best describes the shape. Example output is shown below. Constraints: We can assume that the start,…
DalekSupreme
  • 1,493
  • 3
  • 19
  • 32
2
votes
1 answer

scipy.optimize.minimize_scalar() adding constraint to helper function result inside objective function?

I have a function func_x() that I am trying to minimize using scipy.optimize.minimize_scalar(). func_x() also calls another function func_y() whose result func_x() uses in part to calculate the final scalar value. I want the optimization to also…
2
votes
1 answer

Minimizing a simple Linear Combination

I know this is this is not a practical thing to do (this question I just so I can understand what is going on), but I am wondering why SciPy can’t minimize the following linear combination (it returns the initial weights and only does 1…
2
votes
1 answer

How to use scipy.optimize.minimize for function with 3 variables?

I'm trying to optimise this function: def voce(strain, sigma_s, sigma_y, epsilon_0): stress = sigma_s - (sigma_s - sigma_y)*np.exp(-strain/epsilon_0) return stress by finding the best values for sigma_s, sigma_y and epsilon_0. Strain and…
2
votes
0 answers

How to log step sizes when using scipy.optimize.minimize (L-BFGS-B)?

I am working with the L-BFGS-B implementation of the scipy.optimize.minimize package. I know that when using a gradient (i.e. using the argument jac=...), the algorithm computes the corresponding step size by line search (Wolfe-condition). Does…
lhell
  • 21
  • 3
2
votes
1 answer

In python, how to discretize continuous variable using accuracy as a criterion taking class into consideration

For a set of subjects I have a continuous variable with range 0-100 representing a quantification of a subject's state cont_attribute. For each subject I also have an ordinal variable representing reader annotation of subject's state as one of four…
2
votes
1 answer

Use GEKKO solver in scipy.optimize

I try to use the scipy.optimze.minimize solver (Nelder-Mead) to optimize my parameters of a GEKKO simulation. Is this possible at all? My idea was to hand over the GEKKO object to the solver, but this leads to a error: TypeError: float() argument…
H Bode
  • 165
  • 7
1 2
3
29 30