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

📄 fmu.m

📁 matlab算法集 matlab算法集
💻 M
字号:
function y = fmu (f,p,q,x,mu)
%-----------------------------------------------------------------------
% Usage:       y = fmu (f,p,q,x,mu)
%
% Description: Compute the generalized objective function:
%
%                 F(x) = f(x) + mu*(P(x) + Q(x))
%
% Inputs:       f  = name of objective function to minimize: f(x)
%               p  = name of equality constraint function: p(x) = 0
%               q  = name of inequality constraint function: q(x) >= 0
%
%                    The forms of f, p, and q are:
%
%                    function y = f(x)
%                    function u = p(x)
%                    function v = q(x)
%
%                    When f is called with n by 1 vector x, it must
%                    return the scalar y = f(x).  When p is called with 
%                    n by 1 vector x,it must compute r by 1 vector 
%                    u = p(x). When q is called with n by 1 vector x, 
%                    it must compute s by 1 vector v = q(x).
%               
%               x  = n by 1 vector of independent variables
%               mu = penalty paramter (mu >= 0)
%
% Outputs:      y = value of generalized objective function F(x):
%
%                      F(x) = f(x) + mu*(P(x) + Q(x)) 
%
%                   where P(x) and Q(x) are the penalty terms: 
%
%                      P(x) = p'(x)p(x)
%                      Q(x) = min([0,q(x)])'min([0,q(x)])
%------------------------------------------------------------------------

  infty = 10^100;
  chkvec (x,4,'fmu');

% Objective function
   
   y = feval(f,x);
   if mu <= 0
      return 
   end

% Equality constraints

   funp = getfun (p);
   if funp
     chkfun (feval(p,x),2,'fmu');
     u = feval(p,x);
     r = length (u);
      if norm(u,inf) < sqrt(infty)/(r*mu) 
         y = y + mu*dot(u,u);
      else 
         y = infty/r;
         return;
      end
   end

% Inequality constraints

   funq = getfun (q);
   if funq
      chkfun (feval(q,x),3,'fmu'); 
      v = feval(q,x);
      s = length (v);      
      if norm(v,inf) < sqrt(infty)/(s*mu) 
         y = y + mu*dot(min(0,v),min(0,v));
      else 
         y = infty/s;
      end
   end
%------------------------------------------------------------------------
      

⌨️ 快捷键说明

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