Questions tagged [scipy-optimize-minimize]

446 questions
2
votes
1 answer

How to give additional input to objective function of scipy.optimize.minimize other than independent variables

I am using scipy library for an optimization task. I have a function which has to be minimized. My code and function looks like import numpy as np from scipy.optimize import minimize from scipy.optimize import Bounds bounds =…
chink
  • 1,505
  • 3
  • 28
  • 70
2
votes
1 answer

Scipy minimize successfully terminates, but doesn’t fulfill inequality constraints

I'm trying to minimize the function 0.5*(x^2+y^2) subject to a series (N=20) of inequality constraints of the form x a1+y a2+a3 z >= 1. The solution should be around x=0.50251, y=-0.5846, z=0.36787. The routine terminates with the message…
Emi
  • 81
  • 7
2
votes
2 answers

Confidence interval for result of multivariate minimization/fitting

I have a set of observations [x(t), y(t)], which I try to fit to a certain assumption: x=Fx(ax, bx, t), y=Fy(ay, by, t). Fx and Fy are linear, but the noise of observations is significantly not gaussian. For this I perform minimization of a…
2
votes
1 answer

How to set goal parameters to solve a multiobjective problem with scipy.optimize?

I have spent several hours trying to get my head around the scipy.optimize.minimize function. I have got this working: def poly_fun(coeffs,a,x): predicted=10**np.polynomial.polynomial.polyval(np.log10(a),coeffs) …
2
votes
1 answer

callback in scipy.optimize does not call first value

I've got this simple Problem with callbacks in scipy. I'm using optimize.minimize with values (func, x0, callback=callbackFunc). The callback function does work, BUT only returns the values after step…
2
votes
1 answer

Problems with minimizing 2-dimenshional function in Python's scipy.optimize

I want to minimize 2-dimenshional function and have such Python code: def f(x,y): return (x-1.0)**2 + (y-2.0)**2 res = minimize(f, x0 = [0.0,0.0], bounds = ((-5,5),(-5,5)), method = 'L-BFGS-B') And it doesn't work, because of such error (this…
K. Kovalev
  • 925
  • 1
  • 6
  • 6
2
votes
1 answer

Python: Minimization of a function with potentially random outputs

I'm looking to minimize a function with potentially random outputs. Traditionally, I would use something from the scipy.optimize library, but I'm not sure if it'll still work if the outputs are not deterministic. Here's a minimal example of the…
Lyjat
  • 121
  • 3
1
vote
1 answer

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 of the data. Here the curve_fit works fine, but…
andrerud
  • 146
  • 1
  • 11
1
vote
1 answer

Finding a fast optimization algorithm to solve a non-linear equation with unique positive solution

Goal: Find a fast algorithm in Python that solves the function f(x) below for its positive solution. def f(x): return (l / ((np.tile(r, (n, 1)).transpose() / D / (np.tile(x, (n, 1)) / D).sum(axis = 0)).sum(axis = 1))) - x l, r, and x are…
1
vote
1 answer

scipy.optimize.fmin "ValueError: Unable to coerce to Series"

this is my first time using scipy.optimize.fmin() and I'm not sure if I've written my function correctly. I'm getting this error: ValueError: Unable to coerce to Series, length must be 11: given 0 I've tried reading the few other posts about this…
1
vote
0 answers

Scipy minimize SLSQP: Exit Message 3

I want to solve a multivariable optimization with inequality constraints using the scipy minimize() methode with SLSQP: min a: f(a): g (a) <= SIGMA While my smaller model with the vector {a} of size 6 performs well for the function…
1
vote
1 answer

How to create a minimizing function in python

How should I write this minimize function in order to always get 0 as the result of the calc function? def calc(x, a, b, c, d): z = b + c + d y = x * a - z - x * a * 0.015 return y def minimize(a, b, c, d): z = b + c + d # 0 =…
Herberts
  • 68
  • 5
1
vote
1 answer

Find best minima for initial conditions for past solution to match present values known

I have in Python an ODE system to solve and it is splitted in 2 parts : a past time solution and a future time solution : Here is the ODE system : # defining system def sys_to_solve(t, funcs): return [ funcs[0] * funcs[1], ( …
1
vote
1 answer

Fitting Data with Scipy Optimize Minimize with Both Constraints and Bounds

I'm currently trying to fit some data using Scipy's optimize.minimize function in Python. I have both constraints and bounds that need to be considered during the optimization process. I have found that the method 'trust-constr' works well for me,…
1
vote
1 answer

How to Express a Feasible Region That is a Union of Sets in Scipy

I am a newbie in optimization with scipy. I have a nonlinear problem where the feasible region is as follows: How can I express this region in scipy? Defining a feasible region as the intersection of constraints is all I can do. But when it comes…
Leelou
  • 11
  • 2