Home > matpower5.0 > margcost.m

margcost

PURPOSE ^

MARGCOST Computes marginal cost for generators at given output level.

SYNOPSIS ^

function marginalcost = margcost(gencost, Pg)

DESCRIPTION ^

MARGCOST    Computes marginal cost for generators at given output level.
   MARGINALCOST = MARGCOST(GENCOST, PG) computes marginal cost for generators
   given a matrix in gencost format and a column vector of generation levels.
   The return value has the same dimensions as PG. Each row of GENCOST is
   used to evaluate the cost at the points specified in the corresponding row
   of PG.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function marginalcost = margcost(gencost, Pg)
0002 %MARGCOST    Computes marginal cost for generators at given output level.
0003 %   MARGINALCOST = MARGCOST(GENCOST, PG) computes marginal cost for generators
0004 %   given a matrix in gencost format and a column vector of generation levels.
0005 %   The return value has the same dimensions as PG. Each row of GENCOST is
0006 %   used to evaluate the cost at the points specified in the corresponding row
0007 %   of PG.
0008 
0009 %   MATPOWER
0010 %   $Id: margcost.m 2073 2012-08-01 18:41:49Z cvs $
0011 %   by Ray Zimmerman, PSERC Cornell
0012 %   & Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales
0013 %   Copyright (c) 1996-2012 by Power System Engineering Research Center (PSERC)
0014 %
0015 %   This file is part of MATPOWER.
0016 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0017 %
0018 %   MATPOWER is free software: you can redistribute it and/or modify
0019 %   it under the terms of the GNU General Public License as published
0020 %   by the Free Software Foundation, either version 3 of the License,
0021 %   or (at your option) any later version.
0022 %
0023 %   MATPOWER is distributed in the hope that it will be useful,
0024 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0026 %   GNU General Public License for more details.
0027 %
0028 %   You should have received a copy of the GNU General Public License
0029 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0030 %
0031 %   Additional permission under GNU GPL version 3 section 7
0032 %
0033 %   If you modify MATPOWER, or any covered work, to interface with
0034 %   other modules (such as MATLAB code and MEX-files) available in a
0035 %   MATLAB(R) or comparable environment containing parts covered
0036 %   under other licensing terms, the licensors of MATPOWER grant
0037 %   you additional permission to convey the resulting work.
0038 
0039 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0040 
0041 [ng, m] = size(gencost);
0042 marginalcost = zeros(ng, 1);
0043 
0044 if ~isempty(gencost)
0045   ipwl = find(gencost(:, MODEL) == PW_LINEAR);
0046   ipol = find(gencost(:, MODEL) == POLYNOMIAL);
0047   if ~isempty(ipwl)
0048     x = gencost(:, COST:2:(m-1));
0049     y = gencost(:, (COST+1):2:m);
0050     for i = ipwl'
0051       if gencost(i, NCOST) > 0
0052         c = diff(y(i,:)) ./ diff(x(i,:));
0053         k = find(Pg(i,:) <= x(i,:), 1);
0054         if isempty(k)
0055           marginalcost(i,:) = c(end);
0056         elseif k == 1
0057           marginalcost(i,:) = c(1);
0058         else
0059           marginalcost(i,:) = c(k-1);
0060         end
0061       end
0062     end
0063   end
0064   for i = ipol'
0065     marginalcost(i,:) = polyval(polyder(gencost(i, COST:(COST+gencost(i, NCOST)-1) )), Pg(i,:) );
0066   end
0067 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005