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

📄 qprog.m

📁 primary dual 算法 解决Interior point
💻 M
字号:
function varargout = qprog (x, z, data, what)  [ H q P r b] = deal(data{:});  n            = length(x);  % The number of (primal) variables.  m            = length(b);  % The number of inequality constraints.    if strcmp(what,'objective')        % Compute the response of the quadratic objective function at x.    f = x'*H*x/2 + q'*x;    varargout = { f };  elseif strcmp(what,'gradient')        % Compute the gradient of the quadratic objective function at x. And, if    % requested, output the Hessian of the quadratic objective.    g = H*x + q;      varargout{1} = g;    if nargout == 2      varargout{2} = H;    end  elseif strcmp(what,'constraints')        % Compute the response of the vector-valued inequality constraint    % function. Repeat for each inequality constraint.    c = zeros(m,1);    for i = 1:m      c(i) = x'*P{i}*x/2 + r{i}'*x - b(i);    end    varargout = { c };  elseif strcmp(what,'jacobian')        % Compute the m x n Jacobian of the vector-valued constraint function,    % and the the n x n Hessian of the Lagrangian (minus the Hessian of the    % objective). Repeat for each inequality constraint.    J = zeros(m,n);    W = zeros(n);    for i = 1:m      J(i,:) = (P{i}*x + r{i})';      W      = W + z(i)*P{i};    end    varargout = { J W };  end

⌨️ 快捷键说明

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