Home > matpower7.0 > lib > 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-2016, Power Systems Engineering Research Center (PSERC)
0011 %   by Ray Zimmerman, PSERC Cornell
0012 %   & Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia
0013 %
0014 %   This file is part of MATPOWER.
0015 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0016 %   See https://matpower.org for more info.
0017 
0018 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0019 
0020 [ng, m] = size(gencost);
0021 totalcost = zeros(ng, size(Pg, 2));
0022 
0023 if ~isempty(gencost)
0024   ipwl = find(gencost(:, MODEL) == PW_LINEAR);
0025   ipol = find(gencost(:, MODEL) == POLYNOMIAL);
0026   if ~isempty(ipwl)
0027     x = gencost(:, COST:2:(m-1));
0028     y = gencost(:, (COST+1):2:m);
0029     for i = ipwl'
0030       if gencost(i, NCOST) > 0
0031 %         totalcost(i,:) = interp1(x(i, 1:gencost(i, NCOST)), ...
0032 %                                  y(i, 1:gencost(i, NCOST)), ...
0033 %                                  Pg(i,:), 'linear', 'extrap');
0034         j1 = 1:(gencost(i, NCOST) - 1);    j2 = 2:gencost(i, NCOST);
0035         pp = mkpp(x(i, 1:gencost(i, NCOST))', [(y(i,j2) - y(i,j1)) ./ (x(i,j2) - x(i,j1));  y(i,j1)]');
0036         totalcost(i,:) = ppval(pp, Pg(i,:));
0037       end
0038     end
0039   end
0040   for i = 1:size(totalcost, 2)
0041     totalcost(ipol, i) = polycost(gencost(ipol, :), Pg(ipol, i));
0042   end
0043 end

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