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.
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 % $Id: totcost.m 1635 2010-04-26 19:45:26Z ray $ 0011 % by Ray Zimmerman, PSERC Cornell 0012 % & Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales 0013 % Copyright (c) 1996-2010 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 totalcost = zeros(ng, size(Pg, 2)); 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 j1 = 1:(gencost(i, NCOST) - 1); j2 = 2:gencost(i, NCOST); 0053 pp = mkpp(x(i, 1:gencost(i, NCOST))', [(y(i,j2) - y(i,j1)) ./ (x(i,j2) - x(i,j1)); y(i,j1)]'); 0054 totalcost(i,:) = ppval(pp, Pg(i,:)); 0055 end 0056 end 0057 end 0058 for i = 1:size(totalcost, 2) 0059 totalcost(ipol, i) = polycost(gencost(ipol, :), Pg(ipol, i)); 0060 end 0061 end