问题
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