I am trying to solve a simple convex optimisation problem with cvxopt. I want to maximize the ROI function with x and y >=1 and x+y<=6
import numpy as np
def ROI(x,y):
return np.exp(-x)*x*10+np.exp(-y)*y**2*10
then I use cvxopt to minimize -ROI(x,y) subject to G*(x,y)' <= h
from cvxopt import solvers, blas, matrix, spmatrix, spdiag, log, div
G=matrix([[-1.,0.,1.],[0.,-1.,1.]],(3,2))
h=matrix([-4.,-1.,6.],(3,1))
def F(x=None, z=None):
if(x is None):
return 0,matrix([1.,1.],(2,1))
f = - ROI(x[0],x[1])
grad = matrix([(10*x[0]-10)*np.exp(-x[0]),(10*x[1]**2-20*x[1])*np.exp(-x[1])])
if (z is None):
return f,grad.T
d = [(-10*x[0]+20)*np.exp(-x[0])*z[0],(-10*x[1]**2-20+40*x[1])*np.exp(-x[1])*z[0]]
H = spdiag(d)
return f, grad.T, H
sol = solvers.cp(F, G, h)
the optimal solution given by the solver is (5,1) which is false, for example ROI(4,2)>ROI(5,1). Thank you for your help !