TypeError: 'float' object cannot be interpreted as an integer with solve_qp in python

ε祈祈猫儿з 提交于 2021-01-29 08:28:14

问题


I am new to optimization using python and I have a problem with using the predefined function solve_qp from qpsolvers to find the optimize solution of my problems here is my code:

import numpy as np

X = np.array([1., 2., 4., 6., 9.]).reshape(5, 1)
y = 0.5 + (0.3*X) + np.random.randn(5,1)

from qpsolvers import solve_qp
P = np.dot(X.T,X)
q = np.transpose(-2*np.dot(X.T,y))[0]
G = None
h = None
A = None
b = None
sol = solve_qp(P, q, G, h, A, b)

I got error with the predefined function TypeError: 'float' object cannot be interpreted as an integer but i don't know how to solve. Any help would be much appreciated. Thanks!

来源:https://stackoverflow.com/questions/64827910/typeerror-float-object-cannot-be-interpreted-as-an-integer-with-solve-qp-in-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!