Questions tagged [scipy-optimize-minimize]
446 questions
0
votes
1 answer
Fitting parameters of a data set from a model
I am trying to fit the parameters of a transit light curve.
I have observed transit light curve data and I am using a .py in python that through 4 parameters (period, a(semi-major axis), inclination, planet radius) returns a model transit light…

DIRCEU YURI SIMPLICIO NETTO
- 31
- 1
- 3
0
votes
0 answers
single scalar scipy optimize minimize
I'm having an issue using scipy's minimize() function, and I don't really understand enough about optimization to grasp what is wrong here..
I have a function that calls scipy.optimize.minimize(). It works fine and provides me with exactly the…

fffrost
- 1,659
- 1
- 21
- 36
0
votes
1 answer
Why scipy.optimize.minimize does not work with a constraint and initial value 0
I am trying to optimize a function of two variables. I want one variable to be fixed at 50 and another be between -5 and 5. I wrote the following code:
x0 = np.array([50, 0.0])
res = minimize(error, x0, constraints=[
{'type': "eq", "fun": lambda…

Bakhanov A.
- 146
- 1
- 7
0
votes
1 answer
Numpy: Find the value needed in one equation which minimizes the error
the title is not clear, i hope to explain better here:
i have the two following arrays, ep and sp with the same dimension:
ep = [0.00000000e+00, 4.29973987e-05, 1.77977219e-04, 3.08940223e-04, 4.44883670e-04, 5.84806153e-04, 7.28705999e-04,…

MatFer
- 3
- 4
0
votes
1 answer
How to specify the parameter an objective function is minimized with respect to, using scipy.optimize.minimize()?
Suppose I have an objective function f(a,b,c). I want to find the value of b that minimizes it, holding a and c constant, and to experiment with different combinations of a and c, I prefer not to write f(a,b,c) as g(b).
from scipy.optimize import…

Paw in Data
- 1,262
- 2
- 14
- 32
0
votes
1 answer
Why is a matrix argument of my objective function changed when I minimize it with scipy.optimize.minimize()?
I'm trying to do the Space-Time Auto-Regression (STAR). The code below basically defines the objective function above that I need to minimize, where Y is an N-by-K matrix and D an N-by-N matrix.
import numpy as np
from sys import exit
def…

Paw in Data
- 1,262
- 2
- 14
- 32
0
votes
1 answer
SciPy "Successfully" finding incorrect optimal solution and "Unsuccessfully" finding optimal solution (Portfolio Construction)
I'm building a trading bot and I'm trying to implement an optimiser to maximise alpha while adhering to certain constraints.
My variable is a vector containing the weights of the securities in the portfolio.
I also have a vector that contains the…

OllieHooper
- 405
- 3
- 9
0
votes
1 answer
When I am doing scipy.optimize.minimize, I got Index Error
I am planning to calculate the maximum of objective function.
My coding is as follows.
import numpy as np
from scipy.optimize import minimize
# this is my objective function
def objective(x,sign=-1.0):
x1=x[0]
x2=x[1]
x3=x[2]
…

Hope
- 1
0
votes
1 answer
minimization problem TypeError: 'numpy.float64' object is not callable
so I am trying to minimize a function of array for a given parameter using minimize of optimize and it gives me this error:
Traceback (most recent call last):
File "plot2.py", line 72, in
res = minimize(rosen(al,c), c, args=(al))
File…

alberto orell
- 1
- 1
0
votes
1 answer
Scipy fits very weirdly and creates multiple fitted curves which shouldn't be the case and I know curve fitting doesn't return multiple curves
Here is my code
yp = df.final_sulfur/df.start_sulfur
xp = df.mag/df.hm_weight
sns.set(font_scale=1.5, font='DejaVu Sans')
fig, ax = plt.subplots(1,1, figsize=(9, 9))
yp = df.final_sulfur/df.start_sulfur
xp = df.mag/df.hm_weight
p = ax.plot(xp, yp,…

nithin
- 753
- 3
- 7
- 21
0
votes
1 answer
Scipy minimize constraint: One of two values needs to be zero
I want to minimize the following function :
def objective(B, P, O):
return - (sum([(p * o - 1) * b for p, o, b in zip(P, O, B)]) /\
math.sqrt(sum([(1-p) * p * b**2 * o**2 for p, o, b in zip(P, O, B)])))
sol = minimize(objective, x0=bets,…

flo
- 378
- 2
- 9
0
votes
0 answers
Python multiprocessing within a callable function in scipy.optimize
I am trying to use multiprocessing inside a cost function called by scipy.optimize's minimize function. Inside the cost function I have a loop I want to compute in parallel.
A simplified version of the code is as follows:
import numpy as np
from…

Guest_audio
- 1
- 2
0
votes
1 answer
Why does scipy.optimize.mminimize not use the provided initial guesses
I have a application written in python for calculating minimal return value from a function. Am using scipy.optimize.mminimize with SLSQP as the optimization method.
It runs in a loop and for saving time and kip it from just finding local minima I…

user2929502
- 5
- 3
0
votes
0 answers
Scipy code to solve optimization problem ( gurobi code is written!)
I wrote a Gorubi optimization code, but because of some issues, I need to convert to Scipy code. Still have difficulties to convert it. Here is a part of code related to Gorubi:
m = Model()
#x is charging, discharging variable
x =…

saeed
- 25
- 8
0
votes
1 answer
Scipy optimize: error trying to put function to minimize
I want to find minimal function value with scipy.optimize.minimize_scalar
Function:
def error(w0, w1):
dataset = data
total_error = 0
for i in range(1, 25000):
meta = dataset['Height'][i] - ((w0 + w1 * dataset['Weight'][i]))**2
…

a_chiren
- 15
- 2