How to write a summation with index vector in the objective function?
1 次查看(过去 30 天)
显示 更早的评论
Hi, I want to do this optimization problem in Matlab,
I don't know how to do this summation with i belongs to varLambda_0, I write the code for varLambda_0, but I think it might be useless. BTW, we cannot drop the unnecessary elements in z, because we still need to use z to do the same optimization problem in the next stage. like
Thanks in advance!
for i = 1:length(y2)
if z(:,i)'*gammahat0_0 > a
Gamma_0(i)= i;
end
end
Gamma_0(Gamma_0==0) = []
0 个评论
回答(1 个)
Anmol Dhiman
2019-9-3
I am assuming gamma_hat_0to be vector, Z to be a matrix and Zi be a vector of equal size to gamma_hat_0. I am assuming a to be constant value
To find the lambda_0 from the first equation use
lambda_0=[];
for i =1: size(z,2)
temp = (z(:,i)'.*gamma_hat_0);
% temp will be a vector. Checking if every value in temp is greater
% than a
check = temp>a;
if(~ismember(0,check))
lambda_0(end+1)=i;
end
end
Each value of lambda_0 in the second equation can be used as
for i=1:length(lambda_0)
current_value = lambda_0(i);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Programming and Mixed-Integer Linear Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!