Question about multi-objecitve optimization in Yalmip

57 views
Skip to first unread message

bin sun

unread,
Sep 19, 2017, 4:50:59 PM9/19/17
to YALMIP
I have an optimization problem,I have two decision variables: I and position. I want to get  max sum(I) but this sum(I) is based on another decision variable position(pos). So I build a program like this:

clear all
close all


L=1000; 
dist=100;  
n=3;   
N=[3,3,3];
R=[0.079e-3,0.079e-3,0.079e-3];
lamda1=[0,0,0];
lamda2=[0,0,0];
Tamb=[15,15,15];
Tmax=[90-Tamb(1),90-Tamb(2),90-Tamb(3)];  
u=[1,1,1];   
rous=[1,1,1];   
Wd=[0,0,0];
De=[72.9,72.9,72.9];
T1=[0.325,0.325,0.325];
T2=[0.042,0.042,0.042];
T3=[0,0,0];
T4=[0.637,0.637,0.637];
c= zeros(n,n);
d= zeros(1,n);     
deno=zeros(1,n);
a=zeros(1,n);
sum=0

pos=intvar(1,3);                                                %Here I have two decision variables. But during calculate the best I, the position have to be used! I choose three positions from five 
                                                                             % and try to find the max sum(I)
I=intvar(1,3);

for i=1:n
    for j=1:n 
        if j~=i
            dprim=sqrt((abs(pos(i)-pos(j))*dist)^2+(2*L)^2)       %I use another decision variable here
            d0=dist*abs(pos(i)-pos(j))
            c(i,j)=(N(j)*R(j)*(1+lamda1(j)+lamda2(j))*u(j)*rous(j)/(2*pi)*log(dprim/d0))/(R(i)*T1(i)+N(i)*R(i)*(1+lamda1(i))*T2(i)+N(i)*R(i)*(1+lamda1(i)+lamda2(i))*(T3(i)+T4(i)))
            sum=sum+N(j)*Wd(j)*log(dprim/d0);
        else
            c(i,j)=0
        end
    end
    d(i)=(Tmax(i)-Wd(i)*(0.5*T1(i)+N(i)*(T2(i)+T3(i)+T4(i)))-rous(j)/(2*pi)*sum)/(R(i)*T1(i)+N(i)*R(i)*(1+lamda1(i))*T2(i)+N(i)*R(i)*(1+lamda1(i)+lamda2(i))*(T3(i)+T4(i)))
   
end


f=-I(1)-I(2)-I(3);

F=[alldifferent(pos)]+[1<=pos(1,1)<=5]+[1<=pos(1,2)<=5]+[1<=pos(1,3)<=5]+[1/d(1)*I(1,1)*I(1,1)+c(1,2)/d(1)*I(1,2)*I(1,2)+c(1,3)/d(1)*I(1,3)*I(1,3)<=1];
sol=optimize(F,f);
I=value(I)   %double(I)
pos=value(pos)

The red part shows my problem. When calculate I's constraint, I have to use another decision variable: position. Is that ok? It shows the error that"Multiplying NaN with an SDPVAR makes no sense." Is that mean I can't optimize this problem? 

Could you please show me some similar examples or help me change this code?
New to Yalmip

Thank you very much,
Bin

Johan Löfberg

unread,
Sep 20, 2017, 2:13:35 AM9/20/17
to YALMIP

Johan Löfberg

unread,
Sep 20, 2017, 2:35:53 AM9/20/17
to YALMIP
and this

[1<=pos(1,1)<=5]+[1<=pos(1,2)<=5]+[1<=pos(1,3)<=5]

is simply [1 <= pos <= 5]


However, it is not clear that you've actually thought through how this will be solved. As you pose it now, it will be a nasty nonconvex nonlinear integer problem. Since you only have integer variables, you should effectively be able to write this as a MILP, as you effectively only have to enumerate the cases (in some efficient representation)

At least start by getting rid of stuff like log(1/expression) and replace with -log(expression) and (k*abs(stuff))^2 which simply is k^2*stuff^2, and you will at least arrive at a nonconvex nonlinear integer program that only is incredibly nasty, instead of very incredibly nasty (i.e., you still won't be able to solve it most likely)

I would probably start from scratch, and introduce new variables value(i,j) which is a binary variable representing that pos(i) = j, and then use implications to define the possible values nonlinear stuff

i.e., y = sin(pos(1)) can be written as y == value(1,:)*[sin(1);sin(2);...]

bin sun

unread,
Sep 20, 2017, 12:47:06 PM9/20/17
to YALMIP
Thank you very much. Yeah, this first time to touch yalmip and optimization.

Thank you very much for your help.

My problem looks like this: I have five available positions. I want to choose three from these five positions to put the cables and minimize the sum current of these three cables. But the current constraint is related to the positions.(If three cables are near than less current should carry). From your opinion, I should use (1,5) binary variable to represent the position variables?

Because I am totally new about yalmip and optimization, could you share me some examples which are similar to my problems? So I can more easily to understand the method.

Thank you very much for your time,
Best Regards,
Bin

Johan Löfberg

unread,
Sep 20, 2017, 1:08:57 PM9/20/17
to YALMIP
I don't have any examples

with just a few variables and nasty function ,your best approach is probably brute-force
Reply all
Reply to author
Forward
0 new messages