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

📄 sdmlme.m

📁 这是matlab解2阶锥工具包
💻 M
字号:
function [quiz,lmeindex] = sdmlme(quiz,dimrow,dimcol,name)% SDMPB/SDMLME - declare a new equality constraint%% [quiz,lmeindex] = sdmlme(quiz,dimrow,dimcol,name);%%   Adds an equality constraint (to be specified afterwards)%   <dimrow> and <dimcol> are the row and column sizes%   of each block of the matrix equality (default <dimcol=dimrow>)%   <name> is an optional string that describes the equality.%% Examples:%%   [quiz,lmeindex] = sdmlme(quiz,4,3,'1st example')%   declares a constraint with 4 rows and 3 columns - no block partitioning.%%   [quiz,lmeindex] = sdmlme(quiz,[1 2],[3 4],'2nd example')%   declares a block partitioned constraint with four blocks such that:%             | B1    B3 | = 0%             | B2    B4 | %   where B1 is a 1-by-3 matrix%         B4 is a 2-by-4 matrix%% SEE ALSO sdmvar, sdmlmi, sdmeq and sdmsol.%   This file is part of SeDuMi Interface 1.04 (JUL2002)%   Last update 6th September 2002%   Copyright (C) 2002 Dimitri Peaucelle & Krysten Taitz%   LAAS-CNRS, Toulouse, France% %   This program is free software; you can redistribute it and/or modify%   it under the terms of the GNU General Public License as published by%   the Free Software Foundation; either version 2 of the License, or%   (at your option) any later version.% %   This program is distributed in the hope that it will be useful,%   but WITHOUT ANY WARRANTY; without even the implied warranty of%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%   GNU General Public License for more details.% %   You should have received a copy of the GNU General Public License%   along with this program; if not, write to the Free Software%   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.    %%% check inputs  if nargin<2    error('not enough input arguments');  elseif nargin>4    error('too many input arguments');  elseif ~isa(quiz,'sdmpb')    error('1st input argument must be a SDMPB object');  elseif nargin<3    dimcol=dimrow;    name='NO NAME';  elseif nargin<4    name='NO NAME';  end;      %%% check dimrow input  if min(size(dimrow))~=1    error('2nd input argument (row dimensions of blocks) must be a vector ');  elseif any(round(dimrow)~=dimrow)    error('2nd input argument (row dimension of blocks) is not a vector of integer');  elseif any(dimrow<=0)    error('2nd input argument (row dimension of blocks) must be positive');  end;  %%% check dimcol input  if min(size(dimcol))~=1    error('3rd input argument (column dimensions of blocks) must be a vector ');;  elseif any(round(dimcol)~=dimcol)    error('3rd input argument (column dimension of the constraint) is not a vector of integer');  elseif any(dimcol<=0)    error('3rd input argument (column dimension of the constraint) must be positive');  end;  %%% check name input  if ~ischar(name)    error('3rd input argument (name of the constraint) must be a string');  end;  %%% clear the previous solution if necessary  quiz = sdmclear(quiz);  %%% define the new equality constraint  dimrow=sdmvec(dimrow);  dimcol=sdmvec(dimcol);  nbblockrow=length(dimrow);  nbblockcol=length(dimcol);  quiz.eq.nb=quiz.eq.nb+1;  lmeindex=quiz.eq.nb;  if isempty(quiz.eq.M)    previousM=0;  else    previousM=quiz.eq.M(lmeindex-1);  end;  sdrow = sum(dimrow);  sdcol = sum(dimcol);  quiz.eq.row=[quiz.eq.row,sdrow];  quiz.eq.col=[quiz.eq.col,sdcol];  quiz.eq.m=[quiz.eq.m,previousM+1];  quiz.eq.M=[quiz.eq.M,previousM+sdrow*sdcol];  quiz.eq.c=[quiz.eq.c;(sparse(sdrow*sdcol,1))];  quiz.eq.At=...      [quiz.eq.At;(sparse(sdrow*sdcol,size(quiz.eq.At,2)))];  quiz.eq.Atconj=...      [quiz.eq.Atconj;(sparse(sdrow*sdcol,size(quiz.eq.Atconj,2)))];  quiz.eq.name{lmeindex}=name;  quiz.eq.mnorm{lmeindex}=-Inf;  %%% Temporary vector to save the place of the first element of each block  blockmrow=ones(nbblockrow,1)+tril(ones(nbblockrow,nbblockrow),-1)*dimrow;  blockMrow=tril(ones(nbblockrow,nbblockrow))*dimrow;  blockmcol=ones(nbblockcol,1)+tril(ones(nbblockcol,nbblockcol),-1)*dimcol;  blockMcol=tril(ones(nbblockcol,nbblockcol))*dimcol;  quiz.eq.blockmrow{lmeindex}=blockmrow;  quiz.eq.blockMrow{lmeindex}=blockMrow;  quiz.eq.blockmcol{lmeindex}=blockmcol;  quiz.eq.blockMcol{lmeindex}=blockMcol;   

⌨️ 快捷键说明

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