Questions tagged [scipy-optimize-minimize]
446 questions
0
votes
1 answer
How to set objective/constraint violation tolerance in Scipy SLSQP?
My understanding of SLSQP is that, when it is iterating towards a solution, it simultaneously works to reduce constraint violations and minimize the given function. Since these are two side-by-side processes, I would expect there to be someway to…

Rutvik Marathe
- 41
- 1
- 4
0
votes
1 answer
Multivariable Optimization with multiple constraints by using python
I want to find the minimum output of the function, as shown below, which contains 4 variables (bolded & emphasised), also with multiple constraints.
(width * length * t_base * rho) + (n_fin * t_fin * length * h_fin * rho)
Two constraints are…

tkfahs
- 1
- 1
0
votes
0 answers
Is there a way to change calculation of delta_gradient in scipy.optimize.minimize method of python?
By default delta_g is calculated as gk+1 - gk. But I am running new kind of BFGS algorithm where I need this instead: delta_g= gk+1 - gk + (pk/|delta_x|^2)delta_x, where pk = 2[f(xk) - f(xk+1)] + (gk+1 + gk)*delta_x

user20173216
- 1
- 1
0
votes
0 answers
Solving two non linear equations for two variables using values from previous iterations by python
enter image description hereI want to solve for s[ i ] ,L[ i ] using the two equations f1 and f2, i know the values of s, L at time t=0, and i want s,L values at different time steps. My second equation involves s, L value from current time step [i]…

ponniyin selvan
- 1
- 1
0
votes
0 answers
"warning: basinhopping: local minimization failure" when doing maximum entropy optimization
I'm minimizing a multiple-variable function using scipy.optimize.basinhopping as part of maximum entropy optimization. It works but occasionally I get local minimization failure warning messages. I'm trying to figure out whether they can be…

Neil Fazel
- 1
- 2
0
votes
1 answer
Finding the parameters of a function via curve fit
I'm trying to estimate the parameters (v, n, k) defined in fit_func. I tried the default least squares fit but I couldn't find the parameters successfully.
def fit_func(x, v, n, k):
return v * x ** n / (k ** n + x ** n)
x = [2.5, …

Natasha
- 1,111
- 5
- 28
- 66
0
votes
0 answers
How to stop the function scipy.optimize.minimize from printing "`gtol` termination condition is satisfied." and the number of iteration etc.?
I am running a code where I use the function scipy.optimize.minimize multiple times. Every time the function is called it prints something like
"gtol termination condition is satisfied.
Number of iterations: 42, function evaluations: 320, CG…

Rens Hoogendorp
- 1
- 1
0
votes
0 answers
Scipmy minimize is passing wrong args to my objective function
I am using scipy=1.2.1, python=3.6, numpy=1.16.3, I have an object function defined like so.
def func(arg0,arg1=0,arg2='default'):
print('Args for objective function:',arg0,arg1,arg2)
.
.
.
Before I call my object function I define my x0…

the.lotuseater
- 83
- 1
- 8
0
votes
0 answers
How to find global maximum of a function?
I have a Python function processing some real data and need to find global maximum of the function.
I tried to solve this by using the scipy.optimize.minimize function, but I noticed that the results I get vary a lot depending on the method used…

velkyvont
- 23
- 3
0
votes
1 answer
ValueError: The user-provided objective function must return a scalar value
I had read documentation and trying to understand how to work with scipy.optimize.minimize(), but my code just doesn't work, it keeps showing that"ValueError: The user-provided objective function must return a scalar value."
Here is my code:
PH =…

Robert_T119
- 7
- 1
0
votes
1 answer
Inconsistency while fitting data using lmfit and scipy.optimize
I am trying to fit my data to a model using lmfit library as well as scipy.optimize library. For both libraries, i am using the minimize function and using the Powell method. But, my fits for both of them are coming slightly different. Could anyone…
0
votes
1 answer
How to use scipy minimize with a dataframe
I am trying to select a subset of rows from a dataframe in order to fulfil certain constraints whilst maximising an objective. This is what I have so far:
import pandas as pd
import numpy as np
from scipy.optimize import minimize
df =…

TaxpayersMoney
- 669
- 1
- 8
- 26
0
votes
0 answers
Min Square Error Optimization not Iterating | Python Scipy
I am looking to min the square error between a target and the sum-product of my degree of freedom (Portfolio Weights) and Beta. For some reason, I can't figure out why the results are only applying my guess and no iterations are taking place within…

dabrows
- 1
- 2
0
votes
0 answers
Constrained Optimization Problem in Scipy: boolean index did not match indexed array along dimension 0
I'm having a constrained optimization problem, which i want to solve using the scipy.optimize package.
from scipy import optimize as opt
import numpy as np
def f(x):
return (x[0]-5)**2 + (x[1]-6)**2
#Bounds and Linear Constraints
bounds =…
0
votes
0 answers
UserWarning when using scipy.optimize.minimize with method 'trust-constr'
I am trying to minimize a function using scipy.optimize.minimize and I get the following errors:
Singular Jacobian matrix. Using SVD decomposition to perform the factorizations.
delta_grad == 0.0. Check if the approximated function is linear. If…

JejeBelfort
- 1,593
- 2
- 18
- 39