how to make my model work?(“gurobi does not support general nonlinearities”) #1453
Answered
by
johanlofberg
TBZ8005
asked this question in
Optimization modelling
-
this model is optimizing the matrix multiplication to approximate the DFT matrix, if I choose solver as gurobi+, the answer always violate the constraint; and if I choose solver as gurobi, yalmip will warn me "Solver not applicable (gurobi does not support general nonlinearities)" maxK = 4;
q = 3;
dom = [-(2.^[q-1:-1:0]), 0, 2.^[0:q-1]];
% dom1 = dom'+dom.*1i;
A_real = intvar(2^t, 2^t, maxK, 'symmetric');
A_imag = intvar(2^t, 2^t, maxK, 'symmetric');
rowDist = ones(1, maxK)*2^t;
beta = intvar(1,1,'full');
Constraints = [(-100*2^t <= beta <= 100*2^t):'beta boundary', dom(1) <= A_real(:) <= dom(end), dom(1) <= A_imag(:) <= dom(end)];
Constraints = [Constraints, ismember(A_real(:), dom):['ismember1']];
Constraints = [Constraints, ismember(A_imag(:), dom):['ismember2']];
Constraints = [Constraints, (A_imag(:)'*A_imag(:) >= 1):'at least 1 imag part'];
A = A_real+A_imag*1i;
% to constraint the sparsity
for j = 1:maxK
for i = 1:2^t
Constraints = [Constraints, (1 <= nnz(A(i, :, j)) <= 2):'nonzeros constraints'];
end
end
% to constraint the full rank
for i = 1:maxK
A_det = det(A(:, :, i));
Constraints = [Constraints, ((real(A_det))^2+(imag(A_det))^2 >= 0.5):['Det' num2str(i) 'not equal to zero']];
end
A_prod = fold(@mtimes, mat2cell(reshape(A, 2^t, 2^t * maxK), 2^t, rowDist), eye(2^t));
% Constraints = [Constraints, nnz(A_prod(:)) >= 4^t-3];
Objective = (beta.*dftmtx(2^t)-A_prod);
target = 0.5^t*norm(Objective, 'fro');
ops = sdpsettings('verbose',2,'debug',1,'showprogress',1,'solver','gurobi','relax',0);
ops.allownonconvex = 2;
ops.gurobi.FuncNonLinear = 1;
ops.gurobi.TuneTimeLimit = 100;
% ops.gurobi.ScaleFlag = 2;
% ops.gurobi.TimeLimit = 36020;
% ops.gurobi.IntegralityFocus = 1;
% ops.gurobi.IntFeasTol = 1e-6;
% ops.gurobi.LazyConstraints = 1;
% ops.gurobi.Aggregate = 0;
ops.gurobi.PoolSearchMode = 2;
% ops.gurobi.PoolGap = 0;
% ops.gurobi.DualReductions = 0;
% ops.gurobi.MIPGap = 0.05;
ops.gurobi.MIPFocus = 2;
ops.gurobi.Presolve = 0;
ops.gurobi.NumericFocus = 3;
% ops.gurobi.NoRelHeurTime = 600;
ops.copt.TuneTimeLimit = 0;
ops.copt.TimeLimit = 620;
res1 = optimize(Constraints, target, ops)
res.result = rmse(value(A_prod), value(beta).*dftmtx(2^t), "all"); could you please help me to make it works? |
Beta Was this translation helpful? Give feedback.
Answered by
johanlofberg
Nov 24, 2024
Replies: 1 comment 2 replies
-
The determinant is a (horrible) high-order polynomial, and thus gurobi is not applicable. You will have to come up wit a smarter way to avoid low-rank solutions. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
TBZ8005
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The determinant is a (horrible) high-order polynomial, and thus gurobi is not applicable. You will have to come up wit a smarter way to avoid low-rank solutions.