Home > matpower7.0 > most > lib > t > t_most_30b_1_1_0_uc.m

t_most_30b_1_1_0_uc

PURPOSE ^

T_MOST_30B_1_1_0_UC Tests for MOST.

SYNOPSIS ^

function t_most_30b_1_1_0_uc(quiet)

DESCRIPTION ^

T_MOST_30B_1_1_0_UC  Tests for MOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_30b_1_1_0_uc(quiet)
0002 %T_MOST_30B_1_1_0_UC  Tests for MOST.
0003 
0004 %   MOST
0005 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MOST.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://github.com/MATPOWER/most for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 n_tests = 17;
0017 
0018 t_begin(n_tests, quiet);
0019 
0020 casename = 't_case30_most';
0021 
0022 %% options
0023 mpopt = mpoption('verbose', 0, 'out.all', 0);
0024 % mpopt = mpoption('verbose', 2, 'out.all', -1);
0025 mpopt = mpoption(mpopt, 'out.bus', 0, 'out.branch', 0, 'out.gen', 2);
0026 mpopt = mpoption(mpopt, 'opf.violation', 5e-7, 'mips.comptol', 5e-8);
0027 if have_fcn('intlinprog')
0028     mpopt = mpoption(mpopt, 'linprog.Algorithm', 'dual-simplex');
0029     mpopt = mpoption(mpopt, 'intlinprog.RootLPAlgorithm', 'dual-simplex');
0030     mpopt = mpoption(mpopt, 'intlinprog.TolCon', 1e-9);
0031     mpopt = mpoption(mpopt, 'intlinprog.TolGapAbs', 0);
0032     mpopt = mpoption(mpopt, 'intlinprog.TolGapRel', 0);
0033     mpopt = mpoption(mpopt, 'intlinprog.TolInteger', 1e-6);
0034     %% next line is to work around a bug in intlinprog
0035     % (Technical Support Case #01841662)
0036     mpopt = mpoption(mpopt, 'intlinprog.LPPreprocess', 'none');
0037 end
0038 mpoptac = mpoption(mpopt, 'model', 'AC');
0039 mpoptdc = mpoption(mpopt, 'model', 'DC');
0040 mpopt = mpoption(mpopt, 'most.solver', 'DEFAULT');
0041 
0042 %% turn off warnings
0043 s7 = warning('query', 'MATLAB:nearlySingularMatrix');
0044 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0045 warning('off', 'MATLAB:nearlySingularMatrix');
0046 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0047 
0048 %% define named indices into data matrices
0049 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0050     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0051 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0052     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0053     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0054 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0055     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0056     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0057 [CT_LABEL, CT_PROB, CT_TABLE, CT_TBUS, CT_TGEN, CT_TBRCH, CT_TAREABUS, ...
0058     CT_TAREAGEN, CT_TAREABRCH, CT_ROW, CT_COL, CT_CHGTYPE, CT_REP, ...
0059     CT_REL, CT_ADD, CT_NEWVAL, CT_TLOAD, CT_TAREALOAD, CT_LOAD_ALL_PQ, ...
0060     CT_LOAD_FIX_PQ, CT_LOAD_DIS_PQ, CT_LOAD_ALL_P, CT_LOAD_FIX_P, ...
0061     CT_LOAD_DIS_P, CT_TGENCOST, CT_TAREAGENCOST, CT_MODCOST_F, ...
0062     CT_MODCOST_X] = idx_ct;
0063 
0064 %% reserve and delta offers
0065 xgd_table.colnames = {
0066     'CommitKey', ...
0067         'CommitSched', ...
0068             'PositiveActiveReservePrice', ...
0069                     'PositiveActiveReserveQuantity', ...
0070                             'NegativeActiveReservePrice', ...
0071                                     'NegativeActiveReserveQuantity', ...
0072                                             'PositiveActiveDeltaPrice', ...
0073                                                     'NegativeActiveDeltaPrice', ...
0074 };
0075 xgd_table.data = [
0076     1   1   10.1    15      10.0    15      0.1     0.0;
0077     1   1   10.3    30      10.2    30      0.3     0.2;  
0078     1   1   10.5    20      10.4    20      0.5     0.4;  
0079     1   1   10.7    25      10.6    25      0.7     0.6;
0080     1   1   20.1    25      20.0    25      60.1    60.0; 
0081     1   1   20.3    15      20.2    15      15.1    15.0;
0082     1   1   20.5    30      20.4    30      60.3    60.2;
0083     1   1   20.7    15      20.6    15      15.3    15.2;
0084     1   1   30.1    15      30.0    15      60.3    60.4;
0085     1   1   30.3    30      30.2    30      30.1    30.0;
0086     1   1   30.5    25      30.4    25      60.7    60.6;
0087     1   1   30.7    30      30.6    30      30.3    30.2;
0088     2   1   0.001   50      0.002   50      0       0;
0089     2   1   0.001   50      0.002   50      0       0;
0090     2   1   0.001   50      0.002   50      0       0;
0091     2   1   0.001   50      0.002   50      0       0;
0092     2   1   0.001   50      0.002   50      0       0;
0093     2   1   0.001   50      0.002   50      0       0;
0094     2   1   0.001   50      0.002   50      0       0;
0095     2   1   0.001   50      0.002   50      0       0;
0096     2   1   0.001   50      0.002   50      0       0;
0097     2   1   0.001   50      0.002   50      0       0;
0098     2   1   0.001   50      0.002   50      0       0;
0099     2   1   0.001   50      0.002   50      0       0;
0100     2   1   0.001   50      0.002   50      0       0;
0101     2   1   0.001   50      0.002   50      0       0;
0102     2   1   0.001   50      0.002   50      0       0;
0103     2   1   0.001   50      0.002   50      0       0;
0104     2   1   0.001   50      0.002   50      0       0;
0105     2   1   0.001   50      0.002   50      0       0;
0106     2   1   0.001   50      0.002   50      0       0;
0107     2   1   0.001   50      0.002   50      0       0;
0108 ];
0109 
0110 %% contingency table
0111 % label probty  type        row column      chgtype newvalue
0112 contab = [
0113 %     1   0.002   CT_TBRCH    1   BR_STATUS   CT_REP  0;      %% line 1-2
0114 %     2   0.002   CT_TBRCH    2   BR_STATUS   CT_REP  0;      %% line 1-3, all power from gen1 flows via gen2
0115 %     3   0.002   CT_TBRCH    3   BR_STATUS   CT_REP  0;      %% line 2-4, a path to loads @ buses 7 & 8
0116 %     4   0.002   CT_TBRCH    5   BR_STATUS   CT_REP  0;      %% line 2-5, a path to loads @ buses 7 & 8
0117 %     5   0.002   CT_TBRCH    6   BR_STATUS   CT_REP  0;      %% line 2-6, a path to loads @ buses 7 & 8
0118 %     6   0.002   CT_TBRCH    36  BR_STATUS   CT_REP  0;      %% line 28-27, tie line between areas 1 & 3
0119 %     7   0.002   CT_TBRCH    15  BR_STATUS   CT_REP  0;      %% line 4-12, tie line between areas 1 & 2
0120 %     8   0.002   CT_TBRCH    12  BR_STATUS   CT_REP  0;      %% line 6-10, tie line between areas 1 & 3
0121 %     9   0.002   CT_TBRCH    14  BR_STATUS   CT_REP  0;      %% line 9-10, tie line between areas 1 & 3
0122 %     10  0.002   CT_TGEN     1   GEN_STATUS  CT_REP  0;      %% gen 1 at bus 1
0123 %     11  0.002   CT_TGEN     2   GEN_STATUS  CT_REP  0;      %% gen 2 at bus 2
0124 %     12  0.002   CT_TGEN     3   GEN_STATUS  CT_REP  0;      %% gen 3 at bus 22
0125 %     13  0.002   CT_TGEN     4   GEN_STATUS  CT_REP  0;      %% gen 4 at bus 27
0126 %     14  0.002   CT_TGEN     5   GEN_STATUS  CT_REP  0;      %% gen 5 at bus 23
0127 %     15  0.002   CT_TGEN     6   GEN_STATUS  CT_REP  0;      %% gen 6 at bus 13
0128 %     20  0.010   CT_TGEN     0   PMIN        CT_REL  1.1;    %% 10% load increase
0129 %     20  0.010   CT_TGEN     0   QMIN        CT_REL  1.1;
0130 %     21  0.010   CT_TGEN     0   PMIN        CT_REL  0.9;    %% 10% load decrease
0131 %     21  0.010   CT_TGEN     0   QMIN        CT_REL  0.9;
0132 ];
0133 clist = [];
0134 nc = length(clist);
0135 
0136 %% load the case
0137 mpc = loadcase(casename);
0138 ld = 195;
0139 [mpc.bus, mpc.gen] = scale_load(ld, mpc.bus, mpc.gen, ...
0140         [], struct('scale', 'QUANTITY'));
0141 gbus = mpc.gen(:, GEN_BUS);
0142 
0143 %% set PMIN to non-zero
0144 ig = find(~isload(mpc.gen));
0145 mpc.gen(ig, PMIN) = 0.2 * mpc.gen(ig, PMAX);
0146 
0147 %%-----  get OPF results  -----
0148 rdc = runduopf(mpc, mpoptdc);
0149 % rac = runopf(mpc, mpoptac);
0150 % save t_most4_soln rdc rac -v6
0151 % s = load('t_most4_soln');
0152 s.rdc = rdc;
0153 % s.rac = rac;
0154 
0155 %%-----  set up data for DC run (most)  -----
0156 ng = size(mpc.gen, 1);      %% number of gens
0157 xgd = loadxgendata(xgd_table, mpc);
0158 md = loadmd(mpc, [], xgd);
0159 
0160 if have_fcn('cplex')
0161     mpopt = mpoption(mpopt, 'cplex.lpmethod', 2);   %% dual-simplex
0162 end
0163 if have_fcn('gurobi')
0164     mpopt = mpoption(mpopt, 'gurobi.method', 1);    %% dual-simplex
0165 end
0166 if have_fcn('linprog')
0167     mpopt = mpoption(mpopt, 'linprog.Algorithm', 'dual-simplex');
0168 %     mpopt = mpoption(mpopt, 'linprog.Algorithm', 'simplex');
0169 %     mpopt = mpoption(mpopt, 'linprog.Algorithm', 'interior-point');
0170 %     mpopt = mpoption(mpopt, 'linprog.Algorithm', 'active-set');
0171 end
0172 
0173 % mpopt = mpoption(mpopt, 'most.solver', 'CPLEX');
0174 % mpopt = mpoption(mpopt, 'most.solver', 'GLPK');
0175 % mpopt = mpoption(mpopt, 'most.solver', 'GUROBI');
0176 % mpopt = mpoption(mpopt, 'most.solver', 'MOSEK');
0177 % mpopt = mpoption(mpopt, 'most.solver', 'OT');
0178 % mpopt = mpoption(mpopt, 'verbose', 3);
0179 
0180 %%-----  do DC run (most)  -----
0181 r = most(md, mpopt);
0182 
0183 %%-----  test the results  -----
0184 t = 'success1';
0185 t_ok(s.rdc.success, t);
0186 t = 'success2';
0187 t_ok(r.QP.exitflag, t);
0188 
0189 t = 'f';
0190 t_is(r.results.f, s.rdc.f, 4, t);
0191 
0192 t = 'Pg : base';
0193 t_is(r.flow(1,1,1).mpc.gen(:, PG), s.rdc.gen(:, PG), 5, t);
0194 
0195 t = 'genstatus : base';
0196 t_is(r.flow(1,1,1).mpc.gen(:, GEN_STATUS), s.rdc.gen(:, GEN_STATUS), 12, t);
0197 t_is(r.UC.CommitSched, s.rdc.gen(:, GEN_STATUS), 12, t);
0198 
0199 t = 'gen : base';
0200 t_is(r.flow(1,1,1).mpc.gen(:,1:MU_PMIN), s.rdc.gen(:,1:MU_PMIN), 3, t);
0201 
0202 t = 'energy prices';
0203 t_is(r.results.GenPrices, s.rdc.bus(gbus, LAM_P), 6, t);
0204 
0205 t = 'Pc';
0206 t_is(r.results.Pc, s.rdc.gen(:, PG), 4, t);
0207 
0208 t = 'Gmin';
0209 t_is(r.results.Pc - r.results.Rpm, s.rdc.gen(:, PG), 4, t);
0210 
0211 t = 'Gmax';
0212 t_is(r.results.Pc + r.results.Rpp, s.rdc.gen(:, PG), 4, t);
0213 
0214 t = 'upward contingency reserve quantities';
0215 t_is(r.results.Rpp, zeros(ng, 1), 4, t);
0216 
0217 t = 'downward contingency reserve quantities';
0218 t_is(r.results.Rpm, zeros(ng, 1), 4, t);
0219 
0220 t = 'upward contingency reserve prices';
0221 t_is(r.results.RppPrices, xgd.PositiveActiveReservePrice, 6, t);
0222 
0223 t = 'downward contingency reserve prices';
0224 t_is(r.results.RpmPrices, xgd.NegativeActiveReservePrice, 6, t);
0225 
0226 t = 'Rpmax_pos';
0227 vv = get_idx(r.om);
0228 Rpmax_pos = (r.QP.lambda.upper(vv.i1.Rpp(1):vv.iN.Rpp(1)) - r.QP.lambda.lower(vv.i1.Rpp(1):vv.iN.Rpp(1))) / mpc.baseMVA;
0229 t_is(Rpmax_pos, zeros(ng, 1), 6, t);
0230 
0231 t = 'Rpmax_neg';
0232 Rpmax_neg = (r.QP.lambda.upper(vv.i1.Rpm(1):vv.iN.Rpm(1)) - r.QP.lambda.lower(vv.i1.Rpm(1):vv.iN.Rpm(1))) / mpc.baseMVA;
0233 t_is(Rpmax_neg, zeros(ng, 1), 6, t);
0234 
0235 %% turn warnings back on
0236 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0237 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0238 
0239 t_end;

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