lssol.m
来自「% Atomizer Main Directory, Version .802 」· M 代码 · 共 78 行
M
78 行
%LSSOL Convex quadratic programming and linear least-square code LSSOL by
% Gill et. al.
% [x,obj,lambda,istate,iter,inform,A,b,kx] = lssol(A,b,c,C,x,l,u,tp,msg,kx)
% solves the problem
% minimize f(x)
% subject to ( ) ( x ) ( )
% (l) =< ( ) =< (u)
% ( ) ( Cx) ( )
% where f(x) is one of the following objective functions:
% tp = 'fp' f(x) = none
% tp = 'lp' f(x) = c'*x
% tp = 'qp1' f(x) = 0.5*x'*A*x
% tp = 'qp2' f(x) = c'*x + 0.5*x'*A*x A symmetric and psd
% tp = 'qp3' f(x) = 0.5*x'*A'*A*x A symmetric and psd
% tp = 'qp4' f(x) = c'*x + 0.5*x'*A'*A*x A upper-trapezoidal
% tp = 'ls1' f(x) = 0.5*norm(b-A*x)^2
% tp = 'ls2' f(x) = c'*x + 0.5*norm(b-A*x)^2
% tp = 'ls3' f(x) = 0.5*norm(b-A*x)^2 A upper-trapezoidal
% tp = 'ls4' f(x) = c'*x + 0.5*norm(b-A*x)^2 A upper-trapezoidal
%
% On successful termination, x contains the optimal solution, and
% obj contains the final objective function value. Lambda contains
% the Lagrange multiplier vector, istate denotes the status of the
% constraints and iter denotes the number of iterations. Inform
% contains information about the exit status of LSSOL. Msg
% determines the amount of output. Msg=0 gives no output,
% msg = 10 gives one line per iteration. Kx determines the column
% ordering of R and A for the cases where A is upper-trapezoidal.
% On exit, A and b are transformed according to the user's guide.
%
% This version dated 16-Jan-1992.
% M-file written by Anders Forsgren
% Division of Optimization and Systems Theory
% Department of Mathematics
% Royal Institute of Technology
% S-100 44 Stockholm
% Sweden
% andersf@math.kth.se
function [x,obj,lambda,istate,iter,inform,A,b,kx] = lssol(A,b,c,C,x,l,u,tp,msg,kx)
[m,n] = size(A);
if m == 0
A = zeros(x');
b = 0;
[m,n] = size(A);
end
if nargin < 8
tp = 'ls1';
end
if nargin < 9
msg = 10;
end
if nargin < 10
kx = [1:m]';
end
[mC,nC] = size(C);
[lc] = length(c);
[lx] = length(x);
[ll] = length(l);
[lu] = length(u);
if (lc > 0 & lc ~= lx ) | ll ~= lu | ll ~= mC + lx | (nC > 0 & nC ~= lx),
clear m n mC nC lc lx ll lu obj lambda istate iter inform msg
disp(' ')
disp(' --- Error using lssol, incompatible dimensions of input data.')
disp(' --- Lssol not executed. Please check below and correct. ')
disp(' ')
whos
else
[x,obj,lambda,istate,iter,inform,A,b,kx] = lssolmex(A,b,c,C,x,l,u,tp,msg,kx);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?