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?