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

📄 get.m

📁 这是matlab解2阶锥工具包
💻 M
字号:
function out = get(quiz,info,index)% SDMPB/GET - get information on a SDMPB object%   % out = get(quiz,info,index);%%   <quiz>  is a SDMPB object that describes a linear optimisation problem%   <info> describes the information required about the SDMPB object%%    =[] (default): <out=[]> displays the help of SDMPB/GET%  %    ='name'      : <out> is the name of the SDMPB object%  %    ='varnb'     : <out> is the number of matrix variables defined so far%    ='vardecnb'  : <out> is the number of scalar decision variables defined so far%    ='varname'   : <out> is the name of the <index> variable X%    ='varinit'   : <out> is the value of the <index> variable X that will%                    be used for start when possible.%    ='varvalue'  : <out> is the value of the <index> variable X %                    once the SDMSOL was run%                    same as  >> out=quiz(index)%    ='vardec'    : <out> is the structure of the <index> variable X%                    same as  >> out=quiz{index}%                    It reads as follows (where i=sqrt(-1))  %       out(k,j)=  0     if X(k,j)=0%       out(k,j)= +n     if X(k,j) real    = n-th decision variable  %       out(k,j)= -n     if X(k,j) real    = (-1)*n-th decision variable%       out(k,j)= +n+n*i if X(k,j) complex = n-th decision variable  %       out(k,j)= -n-n*i if X(k,j) complex = (-1)*n-th decision variable  %       out(k,j)= +n-n*i if X(k,j) complex = conjugate n-th decision variable  %       out(k,j)= -n-n*i if X(k,j) complex = (-1)*conjugate n-th decision variable  %%    ='ineqnb'   : <out> is the number of inequality constraints defined so far%    ='ineqname' : <out> is the name of the <index> inequality constraint%    ='ineqdim'  : <out> is a vector with block dimensions of the <index>%                  inequality constraint.%    ='ineqmeig' : <out> is the minimal eigenvalue of the <index> inequality constraint %                  once the SDMSOL was run%                  the constraint is satisfied if meig>=0.  %  %    ='eqnb'     : <out> is the number of equality constraints defined so far%    ='eqname'   : <out> is the name of the <index> equality constraint%    ='eqdimrow' : <out> is a vector with row block dimensions of the%                  <index> equality constraint%    ='eqdimcol' : <out> is a vector with column block dimensions of the%                  <index> equality constraint%    ='eqnorm'   : <out> is the norm of the <index> equality constraint %                   once the SDMSOL was run%                   the constraint is satisfied if mnorm<=eps.  %  %    ='objname'  : <out> is the name of the objective%    ='objopt'   : <out> is the optimal value of the objective once the SDMSOL was run%%    ='solver'   : <out> is the information on SeDuMi's convergence%                  once the SDMSOL was run (see SEDUMI)%%    ='ynorm'    : <out> is the norm of the decision variables vector%                  once the SDMSOL was run (see SEDUMI)%%    ='feas'     : <out>=1 if problem is feasible (optimal solution found)%                  <out>=0 if problem is marginal feasible (modify%                  parameters to improve convergence)%                  <out>=-1 if problem is infeasible%                  <out> is a string if the problem was not solved  %% SEE ALSO sdmvar, sdmset, sdmlmi, sdmobj 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.     out=[];  if nargin<3    index=0;  end;  if nargin<1    error('not enough input agruments');  elseif nargin>3    error('too many input arguments');  elseif ~isa(quiz,'sdmpb')    error('1st input argument must be a SDMPB object');  elseif ~isnumeric(index)    error('3rd input argument must be a positive integer');  elseif ( round(index)~=index ...         | max([1,1]~=size(index)) ...	 | index<0 )      error('3rd input argument must be a positive integer');  elseif nargin<2    help sdmpb/get  elseif isempty(info)    help sdmpb/get  elseif isequal(info,'name')    out=quiz.name; elseif isequal(info,'varnb')    out=quiz.var.nb;  elseif isequal(info,'vardecnb')    out=size(quiz.var.struc,2);      elseif isequal(info,'ineqnb')    out=quiz.ineq.nb;  elseif isequal(info,'eqnb')    out=quiz.eq.nb;  elseif isequal(info,'objname')    out=quiz.obj.name;  elseif isequal(info,'objopt')    out=quiz.obj.opt;  elseif isequal(info,'solver')    out=quiz.info;  elseif isequal(info,'ynorm')    out=norm(quiz.var.ysol);  elseif isequal(info,'feas')    switch quiz.feas     case 'feasible';      out=1;     case 'infeasible'      out=-1;     case 'marginal feasible'      out=0;     otherwise            out=quiz.feas;    end;    elseif nargin<3    error('not enough input arguments');  elseif isequal(info,'vardec')    if ~index | index>quiz.var.nb      error('3rd input argument (index) exceeds number of variables')    end;    varm=quiz.var.m(index);    varM=quiz.var.M(index);    if varM<varm      out=[];      disp('warning : index refers to a variable that was set to a constant');    else      varrow=quiz.var.row(index);      decvar1=sparse(quiz.K.ycomplex,1,quiz.K.ycomplex,size(quiz.var.struc,2),1);      decvar1=decvar1*i+(1:size(quiz.var.struc,2))';      decvar2=quiz.var.struc*decvar1;      decvar2conj=quiz.var.strucconj*decvar1;      decvar2=decvar2+conj(decvar2conj);      out=full(sdmmat(decvar2(varm:varM),varrow));    end;  elseif isequal(info,'varname')    if ~index | index>quiz.var.nb      error('3rd input argument (index) exceeds number of variables')    end;    out=quiz.var.name{index};  elseif isequal(info,'varvalue')    if ~index | index>quiz.var.nb      error('3rd input argument (index) exceeds number of variables')    elseif isempty(quiz.var.ysol)      error('No solution has been calculated')    end;    varm=quiz.var.m(index);    varM=quiz.var.M(index);    if varM<varm      out=full(quiz.var.set{index});      disp('warning : index refers to a variable that was set to a constant');    else      %% Rebuilding of the variable      ytot=quiz.var.struc*quiz.var.ysol;      ytotconj=quiz.var.strucconj*quiz.var.ysol;      varm=quiz.var.m(index);      varM=quiz.var.M(index);      if (varM-varm)>=0        varrow=quiz.var.row(index);        value=full(sdmmat(ytot(varm:varM),varrow));        valueconj=full(sdmmat(ytotconj(varm:varM),varrow));        value=value+conj(valueconj);        out=value;      end;    end;	  elseif isequal(info,'ineqname')    if ~index | index>quiz.ineq.nb      error('3rd input argument (index) exceeds number of inequalities')    end;    out=quiz.ineq.name{index};  elseif isequal(info,'ineqdim')    if ~index | index>quiz.ineq.nb      error('3rd input argument (index) exceeds number of inequalities')    elseif quiz.ineq.M(index)<quiz.ineq.m(index)      warning('the LMI constraint referred by the 3rd input argument (index) has been removed');      out=0;    else      tmp=quiz.ineq.blockM{index}-quiz.ineq.blockm{index}+1;      out=tmp';    end;  elseif isequal(info,'ineqmeig')    if ~index | index>quiz.ineq.nb      error('3rd input argument (index) exceeds number of inequalities')    elseif quiz.ineq.M(index)<quiz.ineq.m(index)      out=0;    else      out=quiz.ineq.meig{index};    end;  elseif isequal(info,'eqname')    if ~index | index>quiz.eq.nb      error('3rd input argument (index) exceeds number of equalities');    end;    out=quiz.eq.name{index};  elseif isequal(info,'eqdimrow')    if ~index | index>quiz.eq.nb      error('3rd input argument (index) exceeds number of equalities')    elseif quiz.eq.M(index)<quiz.eq.m(index)      warning('the LME constraint referred by the 3rd input argument (index) has been removed');      out=0;    else      tmp=quiz.eq.blockMrow{index}-quiz.eq.blockmrow{index}+1;      out=tmp';    end;  elseif isequal(info,'eqdimcol')    if ~index | index>quiz.eq.nb      error('3rd input argument (index) exceeds number of equalities')    elseif quiz.eq.M(index)<quiz.eq.m(index)      warning('the LME constraint referred by the 3rd input argument (index) has been removed');      out=0;    else      tmp=quiz.eq.blockMcol{index}-quiz.eq.blockmcol{index}+1;      out=tmp';    end;  elseif isequal(info,'eqnorm')    if ~index | index>quiz.eq.nb      error('3rd input argument (index) exceeds number of equalities')    elseif quiz.eq.M(index)<quiz.eq.m(index)      out=0;    else      out=quiz.eq.mnorm{index};    end;  else    error('wrong value of 2nd input argument: type >> help sdmpb/get ')  end; 

⌨️ 快捷键说明

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