Skip to main content

All Questions

1 vote
1 answer
84 views

Applying scipy.minimize to Pandas dataframe with parameters

I have a function defined by f(x_0, x_1) = a(x_1 - x_0^2)^2 + (b - x_0)^2, where a and b are some parameters: def f(x): return a*(x[1]-x[0]**2)**2+(b-x[0])**2 where x=np.array([x_0,x_1]) is a numpy ...
Ishigami's user avatar
  • 580
0 votes
0 answers
101 views

`scipy.optimize.minimize` gives different results on GCP and Mac

SciPy's minimize() gives different results on different machines: sp.optimize.minimize(cost_function, x_init, bounds=x_bounds, args=args_in, method='SLSQP', options={'maxiter': sim_config['maxiter'], '...
AdityaT101's user avatar
1 vote
2 answers
79 views

Fitting two curves with a variable number of parameters using `scipy.optimize.least_squares()`

I'm writing code to fit parameters of related pairs of functions from a family using the scipy.optimize.least_squares() function and it seems that the test parameters are not being passed to the ...
JoDraX's user avatar
  • 121
1 vote
0 answers
97 views

SciPy optimization for FEA truss structure

I am trying to optimize the weight of a truss structure by changing the areas. I have this (shortened/verified code for FEA truss) where x is a array of element areas: stresses = np.zeros(10) def FEA(...
al512's user avatar
  • 45
0 votes
1 answer
85 views

pH equilibria optimization leads to numerical instability

I'm creating a pH equilibrium calculator. Starting with compositions of acids / bases the calculator should come up with the equilibrated concentrations of each component, based on physical constants. ...
Sovm's user avatar
  • 59
-1 votes
1 answer
159 views

Assistance in setting up a custom method for Scipy Basinhopping

I'm trying to set a custom method for the local minimization. From my understanding of basinhopping, you start with an initial starting condition, minimize using a local method, then use basinhopping ...
samman's user avatar
  • 613
1 vote
1 answer
68 views

SciPy's scipy.optimize.minimize not obeying constraints

I'm trying to fit a parabola using SciPy's optimize.minimize to some scattered data according to some constraints: the area under the curve and that the curve passes through the initial and end points ...
andrerud's user avatar
  • 166
0 votes
0 answers
229 views

TypeError: objective() takes 1 positional argument but 2 were given, in scipy.optimize, minimize function

I want to get the optimal value of alpha that balance the risk and the cost.(There are alpha_risk, alpha_cost, and risk_cost function given). Would set this problem as to minimize risk for a given ...
celi's user avatar
  • 13
1 vote
0 answers
51 views

Minimizing second input in scipy.minimize_scalar (with first one passed as an argument)

I have defined a function that I want to minimize using minimize_scalar, this function func(a,b) has two inputs and I want to pass the first one as an argument, while default for it is the second. ...
SDA_exp's user avatar
  • 11
2 votes
2 answers
101 views

Curve fitting: How to optimize x_value model for curve fitting in python

I am trying to fit an exponential curve into my data. However, I am having some trouble defining the x_value model properly in order to have a representative curve-fit to the data. I would think that ...
onia106's user avatar
  • 51
0 votes
0 answers
20 views

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) . . . ...
the.lotuseater's user avatar
0 votes
0 answers
218 views

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)**...
Glenbreaks's user avatar
0 votes
1 answer
932 views

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 ...
Samuel Adip Gonzalez Acharya's user avatar
0 votes
1 answer
1k views

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 :- ---...
Jeet's user avatar
  • 395
0 votes
0 answers
2k views

dimension error with scipy optimize.minimize

I want to minimise the objective function: objective_function_2() subject to the inequality constraints 69 < T(x) < 71. The objective of the optimisation is to find the set of Fourier series ...
kodimarka's user avatar

15 30 50 per page