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

Problem with bounds array shape in scipy.optimize constrained methods

Followup to my previous question now I have a problem with the shape of the bounds array in the constrained bfgs method. My code is the following: nr = 5 lag = 1 guess =numpy.array([[[ random.uniform(-1.0,1.0) for k in range(nr)]…
user421473
  • 27
  • 1
  • 4
0
votes
1 answer

How to organize list of list of lists to be compatible with scipy.optimize fmin init array

I am very amateur when it comes to scipy. I am trying to use scipy's fmin function on a multidimensional variable system. For the sake of simplicity I am using list of list of list's. My data is 12 dimensional, when I enter np.shape(DATA) it returns…
user421473
  • 27
  • 1
  • 4
0
votes
0 answers

Multi-variable nonlinear scipy curve_fit

I have been trying to fit my data to a custom equation.which is the following y=(a1/x)+a2*x2+b with curve fit i used curve fit with 1 independant variable it works perfectly but i cannot figure out how to use it with 2 def func (x1,x2,a1,a2,b): …
Mohamed Amine
  • 340
  • 1
  • 4
  • 16
0
votes
1 answer

How to pass multiple constants and variables to Scipy Optimize?

I am trying to fit model data (calculated from eR) to my experimental data e_exp. I am not quite sure how to pass constants and variables to func. import numpy as np import math from scipy.optimize import curve_fit, least_squares, minimize f_exp …
naughty_waves
  • 265
  • 1
  • 13
0
votes
0 answers

Is there someway to prevent an solution to broke using fsolve in python?

I am having some trouble trying to solve a nonlinear system of equations numerically using fsolve from scipy.optimize. I solve this system for a lot of multiples and sub-multiples of one parameter (nuc_den), the solution is good for one third of…
0
votes
0 answers

python optimize minimize dimension error between arguments x0, parameter boundaries, cost function and Jacobian

I would like to try different strategies to fit my data to a given model, with boundaries and providing the analytical Jacobian to improve the results. I can run the optimize.least_squares, e.g.: sol = optimize.least_squares(cost_function, x0=x0,…
0
votes
0 answers

fsolve gives TypeError: fsolve() missing 1 required positional argument: 'x0'

I'm trying to numerically solve an equation that cannot be solved analiticaly (solution must depend on k). But using fsolve gives me TypeError from scipy import * from scipy.optimize import fsolve import numpy as np import matplotlib.pyplot as…
Quasar
  • 63
  • 5
0
votes
1 answer

how can define bounds for " optimize.minimize" in python?

I have function with some variable : def objective(x): #= params x00 = x[0] y00 = x[1] u_m = x[2] a = x[3] b = x[4] u_mean_real = x[5] A = x[6] B = x[7] H = x[8] alpha = x[9] . . . . …
0
votes
1 answer

optimization a linear objective function with linear constraints and binary variables in python

I am new to optimizations and trying to solve a problem, which I feel falls in the umbrella of optimization. I have an ojective function that needs to be maximized def…
chink
  • 1,505
  • 3
  • 28
  • 70
0
votes
1 answer

determining whether two convex hulls overlap

I'm trying to find an efficient algorithm for determining whether two convex hulls intersect or not. The hulls consist of data points in N-dimensional space, where N is 3 up to 10 or so. One elegant algorithm was suggested here using linprog from…
0
votes
2 answers

Question on Scipy - Minimize. Adding additional constraints

I am trying to using scipy minimize function for the following optimization: V = np.matrix(pd.read_csv('V.csv'))` R = np.matrix(pd.read_csv('R.csv', index_col = 'Ticker'))` w0= list() for i in range(0, 84): w0.append(1/84) def…
JungleDiff
  • 3,221
  • 10
  • 33
  • 57
0
votes
1 answer

Find zeroes of function with simpy.optimize.bisect, with a complex function

I'm a student of mechanical engineering, and this is the first year I've met with the Python environment, or the distribution of it Anaconda. I was given a task to find the zeroes of this function: ⋅sin()cos()+⋅cos()sin()2−⋅cos()−ℎ⋅sin()=0 With…
Wyvern
  • 11
  • 2
0
votes
1 answer

Python big optimization problem with daily max

Ok so I have the following optimization problem: I need to figure out for every hour of the year if a generation plant should produce or not depending on the cost of producing and the income it receives to produce. So for every hour of the year I…
David
  • 129
  • 1
  • 11
0
votes
1 answer

Optimization of predictions from sklearn model (e.g. RandomForestRegressor)

Does anyone used any optimization models on fitted sklearn models? What I'd like to do is fit model based on train data and using this model try to find the best combination of parameters for which model would predict the biggest value. Some…
0
votes
1 answer

missing 2 required positional arguments in optimization problem in python

I'm trying to solve an optimization problem using scipy. There's a huge database that I re-arranged in order to use some of the rows as parameters in the optimization problem. Then I take the sum of each entry and multiply by x variables in order to…
ldjr28
  • 1
  • 1