Questions tagged [scipy-optimize-minimize]
446 questions
0
votes
1 answer
Scipy.optimize - minimize not respecting constraints
Using the code below to to understand how Scipy optmization/minimization works. The results are not matching what I am expecting.
"""
Minimize: f = 2*x[0]*x[1] + 2*x[0] - x[0]**2 - 2*x[1]**2
Subject to: -2*x[0] + 2*x[1] <= -2
2*x[0] -…

Marcelo
- 65
- 2
- 10
0
votes
1 answer
In scipy.optimize.minimize, how can I feed optional arguments into the args=() tuple?
So I have some funciton
def fun(x,y=None):
# Do some stuff
and I want to minimize this function over x, but sometimes I will want to have an additional argument y. (Essentially, I want y to always take its default value, except when I'm…

Sam Wilkinson
- 41
- 5
0
votes
1 answer
Is ftol and gtol needed in scipy.optimize.minimize is it proper to give it a very low value?
I am using the bounded limited memory BFGS optimizer to minimize the value of a black box function. I have simulated randomly many input parameter combinations and realized that the ftol and gtol parameter is only in the way, and it doesn't…

user421473
- 27
- 1
- 4
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,…

JP Manzano
- 11
- 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]
.
.
.
. …

nilou.mhy
- 23
- 3
0
votes
1 answer
Deductible modeling -- Difficulty achieving convergence with scipy.optimize.minimize
I am new to Python. I apologize in advance if my code feels cringy. For the past few weeks I have been working on a difficult statistical challenge called deductible modeling. I will try avoiding unnecessary statistical jargon and keeping the…

RSMax
- 25
- 1
- 5
0
votes
1 answer
Singular matrix C in LSQ subproblem error - Multiple recipes
I'm trying a simple optimization concerning cooking recipes.
The peculiarity is that the system will have to optimize several recipes at the same time due to constraints that will be created in common not yet implemented (e.g .: a core common to all…

AnLa
- 29
- 3
0
votes
1 answer
scipy.optimize.minimize - slsqp - hessian matrix
I use the package scipy.optimize.minimize in Python and especially with SLSQP because this algorithm is better suited to my problem. The problem is that SLSQP makes an approximation to calculate the hessian of the objective function while I know it…

Alexis
- 21
- 3
0
votes
0 answers
Broadcasting in scipy.optimize.minimize
I've defined a function that references an array and broadcasts variables across that array. When the function is run, it works fine. However, when I attempt to use scipy.minimize to minimize the function I get the following error:
operands could…

Andy Robinson
- 11
- 1
0
votes
1 answer
Maximise function using scipy minimize
I want to optimize my function Strategy2(alpha, beta), which performs a betting strategy on some data, starting with a wallet value of 20,000, and returns a new wallet value.
So I need to find the optimum alpha & beta values that maximize the…

gr12345
- 23
- 6
0
votes
1 answer
how to extract two outputs from scipy minimize
I want to have a function that based on length, width, and height (within a certain bound) minimizes the volume. But in addition to volume, I also want to calculate half_volume = volume /2.
My minimization algorithm successfully determines the…

Changoleon
- 31
- 4
0
votes
1 answer
How to evaluate execution time when using scipy.optimize?
I am working on a python script that utilizes the minimize() function from scipy.optimize. The script works fine, but it is relatively slow, and I am trying to figure out how to (a) figure out where the time is being spent) so I can (b) speed it…

user1563247
- 516
- 1
- 7
- 20
0
votes
0 answers
Scipy minimize like Excel Solver
I have big table of data that I read from excel in Python where I perform some calculation my dataframe looks like this but my true table is bigger and more complex but the logic stays the same:
with : My_cal_spread=set1+set2 and Errors = abs(…

Gogo78
- 267
- 2
- 10
0
votes
1 answer
Scipy.Optimize.Minimize inefficient? Double calls to cost/gradient function
I'm relatively new to using SciPy; I'm currently using it to minimize a cost function for a multi-layer-perceptron model. I can't use scikit-learn because I need to have the ability to set the coefficients (they are read-only in the MLPClassifer)…

ddjanke
- 121
- 4
0
votes
1 answer
scipy.optimize.minimize returning [inf]
I am trying to call scipy.optimize.minimize to minimize a function poissonNegLogLikelihood, which is defined as follows:
def poissonNegLogLikelihood(lam, y):
Computes the negative log-likelihood for a Poisson random variable.
Inputs:
lam -…

gkeenley
- 6,088
- 8
- 54
- 129