⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lmi.m

📁 国外专家做的求解LMI鲁棒控制的工具箱,可以相对高效的解决LMI问题
💻 M
字号:
function F = lmi(X,handlestring,dummy,noprune)
% The command lmi is obsolete, see help sdpvar/set

% Author Johan L鰂berg
% $Id: lmi.m,v 1.14 2005/05/03 13:27:35 joloef Exp $

%superiorto('sdpvar')

fast = 0;
noprune = 0;
switch nargin
    case 0
        F.clauses={};
        F.LMIid    = [];
        F.savedata = [];
        F = class(F,'lmi');
        return
    case 1
        handlestring = '';       
        % ok probably, check later
    case 2
        if ~isa(handlestring,'char')
            error('The handle must be a string')
        end
    case 4
        handlestring = '';        
        noprune = 1;
        
    otherwise
        error('Wrong number of arguments')
end

F.clauses  = {};
F.LMIid    = [];
F.savedata = [];

try
    F = class(F,'lmi');
catch
    disp('Failure in creating SET object. Restart MATLAB and try again, or type clear classes')
end

% Return empty LMI in degenerate case
if isempty(X)
    return
end

% 0 : Nothing (i.e error)
% 1 : LMI
% 2 : Elementwise
% 3 : Equality
% 4 : SOCC 
% 5 : Rotated Lorentz
% 9 : KYP constraint
%10 : Eigenvalue constraint
%11 : Sum of square constraint
%12 : Logic CNF
switch class(X)
case 'lmi'
    F = X;
    return
case 'char'
    try
        % Parse (check for old notation, take care of ||...|| notation)
        sdpvarExpr = parseLMI(X);
        % Old notation
        X = strrep(X,'.>','>');
        X = strrep(X,'.<','<');
     %   X = strrep(X,'=','==');X = strrep(X,'====','==');
    catch
        error(lasterr)
    end
    % Evaluate
    try
        Fi=evalin('caller',sdpvarExpr);
        switch class(Fi)
            case 'sdpvar'
                Fi = {Fi};
                strict = 0;
            case 'constraint'
                [Fi,strict] = getlist(Fi);
            otherwise              
                error('The string does not define an SDPVAR object')
        end

    catch
        error(lasterr)
    end

case 'sdpvar'
    Fi = {X};
    strict = 0;
    X='Numeric value';
    
case 'logic'
    Fi = {X};
    strict = 0;
    X = 'Numeric value';
    
case 'constraint'
    [Fi,strict] = getlist(X);    
    X='Numeric value';
    
otherwise
    error('The first argument should be an sdpvar object or string.')
end

% Return empty LMI in degenerate case
if all(cellfun('isempty',Fi))
    return
end

i = 1;
while i <= length(Fi)
    thisFi = Fi{i};
    if ~isempty(thisFi)
        if isa(thisFi,'logic')
            TypeofConstraint = 12;
        else
            TypeofConstraint = gethackflag(Fi{i});
        end
        % User just sent a sdpvar object, interpret as X>0
        if (TypeofConstraint==0)
            TypeofConstraint = 1;
        end
        
        if (TypeofConstraint==1)
            [n,m]=size(thisFi);
            if (n~=m) | ((TypeofConstraint == 1) & (n*m==1)) | ~ishermitian(thisFi) 
                TypeofConstraint = 2;
            end
        end
        
        if TypeofConstraint == 2

            % remove constraint of the type set(0 >= 0)
            B = getbase(thisFi);
            if 0
                % Detect constraint set(negative number >= 0)
                % removed due to problems with mpt toolbox
                candidates = find(B(:,1) < 0);
                if ~isempty(candidates)
                    Bv = B(candidates,2:end);
                    dummy = any(Bv,2);
                    used = find(dummy);
                    if length(used) < size(Bv,1)
                        thisFi = thisFi(candidates(used));
                        if any(B(candidates(find(~dummy)),1) < 0)
                            % error('Trivially infeasible : There are negative constants in this element-wise constraint.');
                        end
                    end
                end
            end
            if ~noprune
                Bv = B(:,2:end);
                used = find(any(Bv,2));
                if length(used)<size(Bv,1)
                    thisFi = thisFi(used);
                end
            end
        end

        switch TypeofConstraint
        case {1,2,3,4,5,7,8,9,10,11,12,13}
            F.clauses{i}.data=thisFi;
            F.clauses{i}.type = TypeofConstraint;
            F.clauses{i}.symbolic=X;
            F.clauses{i}.handle=handlestring;        
            F.clauses{i}.strict = strict(i);
            F.clauses{i}.cut = 0;
            F.LMIid = [F.LMIid yalmip('lmiid')];
            i = i + 1;                      
        otherwise
            error('Error in argument in LMI. Please report bug');
        end
    end
    
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -