Home > matpower7.1 > lib > opf_gen_cost_fcn.m

opf_gen_cost_fcn

PURPOSE ^

OPF_GEN_COST_FCN Evaluates polynomial generator costs and derivatives.

SYNOPSIS ^

function [f, df, d2f] = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt)

DESCRIPTION ^

OPF_GEN_COST_FCN  Evaluates polynomial generator costs and derivatives.
   [F, DF, D2F] = OPF_GEN_COST_FCN(X, BASEMVA, COST, MPOPT)

   Evaluates the polynomial generator costs and derivatives.

   Inputs:
     X : single-element cell array with vector of (active or reactive)
         dispatches (in per unit)
     BASEMVA : system per unit base
     GENCOST : standard gencost matrix corresponding to dispatch
               (active or reactive) provided in X
     IG : vector of generator indices of interest
     MPOPT : MATPOWER options struct

   Outputs:
     F  : sum of generator polynomial costs
     DF : (optional) gradient (column vector) of polynomial costs
     D2F : (optional) Hessian of polynomial costs

   Examples:
       f = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt);
       [f, df] = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt);
       [f, df, d2f] = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [f, df, d2f] = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt)
0002 %OPF_GEN_COST_FCN  Evaluates polynomial generator costs and derivatives.
0003 %   [F, DF, D2F] = OPF_GEN_COST_FCN(X, BASEMVA, COST, MPOPT)
0004 %
0005 %   Evaluates the polynomial generator costs and derivatives.
0006 %
0007 %   Inputs:
0008 %     X : single-element cell array with vector of (active or reactive)
0009 %         dispatches (in per unit)
0010 %     BASEMVA : system per unit base
0011 %     GENCOST : standard gencost matrix corresponding to dispatch
0012 %               (active or reactive) provided in X
0013 %     IG : vector of generator indices of interest
0014 %     MPOPT : MATPOWER options struct
0015 %
0016 %   Outputs:
0017 %     F  : sum of generator polynomial costs
0018 %     DF : (optional) gradient (column vector) of polynomial costs
0019 %     D2F : (optional) Hessian of polynomial costs
0020 %
0021 %   Examples:
0022 %       f = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt);
0023 %       [f, df] = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt);
0024 %       [f, df, d2f] = opf_gen_cost_fcn(x, baseMVA, gencost, ig, mpopt);
0025 
0026 %   MATPOWER
0027 %   Copyright (c) 1996-2017, Power Systems Engineering Research Center (PSERC)
0028 %   by Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia
0029 %   and Ray Zimmerman, PSERC Cornell
0030 %
0031 %   This file is part of MATPOWER.
0032 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0033 %   See https://matpower.org for more info.
0034 
0035 %%----- initialize -----
0036 if isempty(ig)
0037     [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0038     ig = find(gencost(:, MODEL) == POLYNOMIAL);     %% poly MW / MVAr costs
0039 end
0040 PQg = x{1};                 %% active or reactive dispatch in p.u.
0041 ng = length(PQg);           %% number of dispatchable injections
0042 
0043 %%----- evaluate objective function -----
0044 xx = PQg(ig) * baseMVA;     %% active or reactive dispatch in MW/MVAr
0045 f = sum( totcost(gencost(ig, :), xx) ); %% cost of poly P or Q
0046 
0047 %%----- evaluate cost gradient -----
0048 if nargout > 1
0049     %% polynomial cost of P and Q
0050     df = zeros(ng, 1);      %% w.r.t p.u. Pg / Qg
0051     df(ig) = baseMVA * polycost(gencost(ig, :), xx, 1);
0052 
0053     %% ---- evaluate cost Hessian -----
0054     if nargout > 2
0055         %% polynomial generator costs
0056         d2f = sparse(ig, ig, baseMVA^2 * polycost(gencost(ig, :), xx, 2), ng, ng);
0057     end
0058 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005