solving Quadratic programming by Gurobi Mex

383 views
Skip to first unread message

dexter

unread,
Aug 9, 2011, 5:51:35 PM8/9/11
to Gurobi Optimization
I try to solve QP by Gurobi Mex, could you tell me how to get
opts.QP.qrow and opts.QP.qcol, and what's meaning of QP.qrow and
QP.qcol? Citing the example from Gurobi Mex website:

min 0.5 x0^2 - x0*x1 + x1^2 - 2*x0 - 6*x1,

c = [-2 -6]; % objective linear term
opts.QP.qrow = int32([0 0 1]); % indices of x0, x0, x1 as in (0.5
x0^2 - x0*x1 + x1^2); use int64 if sizeof(int) is 8 for your system
opts.QP.qcol = int32([0 1 1]); % indices of x0, x1, x1 as in (0.5
x0^2 - x0*x1 + x1^2); use int64 if sizeof(int) is 8 for your system
opts.QP.qval = [0.5 -1 1]; % coefficients of (0.5 x0^2 - x0*x1 +
x1^2)

Also could you tell me how to set the options for QP without
constraints? Thank you very much for your time.

Best
Dexter

Wotao Yin

unread,
Aug 10, 2011, 10:39:48 PM8/10/11
to Gurobi Optimization
Hi Dexter,

Let me try to use the example of min 0.5 x0^2 - x0*x1 + x1^2 - 2*x0 -
6*x1.

First, the linear part of the objective function is - 2*x0 - 6*x1.
Its coefficients are specified in c = [-2 -6];

Next, the second-order part of the objective function is 0.5 x0^2 -
x0*x1 + x1^2. Let's rewrite it as

0.5 x0 * x0 - x0 * x1 + x1 * x1. ....................... (1)

Its has three monomial terms, and each is the product of two variables
and a coefficient.

opts.QP.qrow = int32([0 0 1]) specifies those first variables, which
are x0, x0, x1 in their order appeared in (1).

opts.QP.qcol = int32([0 1 1]) specifies those second variables, which
are x0, x1, x1 in their order appeared in (1).

Last, opts.QP.qval = [0.5 -1 1] specifies those coefficients, which
are 0.5, -1, 1 in their order appeared in (1).

If there is no constraint in your QP, just let A = [ ]; and b=[ ];

Best,

Wotao

dexter

unread,
Aug 12, 2011, 12:01:53 AM8/12/11
to Gurobi Optimization
got it. Thanks so much for your answer.

- Dexter
> > Dexter- Hide quoted text -
>
> - Show quoted text -

dexter

unread,
Sep 26, 2011, 3:07:14 PM9/26/11
to Gurobi Optimization
Hi Wotao,
Could you give an example to illustrate how to set A for non-linear
constraint by Gurobi Mex? I encounter a kind of constraint like H ≤ w'
μ+ Φ^-1 (α) [w' Σ w]^(1/2) where Φ^-1(α) is inverse normal cumulative
distribution function, μ Σ H α are parameters and w is variable.
Thanks a lot for your time.


Best
Dexter
> > Dexter- 隐藏被引用文字 -
>
> - 显示引用的文字 -

Wotao Yin

unread,
Sep 26, 2011, 3:10:07 PM9/26/11
to gur...@googlegroups.com
Dexter,

Unfortunately, it's not a QP. It is an SOCP. Please check out solver Mosek.

--
Wotao Yin
Rice University | Computational & Applied Math | wotaoyin.com


2011/9/26 dexter <dext...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages