Questions tagged [scipy-optimize-minimize]

446 questions
0
votes
1 answer

ValueError: `f0` passed has more than 1 dimension

Dimension error appears when trying to call minimize function import numpy as np import math import scipy from scipy import optimize from scipy.optimize import minimize, line_search x1=[1,2,1] ; y1=0 x2=[1,1,2] ; y2=0 x3=[2,3,3] ; y3=1 x4=[2,2,1] ;…
0
votes
0 answers

Determining Best Fit Center of Scattered 3D Points

I am attempting to find the center of several sets of 3D points on a sphere. Each set is comprised of three or more points that fall on the arc of a circle, but not perfectly as they have been supplied by an object detection algorithm, so there is…
Bvdb89
  • 11
  • 3
0
votes
0 answers

How to set the bounds of scipy.optimize.minimize()?

Im trying to minimize function(T) by scipy.optimize.minimize(). With 0 < T < 1. My code is the following: import scipy import math def function(T): ''' U = (1- sqrt(T)^(-2) 1 - T^3 * (1 - T - U) ^ 5 * U ^ 10 ''' return 1 -…
bibols
  • 1
  • 2
0
votes
0 answers

Dictionary of Constraints Python SciPy.Optimize

I'm working on creating a dictionary of constraints for a large SCED power problem for minimization. However, I'm being given a ValueError saying an unknown type is passed despite only using Optimize.LinearConstraints at present. When I change to…
0
votes
2 answers

Imposing monotonicity with scipy.optimize.minimize

I am trying to minimize a function of a vector of length 20, but I want to constrain the solution to be monotonic, i.e. x[1] <= x[2]... <= x[20] I have tried to implement this in the following way using "constraints" for this routine: cons =…
0
votes
2 answers

How to use scipy `minimize` on a difference between two vectors?

I have two vectors w1 and w2 (each of length 100), and I want to minimize the sum of their absolute difference i.e. import numpy as np def diff(w: np.ndarray) -> float: """Get the sum of absolute differences in the vector w. Args: …
PyRsquared
  • 6,970
  • 11
  • 50
  • 86
0
votes
1 answer

Scipy Optimize Minimize: Optimization terminated successfully but not iterating at all

I am trying to code an optimizer finding the optimal constant parameters so as to minimize the MSE between an array y and a generic function over X. The generic function is given in pre-order, so for example if the function over X is x1 + c*x2 the…
0
votes
2 answers

How many function evaluations executed between 2 iterations in Scipy minimize

I am using scipy minimize function, mostly the BFGS method. I need to find how many function evaluation were executed between 2 following iterations. This function evaluation usually aim to calculate numerical derivatives. If it is possible to find…
Tamuzd
  • 33
  • 3
0
votes
1 answer

Fitting 2 experimental datasets using scipy - chemical reaction - SOLVED

Long time lurking, first time posting. I am working with a chemical system that is detected only for a certain period of time, so I will have the reaction and the decay of the signal. The equation is given by: Derivative(GL, t): (-k*GL) -…
0
votes
1 answer

Scipy.optimize.minimize function results in wrong results. Equal to inital values, stops after 1 iteration

I am trying to execute a minimize function from Scipy however I am receiving wrong answers and it stops after a single iteration. Problem introduction: When I got this code running I would like to optimize a reactor size, the variables are therefore…
Aike
  • 3
  • 1
0
votes
0 answers

How to define the constrains and bounds of scipy.optimize.minimize

I have two matrix r and w. r is a (3,4) matrix which is constant and w is a (4,3) matrix which is variable and the target I'm trying to optimize r = [[0.1,0.15,0.03,0.2], [0.1,0.15,0.11,0.1], [-0.3,0.37,0.25,-0.1]] -I want to minimize the…
xlian
  • 1
  • 2
0
votes
1 answer

Performing scipy.optimize.minimize with Martin Eastwood's MPE formula

I have difficulty performing scipy.optimize.minimize with Martin Eastwood's interpolation formula— z=(x^w1/(x^w2+y^w3))*w4 * 17 (we get 16 instead of 17 while x[3], x[4], x[16], x[18] reside in the formula) My data set (17/12/12…
user19119603
0
votes
1 answer

finding Intersection using scipy.optimize.minimize

I'm trying to find x of intersection between two simple math functions using only scipy.optimize.minimize I found the point successfully using (fsolve) fsolve(lambda t: f1(t) - f2(t), x0) but I'm limited to using only minimize and I couldn't find…
0
votes
1 answer

Callback gradient norm from scipy.minimise (python)

I am using scipy.minimize with the 'CG' method and I want to callback the gradient norm at each iteration. So far, I have been able to call back the function at each iteration using this: def min_method(fn, grad, x0): all_fn = [fn(x0).item()] …
0
votes
1 answer

How to use scipy minimization with GPU in google collab?

I had to change my runtime type to GPU in collab as otherwise, the RAM was crashing. However, when I use GPU I am getting an error while executing the scipy minimization. The error is as follows :- ------Start-------- Traceback (most recent call…
Jeet
  • 359
  • 1
  • 6
  • 24