0001 function t_runopf_w_res(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 if nargin < 1
0034 quiet = 0;
0035 end
0036
0037 t_begin(46, quiet);
0038
0039 if quiet
0040 verbose = 0;
0041 else
0042 verbose = 0;
0043 end
0044
0045 casefile = 't_case30_userfcns';
0046 mpopt = mpoption('OPF_VIOLATION', 1e-6, 'PDIPM_GRADTOL', 1e-8, ...
0047 'PDIPM_COMPTOL', 1e-8, 'PDIPM_COSTTOL', 1e-9);
0048 mpopt = mpoption(mpopt, 'OUT_ALL', 0, 'VERBOSE', verbose, 'OPF_ALG', 560);
0049
0050
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
0055 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0056 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0057
0058 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0059 r = runopf_w_res(casefile, mpopt);
0060 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0061 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0062 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0063 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0064 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0065 mpc = loadcase(casefile);
0066 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0067 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0068 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0069
0070 t = 'gen 5 no reserves : ';
0071 mpc = loadcase(casefile);
0072 mpc.reserves.zones(:, 5) = 0;
0073 mpc.reserves.cost(5) = [];
0074 mpc.reserves.qty(5) = [];
0075 r = runopf_w_res(mpc, mpopt);
0076 t_is(r.reserves.R, [25; 15; 0; 0; 0; 20], 4, [t 'R']);
0077 t_is(r.reserves.prc, [2; 2; 2; 2; 0; 5.5], 6, [t 'prc']);
0078 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0079 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0080 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0081 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0082 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0083 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0084
0085 t = 'extra offline gen : ';
0086 mpc = loadcase(casefile);
0087 idx = [1:3 5 4:6];
0088 mpc.gen = mpc.gen(idx, :);
0089 mpc.gencost = mpc.gencost(idx, :);
0090 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0091 mpc.reserves.cost = mpc.reserves.cost(idx);
0092 mpc.reserves.qty = mpc.reserves.qty(idx);
0093 mpc.gen(4, GEN_STATUS) = 0;
0094 r = runopf_w_res(mpc, mpopt);
0095 t_is(r.reserves.R, [25; 15; 0; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0096 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 5.5; 5.5], 6, [t 'prc']);
0097 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0098 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0099 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0100 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0101 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0102 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0103
0104 t = 'both extra & gen 6 no res : ';
0105 mpc = loadcase(casefile);
0106 idx = [1:3 5 4:6];
0107 mpc.gen = mpc.gen(idx, :);
0108 mpc.gencost = mpc.gencost(idx, :);
0109 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0110 mpc.reserves.cost = mpc.reserves.cost(idx);
0111 mpc.reserves.qty = mpc.reserves.qty(idx);
0112 mpc.gen(4, GEN_STATUS) = 0;
0113 mpc.reserves.zones(:, 6) = 0;
0114 mpc.reserves.cost(6) = [];
0115 mpc.reserves.qty(6) = [];
0116 r = runopf_w_res(mpc, mpopt);
0117 t_is(r.reserves.R, [25; 15; 0; 0; 0; 0; 20], 4, [t 'R']);
0118 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 0; 5.5], 6, [t 'prc']);
0119 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0120 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0121 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0122 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0123 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0124 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0125
0126 t = 'no qty (Rmax) : ';
0127 mpc = loadcase(casefile);
0128 mpc.reserves = rmfield(mpc.reserves, 'qty');
0129 r = runopf_w_res(mpc, mpopt);
0130 t_is(r.reserves.R, [39.3826; 0.6174; 0; 0; 19.3818; 0.6182], 4, [t 'R']);
0131 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 5, [t 'prc']);
0132 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 5, [t 'mu.l']);
0133 t_is(r.reserves.mu.u, [0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0134 t_is(r.reserves.mu.Pmax, [0.1; 0; 0; 0; 0.5; 0], 5, [t 'mu.Pmax']);
0135 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0136 t_is(r.reserves.totalcost, 176.3708, 4, [t 'totalcost']);
0137
0138 t = 'RAMP_10, no qty (Rmax) : ';
0139 mpc = loadcase(casefile);
0140 mpc.reserves = rmfield(mpc.reserves, 'qty');
0141 mpc.gen(1, RAMP_10) = 25;
0142 r = runopf_w_res(mpc, mpopt);
0143 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0144 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0145 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0146 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0147 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0148 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0149 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0150
0151 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0152
0153 t_end;