I will make the following assumptions:
- $Q$ is symmetric positive semidefinite
- $r^Tx \ge 0$
Note that maximizing $\frac{r^Tx}{X^TQx}$ is equivalent to minimizing $\frac{X^TQx}{r^Tx}$ .
Under the stated assumptions, this is a convex optimization problem, which can be submitted to and solved by Gurobi.
The easiest way of doing so is using a convex optimization tool such as CVX or CVXPY. The CVX code would be
cvx_begin
cvx_solver gurobi
variable x(n)
minimize(quad_over_lin(chol(A)*x,r'*x))
cvx_end
which uses the CVX function quad_over_lin
. chol(A)
is the upper triangular Cholesky factor of A.
CVXPY also has the same quad_ovdr_lin
function as CVX, but depending on which function is called to compute the Cholesky factor, you would need to apply a transpose to the Cholesky factor if a lower triangular Cholesky factor is generated
This could instead be done using a "native" Gurobi interface. In that case, you would need to minimize a new variable, t, subject to the rotated second order constraint:
norm(chol(A)*x) <= sqrt(t*r'*x), t >= 0, r'*x >= 0
using the appropriate syntax to specify this constraint for whatever interface you are using. As before, if chol(A) is lower triangular, you need to use its transpose.