Are you saying you want to maximize a function involving convex quadratic function? I hope you are aware that it is a very very hard problem.
The sqrt operator in YALMIP is limited to scenarios where it can be implemented using an SOCP representation. Since you have nonconvex stuff, you don't have any solver which can mix the SOCP cone and nonconvex stuff. This is easily fixed though by using the sqrtm operator instead. With this, you allow YALMIP to model it directly as the square root (i.e., a callback in the solver) and thus simply use a nonlinear solver. No guarantees that you will find any solution though as it is a nonconvex problem (you could always thy the global solver bmibnb if the problem is small enough)
BTW, you are welcome over to the YALMIP google groups instead for further discussion (not to pollute OPTI support forum with YALMIP issues)
x = sdpvar(size(coil.Rfull,2),1);
Ex_part1 = coupling(kk).Ex_part1*omega*x;
Ey_part1 = coupling(kk).Ey_part1*omega*x;
Ez_part1 = coupling(kk).Ez_part1*omega*x;
% + A^t
Ex_part2 = coupling(kk).Ex_part2*omega*x;
Ey_part2 = coupling(kk).Ey_part2*omega*x;
Ez_part2 = coupling(kk).Ez_part2*omega*x;
Exsquare = (Ex_part1.^2 + 2*Ex_part1.*Ex_part2 + Ex_part2.^2);
Eysquare = (Ey_part1.^2 + 2*Ey_part1.*Ey_part2 + Ey_part2.^2);
Ezsquare = (Ez_part1.^2 + 2*Ez_part1.*Ez_part2 + Ez_part2.^2);
Objective = max(sqrtm(Exsquare+Eysquare+Ezsquare));
coil.CtargetFull = [coil.Cx;coil.Cy;coil.Cz];
% error constrains
lr = zeros(1,size(coil.btarget,2));
ur = zeros(1,size(coil.btarget,2));
for j=1:size(coil.CtargetFull,1)
if coil.btarget(j)<0
% lr and ur stands for "lower" and "upper"
lr(j) = (1+coil.error)*coil.btarget(j);
ur(j) = (1-coil.error)*coil.btarget(j);
elseif coil.btarget(j)>0
lr(j) = (1-coil.error)*coil.btarget(j);
ur(j) = (1+coil.error)*coil.btarget(j);
else
lr(j) = -0.001;
ur(j) = 0.001;
end
end
% the bounding calculation without reduction
% 20000 is used to reduce the possibilities,
% knowing that the normal coil is solved the value between
% 7129 and -7069
lb = ones(size(shield.Anorm,2),1)*-20000;
ub = ones(size(shield.Anorm,2),1)*20000;
index = 1;
for i=1:size(coil.subBoundaries,1)
for j=1:size(coil.subBoundaries(i).node,1)
lb(index) = 0; %boundary of the mesh have to be null
ub(index) = 0; %boundary of the mesh have to be null
index = index+1;
end
end
Constraints = [lr' <= coil.CtargetFull*x <= ur',...
lb<=x<=ub];
options = sdpsettings('verbose',2);
options = sdpsettings(options,'solver','bmibnb','showprogress',1);
options = sdpsettings(options,'showprogress',1);
solvesdp(Constraints,Objective,options)
coil.s = double(x);
displayStreamFunction(coil.listTriangle,coil.s,coil.listNode)
sdpvar t
Constraint = cone([repmat(t,1,size(Ex_part1,1));
(Ex_part1+Ex_part2)'
(Ey_part1+Ey_part2)'
(Ez_part1+Ez_part2)']);
more constraints...
instead of sqrt(3*x1^2+2*x1*x2+3*x2^2) which is sqrt(x'*[2 1;1 3]*x) work with norm(chol([2 1;1 3])*x)
for i=1:size(Ex_part2,1)
E3(i) = norm([Ex_part1(i)+Ex_part2(i);Ey_part1(i)+Ey_part2(i);Ez_part1(i)+Ez_part2(i)]);
end
maxVector = repmat(t,1,size(Ex_part1_3,1));
vector = [(Ex_part1+Ex_part2)';(Ey_part1+Ey_part2)';(Ez_part1+Ez_part2)'];
Constraints = [cone([maxVector;vector]),...
lr' <= coil.Ctarget*x <= ur',...
lb<=x<=ub];
for i=1:size(coil.subBoundaries,1)
lb(i) = 0; %boundary of the mesh have to be null
ub(i) = 0; %boundary of the mesh have to be null
end
% the bounding calculation with reduction
% 20000 is used to reduce the possibilities,
% knowing that the normal coil is given with value between
% 7129 and -7069
lb = ones(size(coil.Ctarget,2),1)*-20000;
ub = ones(size(coil.Ctarget,2),1)*20000;
for i = 1:length(data)
x(data(i)) = 0;
end
for i = 1:length(data)
x(i) = 0;
end
Constraints = [lr' <= coil.Ctarget*x <= ur',...
x(1:size(coil.subBoundaries,1))==0];
Hi again,
I have tested Mosek and Gurobi, they both succed in the minimization of the maximal induced voltage field!