在定义的范围内寻找功能的最小值

时间:2018-09-05 12:39:50

标签: python scipy

我需要找到给定范围内某些Y的最小值X。我正在尝试使用scipy模块。

我想找到的功能最小化是:

(x - 100) / 100

这是我所做的:

from __future__ import division
import numpy as np
from scipy.optimize import minimize

def f(x):
    Y = (x - 100) / 100
    return Y

min_result = minimize(f, 2, method="SLSQP", options = {'disp': False}, bounds=(0,101))
print("Minima found at: X = {}, Y = {}".format(min_result.x, min_result.fun))

运行上面的代码时,出现以下错误:

IndexError: SLSQP Error: the length of bounds is not compatible with that of x0.

这可能是什么原因?我需要找到X的最小值,介于0和100之间。

0 个答案:

没有答案
相关问题