我正在尝试解决以下等式:
maximize x^{T}Ax
其中x
是3 X 1
要最大化的变量的向量,A
是值的3 X 3
矩阵。
所以基本上x^{T} = [a,b,c]
哪些是要最大化的未知数,A
可能类似于
A = [ [29, 29, 79],
[28, 28, 48],
[9, 40, 0 ]]
有人可以告诉我如何使用 PuLP 或 python 中的其他一些线性编程包以最大化问题的形式表示这一点吗?
任何帮助将非常感激。我对这个领域非常陌生,不知道如何开始表示这个公式。
到目前为止,我已经尝试使用CVXPY来模拟这个函数。我有以下代码,但看到一个错误:
[1] A = np.array([[29,29,79],[28,28,48],[9,40,0]])
[2] x=Variable(3)
[3] objective=Minimize(x.T*A*x)
Warning: Forming a nonconvex expression (affine)*(affine).
warnings.warn("Forming a nonconvex expression (affine)*(affine).")
[4] constraints=[0<=x,x<=1,sum_entries(x)==1] #what I'm trying to say is each entry of x should be between 0 and 1 and all entries should add up to 1.
[5] prob = Problem(objective, constraints)
[6] prob.solve()
DCPError: Problem does not follow DCP rules.