"Adding NaN to an SDPVAR makes no sense." That's why?

708 views
Skip to first unread message

Ding YiFan

unread,
Apr 29, 2016, 11:01:31 AM4/29/16
to YALMIP


   I write the codes as following:

     
IfTransfer=binvar(10,1);              
TimeOfTransfer=intvar(10,1);      

IfShift=binvar(10,1);              
GearOfShift=intvar(10,1);          

IfClip=binvar(10,1);              
GearOfClip=intvar(10,1);          


ResOfTransfer=IfTransfer.*TimeOfTransfer;            
ResOfShift=(IfShift.*GearOfShift)/10;              
ResOfClip=(IfClip.*GearOfClip)/10;                

AmountOfShift=ResOfShift.*AbilityOfShift;              
AmountOfClip=ResOfClip.*AbilityOfClip;                

DataOfShift=zeros(10,24);                            %errors happen here~~~~(>_<)~~~~
DataOfClip=zeros(10,24);
for i=1:10
   DataOfShift(i,:)=AmountOfShift(i)*WillOfShift(i,:);        
    DataOfClip(i,:)=AmountOfClip(i)*WillOfClip(i,:);            
end

SumOfTransfer=sum(abs(ResOfTransfer));
SumOfShift=sum(abs(DataOfShift(:)))/2;
SumOfClip=sum(abs(DataOfClip(:)));

f=400*SumOfTransfer+1*SumOfShift+1.2*SumOfClip;                  
Then some errors happen:
error using +  (line 56)
Adding NaN to an SDPVAR makes no sense.

error DataOfUsers (line 89)
f=400*SumOfTransfer+1*SumOfShift+1.2*SumOfClip;

Then Icheck the workspace and find that the variables  "DataOfShift" and "DataOfClip" are full of NaN.


However, if I change the following codes
DataOfShift=zeros(10,24);
DataOfClip=zeros(10,24);
into these:
DataOfShift=sdpvar(10,24);
DataOfClip=sdpvar(10,24);

Then those errors disappear.
 
But "DataOfShift" and "DataOfClip" are not the decision variables I want to get, they are just intermediate variables.


So what should I do?

Best Wishes.

Johan Löfberg

unread,
Apr 29, 2016, 11:04:47 AM4/29/16
to YALMIP

Johan Löfberg

unread,
Apr 29, 2016, 11:07:51 AM4/29/16
to YALMIP
i.e do

x=[]                   
for i=1:10
   x=[x;sdpvar(1,2)]  ;      
end

Johan Löfberg

unread,
Apr 29, 2016, 11:09:35 AM4/29/16
to YALMIP
but you could of course do DataOfShift=sdpvar(10,24);
DataOfClip=sdpvar(10,24); too, as you replace every row anyway. same result

Ding YiFan

unread,
May 2, 2016, 9:37:18 PM5/2/16
to YALMIP
Thank You!
Reply all
Reply to author
Forward
0 new messages