Questions tagged [scipy-optimize-minimize]
446 questions
0
votes
1 answer
scipy.optimise TypeError - takes 1 positional argument but 2 were given with external functions
I am trying to speed up my functions called by scipy minimize. They were originally all lambda's so I thought I'd replace these with numba @njit functions.
But I get this exception:
File "/blah/opt.py", line 142, in normalise
result =…

Olddave
- 397
- 1
- 2
- 12
0
votes
1 answer
scipy.minimize How can i sum multiple targetfunctions to one targetfunction?
For an exercise i need to solve multiple mixture problems out of different substrats for 4 different products. My problem is that i have a target function to optimize for every sort separately. My goal is to add those 4 targetfunctions to one…

mrgreen
- 7
- 3
0
votes
0 answers
scipy's minimization only change one parameter
I have a problem with minimizing a likelihood function(LLF). I wrote everything and my code works without any error. but my problem is the scipy. minimize only change 1 parameter and the other ones remain the same as the initial inputs. (i changed…

NimDang
- 11
- 4
0
votes
1 answer
Scipy.minimize - How to minimize two functions at the same time
I need to optimize the mixture of different substrats to different products. The amount of each substrat should add together to the best proportion for the components C,P,N,Si for the product.
From the 4 substrats i need to find the perfect…

mrgreen
- 7
- 3
0
votes
1 answer
Setting bounds of a specific array subset of x0 scipy python
I need to set different bounds for each subset of the x0 array in scipy.optimize.minimize() function.
This is what I tried so far:
x0 = np.zeros(20)
# disp = x0[0:5]
# w = x0[5:10]
# qi = x0[10:15]
# qai = x0[15:20]
…

Davide Tamagnini
- 15
- 3
0
votes
1 answer
How to generate constraints dynamically in scipy.optimize?
Well what I was trying to do was to model the following using scipy.optimize.minimize.
What I'm trying to optimize is this function with its constraints:
Here variable V is a list of variables, list's length is equal to the size of Omega.
What…

LoveCode
- 13
- 3
0
votes
1 answer
PuLP - Why cant you use a generator/list expression for UpBounds? "TypeError: must be real number, not list"
I am trying to code the upper bounds of a set of variables (x1, x2...xn) for my problem in Pulp. I already have a list of the upper bounds that i want to use. the problem is that a generator or list expression yields an error.
UpBounds=[370.94,…

beginner_python
- 37
- 4
0
votes
1 answer
Minimizing Two Functions Simultaneously
I'm trying to optimize a model that involves two functions to be fitted to data simultaneously whilst sharing variables. I am currently having problems minimizing this model due to scipy.optimize requiring a function to be passed through but I need…

Ryan
- 1
- 1
0
votes
0 answers
Minimise a function in Python
Could you help on how to minimize a function in Python? Particularly, it's the logistic function. Below is my cost function, I got it correctly because I checked the answer.
def g(z):
h = 1 / (1 + numpy.exp(-z))
return h
theta1_ravel =…

user15515518
- 91
- 6
0
votes
0 answers
How to scipy optimize minimize with trust-ncg
I have as an assignment to use the 'trust-ncg' method of scipy.opt.minimize.
I have given the outputs of my function f(x,y). I manually find the Jacobian in a function. So, also the Hessian. Simplified, it is:
def foo(params):
x,y = params
…

NiRvanA
- 105
- 1
- 1
- 8
0
votes
1 answer
Scipy minimize error: "invalid index to scalar variable"
I'm trying to minimize a function w.r.t. a list x0 of shape (30), but I got the error:
"invalid index to scalar variable"
In particular my code is like this:
def func(data, x0):
s_i=np.zeros(data.shape[0])
for i in range(data.shape[0]):
…

emm gi
- 45
- 6
0
votes
1 answer
scipy: How to minimize the minimum residual sum of squares with constraint?
When using Ordinary Least Squares linear regression method to fit x and y, it will get a function y = a*x + b, but in my case I need to make b <= 0.
x = [139, 162, 147, 110, 145, 144, 131, 132, 135, 85, 77, 90, 103, 163, 102, 31, 71, 95, 143, 94,…

luneice
- 157
- 1
- 10
0
votes
1 answer
Get all feasible solutions with SCIP
How do I get all feasible solutions with scip? I already know something through the web "https://www.scipopt.org/doc/html/COUNTER.php". But I've learned that I only get the solutions by detected. I can't get all solutions if the feasible solutions…
0
votes
0 answers
Input an array of data for Scipy.optimize.minimize
import scipy.optimize as opt
def fun1(u,es):
theta = u[0]
ret = (np.fft.fft(es_storex.flatten()+1j*es_storey.flatten()))*np.exp(1j*theta)
return (ret)
x = np.array([3.])
results = opt.minimize(fun1, x)
I'm trying to do a phase…

Dimuthu Kodituwakku
- 11
- 1
- 4
0
votes
0 answers
non-linear programming problem using python
I have this (non?) linear programming problem which am not sure on how to go about solving it. So i have the following variables x,y and their bounds:
x_lower=[0,0,0,0,0,0]
x_upper=[100,20,50,200,10,50]
list_y=[1.41,1.42,5.60,5.70,8.60,8.80]
I want…

beginner_python
- 37
- 4