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, 'mips.gradtol', 1e-8, ...
0047 'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0048 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, 'opf.ac.solver', 'MIPS');
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 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0056 r = runopf_w_res(casefile, mpopt);
0057 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0058 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0059 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0060 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0061 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0062 mpc = loadcase(casefile);
0063 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0064 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0065 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0066
0067 t = 'gen 5 no reserves : ';
0068 mpc = loadcase(casefile);
0069 mpc.reserves.zones(:, 5) = 0;
0070 mpc.reserves.cost(5) = [];
0071 mpc.reserves.qty(5) = [];
0072 r = runopf_w_res(mpc, mpopt);
0073 t_is(r.reserves.R, [25; 15; 0; 0; 0; 20], 4, [t 'R']);
0074 t_is(r.reserves.prc, [2; 2; 2; 2; 0; 5.5], 6, [t 'prc']);
0075 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0076 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0077 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0078 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0079 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0080 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0081
0082 t = 'extra offline gen : ';
0083 mpc = loadcase(casefile);
0084 idx = [1:3 5 4:6];
0085 mpc.gen = mpc.gen(idx, :);
0086 mpc.gencost = mpc.gencost(idx, :);
0087 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0088 mpc.reserves.cost = mpc.reserves.cost(idx);
0089 mpc.reserves.qty = mpc.reserves.qty(idx);
0090 mpc.gen(4, GEN_STATUS) = 0;
0091 r = runopf_w_res(mpc, mpopt);
0092 t_is(r.reserves.R, [25; 15; 0; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0093 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 5.5; 5.5], 6, [t 'prc']);
0094 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0095 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0096 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0097 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0098 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0099 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0100
0101 t = 'both extra & gen 6 no res : ';
0102 mpc = loadcase(casefile);
0103 idx = [1:3 5 4:6];
0104 mpc.gen = mpc.gen(idx, :);
0105 mpc.gencost = mpc.gencost(idx, :);
0106 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0107 mpc.reserves.cost = mpc.reserves.cost(idx);
0108 mpc.reserves.qty = mpc.reserves.qty(idx);
0109 mpc.gen(4, GEN_STATUS) = 0;
0110 mpc.reserves.zones(:, 6) = 0;
0111 mpc.reserves.cost(6) = [];
0112 mpc.reserves.qty(6) = [];
0113 r = runopf_w_res(mpc, mpopt);
0114 t_is(r.reserves.R, [25; 15; 0; 0; 0; 0; 20], 4, [t 'R']);
0115 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 0; 5.5], 6, [t 'prc']);
0116 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0117 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0118 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0119 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0120 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0121 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0122
0123 t = 'no qty (Rmax) : ';
0124 mpc = loadcase(casefile);
0125 mpc.reserves = rmfield(mpc.reserves, 'qty');
0126 r = runopf_w_res(mpc, mpopt);
0127 t_is(r.reserves.R, [39.3826; 0.6174; 0; 0; 19.3818; 0.6182], 4, [t 'R']);
0128 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 5, [t 'prc']);
0129 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 5, [t 'mu.l']);
0130 t_is(r.reserves.mu.u, [0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0131 t_is(r.reserves.mu.Pmax, [0.1; 0; 0; 0; 0.5; 0], 5, [t 'mu.Pmax']);
0132 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0133 t_is(r.reserves.totalcost, 176.3708, 4, [t 'totalcost']);
0134
0135 t = 'RAMP_10, no qty (Rmax) : ';
0136 mpc = loadcase(casefile);
0137 mpc.reserves = rmfield(mpc.reserves, 'qty');
0138 mpc.gen(1, RAMP_10) = 25;
0139 r = runopf_w_res(mpc, mpopt);
0140 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0141 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0142 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0143 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0144 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0145 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0146 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0147
0148 t_end;