find_simple_variable_bounds.m
来自「求解线性矩阵不等式简单方便--与LMI工具箱相比」· M 代码 · 共 40 行
M
40 行
function [p,lower,upper] = find_simple_variable_bounds(p);
if any(p.K.q > 0) | any(p.K.s > 0)
lower = -inf(length(p.c),1);
upper = inf(length(p.c),1);
else
[lower,upper,used_rows] = findulb(p.F_struc,p.K);
used_rows = used_rows(~any(full(p.F_struc(used_rows,1+find(p.variabletype~=0))),2));
if ~isempty(used_rows)
p_temp = p;
p_temp.F_struc(p.K.f+used_rows,:)=[];
p_temp.K.l = p.K.l - length(used_rows);
if size(p.F_struc,1) > 0
% These variables are still used in some other constraints
still_used = find(sum(abs(p_temp.F_struc(:,2:end)),1) > 0);
if ~isempty(still_used)
% we have to keep these variables
lower(still_used) = -inf;
upper(still_used) = inf;
% They are used here
keep_rows = find(sum(abs(p.F_struc(:,1+still_used)),2) > 0);
if any(keep_rows>(p.K.l + p.K.f))
% error('Tell johan to fix the SDP case in find_simple_variable_bounds!')
end
used_rows = used_rows + p.K.f;
used_rows = setdiff(used_rows,keep_rows);
p.F_struc(used_rows,:)=[];
p.K.l = p.K.l - nnz(used_rows>p.K.f);
p.K.f = p.K.f - nnz(used_rows<=p.K.f);
else
p = p_temp;
end
else
p = p_temp;
end
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?