How to index lmi constraints?

4 ビュー (過去 30 日間)
Abdul
Abdul 2014 年 3 月 22 日
回答済み: Johan Löfberg 2014 年 4 月 1 日
Dear Sir/Madam I have a nx1 index set Code for sdpvar object K and want to constrain elements of K to be pairwise distinct. I am using yalmip with the following constaint. F =[F, implies(a1, K(i)-K(ii)<= -.5*rand(1)), implies(a2, K(i)-K(ii) >= .5*rand(1)), a1+a2==1]; where a1 and a2 are binary. I want to include this constraint inside nested loops for all pairs (i,ii) with ii>i both belonging to Code. What is the easiest way to do this preferably in a vectorized manner?

採用された回答

Johan Löfberg
Johan Löfberg 2014 年 4 月 1 日
Something like this would be a complete vectorization
n = 3;
[i,ii] = find(triu(ones(n),1));
index = sub2ind([n n],i,ii)
a1 = binvar(length(i),1);
a2 = binvar(length(i),1);
K = sdpvar(n);
F = [implies(a1, K(index) <= -0.1), implies(a2, K(index) >= 0.1), a1 + a2 == 1]

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Matrix Inequalities についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by