Home > matpower7.0 > lib > opf_costfcn.m

opf_costfcn

PURPOSE ^

OPF_COSTFCN Evaluates objective function, gradient and Hessian for OPF.

SYNOPSIS ^

function [f, df, d2f] = opf_costfcn(x, om)

DESCRIPTION ^

OPF_COSTFCN  Evaluates objective function, gradient and Hessian for OPF.
   [F, DF, D2F] = OPF_COSTFCN(X, OM)

   Objective function evaluation routine for AC optimal power flow,
   suitable for use with MIPS or FMINCON. Computes objective function value,
   gradient and Hessian.

   Inputs:
     X : optimization vector
     OM : OPF model object

   Outputs:
     F   : value of objective function
     DF  : (optional) gradient of objective function (column vector)
     D2F : (optional) Hessian of objective function (sparse matrix)

   Examples:
       f = opf_costfcn(x, om);
       [f, df] = opf_costfcn(x, om);
       [f, df, d2f] = opf_costfcn(x, om);

   See also OPF_CONSFCN, OPF_HESSFCN.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [f, df, d2f] = opf_costfcn(x, om)
0002 %OPF_COSTFCN  Evaluates objective function, gradient and Hessian for OPF.
0003 %   [F, DF, D2F] = OPF_COSTFCN(X, OM)
0004 %
0005 %   Objective function evaluation routine for AC optimal power flow,
0006 %   suitable for use with MIPS or FMINCON. Computes objective function value,
0007 %   gradient and Hessian.
0008 %
0009 %   Inputs:
0010 %     X : optimization vector
0011 %     OM : OPF model object
0012 %
0013 %   Outputs:
0014 %     F   : value of objective function
0015 %     DF  : (optional) gradient of objective function (column vector)
0016 %     D2F : (optional) Hessian of objective function (sparse matrix)
0017 %
0018 %   Examples:
0019 %       f = opf_costfcn(x, om);
0020 %       [f, df] = opf_costfcn(x, om);
0021 %       [f, df, d2f] = opf_costfcn(x, om);
0022 %
0023 %   See also OPF_CONSFCN, OPF_HESSFCN.
0024 
0025 %   MATPOWER
0026 %   Copyright (c) 1996-2018, Power Systems Engineering Research Center (PSERC)
0027 %   by Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia
0028 %   and Ray Zimmerman, PSERC Cornell
0029 %
0030 %   This file is part of MATPOWER.
0031 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0032 %   See https://matpower.org for more info.
0033 
0034 %%----- evaluate objective function -----
0035 %% general nonlinear costs
0036 if nargout == 3
0037     [f, df, d2f]    = om.eval_nln_cost(x);
0038     if om.qdc.NS
0039         [fq, dfq, d2fq] = om.eval_quad_cost(x);
0040         f = f + sum(fq);
0041         df = df + dfq;
0042         d2f = d2f + d2fq;
0043     end
0044 elseif nargout == 2
0045     [f, df]   = om.eval_nln_cost(x);
0046     if om.qdc.NS
0047         [fq, dfq] = om.eval_quad_cost(x);
0048         f = f + sum(fq);
0049         df = df + dfq;
0050     end
0051 else
0052     f  = om.eval_nln_cost(x);
0053     if om.qdc.NS
0054         fq = om.eval_quad_cost(x);
0055         f = f + sum(fq);
0056     end
0057 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005