1

I am very new to using IBM CPLEX , and am using CPLEX with Matlab. I was wondering how to compile a custom objective function in CPLEX using Matlab. The objective function is as follows: Optimization problem to replicate in CPLEX using MATLAB

Here aj is a column vector of size 36000 X 1 and A is a sparse matrix of size 36000 x 4503. wj is a column vector of size 4503 x 1 of optimization variables. Until now this is a simple cplexlsqnonneglin if we include the wj >=0 constraint. But I would also like to include the two other sum terms with 'beta' and lambda and the wjj = 0 constraint. Any help in recreating this optimization problem in CPLEX would be much appreciated.

Thanks in advance!

1 Answer 1

0

When you add the other terms into the objective, your problem becomes a general quadratic program. Since wj >= 0 we have that ||wj||_1 = e'*wj. So we can write your problem as:

 minimize  0.5*(aj - A*wj)'*(aj - A*wj) + 0.5*beta*wj'*wj + lambda*e'*w
   wj
 subject to  wj >= 0, wj(j) = 0

After pushing the quadratic terms in the objective together we have the following QP:

minimize  0.5*aj'*aj -aj'*A*wj + 0.5*wj'*(A'*A + beta*I)*w + lambda*e'*w
 wj
subject to  wj >= 0, w(j) = 0

I can't help you with CPLEX. But you can solve this problem with Gurobi in MATLAB using the following code

m = 36000;
n = 4503;
A  = sprand(m, n, .01);
aj = rand(m, 1);
lambda = 0.1;
beta   = 0.4;

j = 300;

model.objcon = 0.5*aj'*aj;
model.obj    = -aj'*A + lambda*ones(1,n);
model.A      =  sparse(1, n);
model.sense  = '=';
model.rhs    = 0;
model.Q      = 0.5*(A'*A + beta*speye(n));
model.vtype  = 'C';
model.lb     = zeros(n, 1);
model.ub     = inf(n,1);
model.ub(j)  = 0; % set 0 <= wj(j) <= 0

params.outputflag = 1;
result = gurobi(model, params);

if strcmp(result.status, 'OPTIMAL')
    wj = result.x(1:n);
end

For more details see the documentation on Gurobi's MATLAB interface: http://www.gurobi.com/documentation/5.6/reference-manual/matlab_gurobi

Note you may want to create variables and constraints to avoid forming A'*A + beta*I in the objective. For example you could create a new variable r and a constraint r = A*wj. Then the objective wj'*(A'*A + beta*I) wj would become r'*r + beta*wj'*wj. This may help with the numerics.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.