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

Bucket Constraint Optimization

I'm trying to design a constraint that is based on optimizing groups/buckets of elements rather than just individual elements. Here is a list of all the constraints I have: Total sum of all the elements must equal a certain value Total sum of each…
2
votes
1 answer

Python non linear programming model for stock-out based substitution returns 'function' object not iterab

My goal is to calculate the value of both a matrix (df_a) and a list (l), with the main idea being to calculate, for each position i, the value of the following: - and aiming to minimize the error, i.e., S - RHS of the equation shown However, I…
2
votes
1 answer

Curve.fit optimization error: 'Covariance of the parameters could not be estimated

I'm trying to fit some data into a function, but scipy curve_fit gives me the following message: "OptimizeWarning: Covariance of the parameters could not be estimated" and won't plot or print the parameters of the fit. I believe the power inside the…
2
votes
1 answer

Is it possible to use Python Mixed Integer Linear programming to get all solutions in an interval?

I have a linear problem to solve looking for integer numbers. I found a way to solve it using the new milp implementation in spicy. Hereafter is a demonstration code. The problem is the following. From a vector of weights w I am looking for the…
Ger
  • 9,076
  • 10
  • 37
  • 48
2
votes
1 answer

Fastest possible optimisation of an area difference with a constrained sum

I have four arrays, a1,a2,a3,a4, each of length 500. I have a target array at, also of length 500. These arrays each represent the y coordinates of unevenly spaced points on a graph. I have the x coordinates in a separate array. I want to optimise…
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
2 answers

scipy curve_fit incorrect for large X values

To determine trends over time, I use scipy curve_fit with X values from time.time(), for example 1663847528.7147126 (1.6 billion). Doing a linear interpolation sometimes creates erroneous results, and providing approximate initial p0 values doesn't…
Anders Petersson
  • 391
  • 1
  • 12
2
votes
0 answers

Scipy linear-constrained optimisation out of bounds

I am trying to maximize certain logLikelihood function, given trajectory T and parameter tMax, with respect to set o 2d + 2d^2 parameters X, where d is fixed integer. Each parameter valid range is (0, 10), with exception to parameters with indexes…
2
votes
1 answer

Can I use PyOpenCL in integration with Scipy to perform Differential Evolution in parallel with GPU?

I got my code for simulating a multivariate regression model to work using the Differential Evolution, and even got the multiprocessing option to help out in reducing runtime. However, with 7 independent variables with 10 values each and matrix…
2
votes
1 answer

Instability in fitting data using Scipy Optimize library

I am attempting to fit a function to a set of data I have. The function in question is: x(t) = - B + sqrt(AB(t-t0) + (x0 + B)^2) I have tried to fit my data (included at the bottom) to this using two different methods but have found that whatever I…
JamesVR
  • 51
  • 4
2
votes
0 answers

Scipy Optimize (L-BFGS-B) Output : What does variable M represent?

RUNNING THE L-BFGS-B CODE Machine precision = 2.220D-16 N = 425 M = 10 At X0 0 variables are exactly at the bounds What is the meaning of variable M? I know N stands for the number of trainable parameters.
tonygrey
  • 71
  • 5
2
votes
1 answer

How to use scipy curve_fit to solve equation with some parameters values known

I try to use scipy curve_fit to solve an equation in order to get the estimated value for some unknown parameters. I have the independent variable (x) and dependent variable(y) and one parameter (e) known, now I need to find the estimated value for…
user032020
  • 406
  • 2
  • 13
2
votes
1 answer

How do I deal with domain error for inverse cosine on fsolve?

I have a function defined f(x) = acos(x) in python, and want to solve for its zeroes given an initial value. However, fsolve seems to return a math domain error even when my initial guess is well within the domain of the cosine inverse function, or…
DentPanic42
  • 121
  • 4
2
votes
1 answer

Problem minimizing a constrained function in Python with scipy.optimize.minimize

I'm trying to minimize a constrained function of several variables adopting the algorithm scipy.optimize.minimize. The function concerns the minimization of 3*N parameters, where Nis an input. More specifically, my minimization parameters are given…
2
votes
1 answer

Minimization of a function with constraints in Python

I'm trying to minimize a function of three N-sized arrays that contain the minimization parameters that I want to find. For example, suppose the parameters I want to find in order to minimize the function are given by the arrays x =…