Home > matpower5.0 > t > t_totcost.m

t_totcost

PURPOSE ^

T_TOTCOST Tests for code in TOTCOST.

SYNOPSIS ^

function t_totcost(quiet)

DESCRIPTION ^

T_TOTCOST  Tests for code in TOTCOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_totcost(quiet)
0002 %T_TOTCOST  Tests for code in TOTCOST.
0003 
0004 %   MATPOWER
0005 %   $Id: t_totcost.m 1687 2010-06-01 20:11:37Z ray $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2010 by Power System Engineering Research Center (PSERC)
0008 %
0009 %   This file is part of MATPOWER.
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 %
0012 %   MATPOWER is free software: you can redistribute it and/or modify
0013 %   it under the terms of the GNU General Public License as published
0014 %   by the Free Software Foundation, either version 3 of the License,
0015 %   or (at your option) any later version.
0016 %
0017 %   MATPOWER is distributed in the hope that it will be useful,
0018 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0020 %   GNU General Public License for more details.
0021 %
0022 %   You should have received a copy of the GNU General Public License
0023 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0024 %
0025 %   Additional permission under GNU GPL version 3 section 7
0026 %
0027 %   If you modify MATPOWER, or any covered work, to interface with
0028 %   other modules (such as MATLAB code and MEX-files) available in a
0029 %   MATLAB(R) or comparable environment containing parts covered
0030 %   under other licensing terms, the licensors of MATPOWER grant
0031 %   you additional permission to convey the resulting work.
0032 
0033 if nargin < 1
0034     quiet = 0;
0035 end
0036 
0037 n_tests = 22;
0038 
0039 t_begin(n_tests, quiet);
0040 
0041 %% define named indices into data matrices
0042 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0043     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0044     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0045 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0046 
0047 %% generator cost data
0048 %    1    startup    shutdown    n    x1    y1    ...    xn    yn
0049 %    2    startup    shutdown    n    c(n-1)    ...    c0
0050 gencost = [
0051     2    0    0    3    0.01    0.1    1    0    0    0    0    0;
0052     2    0    0    5    0.0006    0.005    0.04    0.3    2    0    0    0;
0053     1    0    0    4    0    0    10    200    20    600    30    1200;
0054     1    0    0    4    -30    -2400    -20    -1800    -10    -1000    0    0;
0055 ];
0056 
0057 t = 'totcost - quadratic';
0058 t_is(totcost(gencost, [0;0;0;0]), [1;2;0;0], 8, t);
0059 t_is(totcost(gencost, [1;0;0;0]), [1.11;2;0;0], 8, t);
0060 t_is(totcost(gencost, [2;0;0;0]), [1.24;2;0;0], 8, t);
0061 
0062 t = 'totcost - 4th order polynomial';
0063 t_is(totcost(gencost, [0;0;0;0]), [1;2;     0;0], 8, t);
0064 t_is(totcost(gencost, [0;1;0;0]), [1;2.3456;0;0], 8, t);
0065 t_is(totcost(gencost, [0;2;0;0]), [1;2.8096;0;0], 8, t);
0066 
0067 t = 'totcost - pwl (gen)';
0068 t_is(totcost(gencost, [0;0;-10;0 ]), [1;2;-200;0], 8, t);
0069 t_is(totcost(gencost, [0;0;5;0 ]),   [1;2;100;0], 8, t);
0070 t_is(totcost(gencost, [0;0;10;0]),   [1;2;200;0], 8, t);
0071 t_is(totcost(gencost, [0;0;15;0]),   [1;2;400;0], 8, t);
0072 t_is(totcost(gencost, [0;0;20;0]),   [1;2;600;0], 8, t);
0073 t_is(totcost(gencost, [0;0;25;0]),   [1;2;900;0], 8, t);
0074 t_is(totcost(gencost, [0;0;30;0]),   [1;2;1200;0], 8, t);
0075 t_is(totcost(gencost, [0;0;35;0]),   [1;2;1500;0], 8, t);
0076 
0077 t = 'totcost - pwl (load)';
0078 t_is(totcost(gencost, [0;0;0;10 ]), [1;2;0;1000], 8, t);
0079 t_is(totcost(gencost, [0;0;0;-5 ]), [1;2;0;-500], 8, t);
0080 t_is(totcost(gencost, [0;0;0;-10]), [1;2;0;-1000], 8, t);
0081 t_is(totcost(gencost, [0;0;0;-15]), [1;2;0;-1400], 8, t);
0082 t_is(totcost(gencost, [0;0;0;-20]), [1;2;0;-1800], 8, t);
0083 t_is(totcost(gencost, [0;0;0;-25]), [1;2;0;-2100], 8, t);
0084 t_is(totcost(gencost, [0;0;0;-30]), [1;2;0;-2400], 8, t);
0085 t_is(totcost(gencost, [0;0;0;-35]), [1;2;0;-2700], 8, t);
0086 
0087 t_end;

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