Home > matpower5.1 > totcost.m

totcost

PURPOSE ^

TOTCOST Computes total cost for generators at given output level.

SYNOPSIS ^

function totalcost = totcost(gencost, Pg)

DESCRIPTION ^

TOTCOST    Computes total cost for generators at given output level.
   TOTALCOST = TOTCOST(GENCOST, PG) computes total cost for generators given
   a matrix in gencost format and a column vector or matrix 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 totalcost = totcost(gencost, Pg)
0002 %TOTCOST    Computes total cost for generators at given output level.
0003 %   TOTALCOST = TOTCOST(GENCOST, PG) computes total cost for generators given
0004 %   a matrix in gencost format and a column vector or matrix of generation
0005 %   levels. The return value has the same dimensions as PG. Each row
0006 %   of GENCOST is used to evaluate the cost at the points specified in the
0007 %   corresponding row of PG.
0008 
0009 %   MATPOWER
0010 %   Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC)
0011 %   by Ray Zimmerman, PSERC Cornell
0012 %   & Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales
0013 %
0014 %   $Id: totcost.m 2644 2015-03-11 19:34:22Z ray $
0015 %
0016 %   This file is part of MATPOWER.
0017 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0018 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0019 
0020 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0021 
0022 [ng, m] = size(gencost);
0023 totalcost = zeros(ng, size(Pg, 2));
0024 
0025 if ~isempty(gencost)
0026   ipwl = find(gencost(:, MODEL) == PW_LINEAR);
0027   ipol = find(gencost(:, MODEL) == POLYNOMIAL);
0028   if ~isempty(ipwl)
0029     x = gencost(:, COST:2:(m-1));
0030     y = gencost(:, (COST+1):2:m);
0031     for i = ipwl'
0032       if gencost(i, NCOST) > 0
0033 %         totalcost(i,:) = interp1(x(i, 1:gencost(i, NCOST)), ...
0034 %                                  y(i, 1:gencost(i, NCOST)), ...
0035 %                                  Pg(i,:), 'linear', 'extrap');
0036         j1 = 1:(gencost(i, NCOST) - 1);    j2 = 2:gencost(i, NCOST);
0037         pp = mkpp(x(i, 1:gencost(i, NCOST))', [(y(i,j2) - y(i,j1)) ./ (x(i,j2) - x(i,j1));  y(i,j1)]');
0038         totalcost(i,:) = ppval(pp, Pg(i,:));
0039       end
0040     end
0041   end
0042   for i = 1:size(totalcost, 2)
0043     totalcost(ipol, i) = polycost(gencost(ipol, :), Pg(ipol, i));
0044   end
0045 end

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005