0

I want to solve a maximisation problem with objective

f(x, y, z) = 0.5 * (x^2 + y^2 + z^2)

with x, y, z in [0, 1].

However when feeding this problem to CPLEX with the code below, it prompts an error saying that my objective is non-convex.

Also I should say that I checked the .lp file to be sure that I have correctly stated the problem.

import cplex


p = cplex.Cplex()
p.objective.set_sense(p.objective.sense.maximize)

p.variables.add(ub=[1, 1, 1],
                names=["x", "y", "z"])


qmat = [[[0], [1.]],
        [[1], [1.]],
        [[2], [1.]]]
p.objective.set_quadratic(qmat)

p.write("qpex.lp")

p.solve()

I don't understand why since my function f is definitely convex (the Hessian is the identity matrix). What am I doing wrong?

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
Xb19
  • 130
  • 2
  • 10

1 Answers1

2

Notice that when you specify the objective

p.objective.set_sense(p.objective.sense.maximize)

You have specified it to be a maximization problem.

To make it a convex optimization problem, you should be solving a minimization problem instead.

Minimizing a convex function is a convex optimization problem, maximizing a convex function in general is not a convex optimization problem.

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
  • So is there a solution to solve this problem ? Minimizing -f is not allowed either since -f is not convex... – Xb19 Jun 16 '19 at 15:43
  • perhaps use a non-convex optimizer? For your particular problem, we want the solution to be as far from the origina as possible, hence the answer is (1,1,1). – Siong Thye Goh Jun 16 '19 at 15:54
  • another way is let X=x^2, Y=y^2, Z=z^2, and the problem is equivalent to maximize 0.5(X+Y+Z) subject to 0<=X<=1 , 0<=Y<=1, 0<=Z<=1. it is now a linear programming problem. but of course, this is not a general approach. – Siong Thye Goh Jun 16 '19 at 15:59