0001 function t_runmarket(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 n_tests = 20;
0038
0039 t_begin(n_tests, quiet);
0040
0041 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0042 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0043 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0044 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0045 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0046
0047 if ~have_fcn('smartmarket')
0048 t_skip(n_tests, 'smartmarket code not available');
0049 else
0050 mpc = loadcase('t_auction_case');
0051
0052 mpopt = mpoption('OPF_ALG', 560, 'OUT_ALL_LIM', 1, 'OUT_BRANCH', 0, 'OUT_SYS_SUM', 0, 'OUT_ALL', 0, 'VERBOSE', 1);
0053
0054
0055 offers.P.qty = [
0056 12 24 24;
0057 12 24 24;
0058 12 24 24;
0059 12 24 24;
0060 12 24 24;
0061 12 24 24;
0062 ];
0063 offers.P.prc = [
0064 20 50 60;
0065 20 40 70;
0066 20 42 80;
0067 20 44 90;
0068 20 46 75;
0069 20 48 60;
0070 ];
0071 bids.P.qty = [
0072 10 10 10;
0073 10 10 10;
0074 10 10 10;
0075 ];
0076 bids.P.prc = [
0077 100 70 60;
0078
0079
0080 100 50 20;
0081 100 60 50;
0082 ];
0083
0084 offers.Q.qty = [ 60; 60; 60; 60; 60; 60; 0; 0; 0 ];
0085 offers.Q.prc = [ 0; 0; 0; 0; 0; 3; 0; 0; 0 ];
0086 bids.Q.qty = [ 15; 15; 15; 15; 15; 15; 15; 12; 7.5 ];
0087
0088 bids.Q.prc = [ 0; 0; 0; 0; 0; 0; 0; 20; 0 ];
0089
0090 t = 'marginal Q offer, marginal PQ bid, auction_type = 5';
0091 mkt = struct( 'auction_type', 5, ...
0092 't' , [], ...
0093 'u0', [], ...
0094 'lim', [] );
0095 [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0096 co5 = co;
0097 cb5 = cb;
0098
0099
0100
0101
0102
0103
0104 i2e = r.bus(:, BUS_I);
0105 e2i = sparse(max(i2e), 1);
0106 e2i(i2e) = (1:size(r.bus, 1))';
0107 G = find( ~isload(r.gen) );
0108 L = find( isload(r.gen) );
0109 Gbus = e2i(r.gen(G,GEN_BUS));
0110 Lbus = e2i(r.gen(L,GEN_BUS));
0111
0112 t_is( co.P.qty, ones(6, 1) * [12 24 0], 2, [t ' : gen P quantities'] );
0113 t_is( co.P.prc(1,:), 50.1578, 3, [t ' : gen 1 P prices'] );
0114 t_is( cb.P.qty, [10 10 10; 10 0.196 0; 10 10 0], 2, [t ' : load P quantities'] );
0115 t_is( cb.P.prc(2,:), 56.9853, 4, [t ' : load 2 P price'] );
0116 t_is( co.P.prc(:,1), r.bus(Gbus, LAM_P), 8, [t ' : gen P prices'] );
0117 t_is( cb.P.prc(:,1), r.bus(Lbus, LAM_P), 8, [t ' : load P prices'] );
0118
0119 t_is( co.Q.qty, [4.2722; 11.3723; 14.1472; 22.8939; 36.7886; 12.3375; 0; 0; 0], 2, [t ' : Q offer quantities'] );
0120 t_is( co.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q offer prices'] );
0121 t_is( cb.Q.qty, [0;0;0;0;0;0; 15; 4.0785; 5], 2, [t ' : Q bid quantities'] );
0122 t_is( cb.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q bid prices'] );
0123 t_is( co.Q.prc, r.bus([Gbus; Lbus], LAM_Q), 8, [t ' : Q offer prices'] );
0124 t_is( cb.Q.prc, co.Q.prc, 8, [t ' : Q bid prices'] );
0125
0126 t = 'marginal Q offer, marginal PQ bid, auction_type = 0';
0127 mkt.auction_type = 0;
0128 [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0129 t_is( co.P.qty, co5.P.qty, 8, [t ' : gen P quantities'] );
0130 t_is( cb.P.qty, cb5.P.qty, 8, [t ' : load P quantities'] );
0131 t_is( co.P.prc, offers.P.prc, 8, [t ' : gen P prices'] );
0132 t_is( cb.P.prc, bids.P.prc, 8, [t ' : load P prices'] );
0133
0134 t_is( co.Q.qty, co5.Q.qty, 8, [t ' : gen Q quantities'] );
0135 t_is( cb.Q.qty, cb5.Q.qty, 8, [t ' : load Q quantities'] );
0136 t_is( co.Q.prc, offers.Q.prc, 8, [t ' : gen Q prices'] );
0137 t_is( cb.Q.prc, bids.Q.prc, 8, [t ' : load Q prices'] );
0138 end
0139
0140 t_end;