0001 function t_runmarket(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if nargin < 1
0015 quiet = 0;
0016 end
0017
0018 n_tests = 20;
0019
0020 t_begin(n_tests, quiet);
0021
0022 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0023 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0024 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0025 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0026 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0027
0028 if ~have_fcn('smartmarket')
0029 t_skip(n_tests, 'smartmarket code not available');
0030 else
0031 mpc = loadcase('t_auction_case');
0032
0033 mpopt = mpoption('opf.ac.solver', 'MIPS', 'out.lim.all', 1, 'out.branch', 0, 'out.sys_sum', 0, 'out.all', 0, 'verbose', 1);
0034
0035
0036 offers.P.qty = [
0037 12 24 24;
0038 12 24 24;
0039 12 24 24;
0040 12 24 24;
0041 12 24 24;
0042 12 24 24;
0043 ];
0044 offers.P.prc = [
0045 20 50 60;
0046 20 40 70;
0047 20 42 80;
0048 20 44 90;
0049 20 46 75;
0050 20 48 60;
0051 ];
0052 bids.P.qty = [
0053 10 10 10;
0054 10 10 10;
0055 10 10 10;
0056 ];
0057 bids.P.prc = [
0058 100 70 60;
0059
0060
0061 100 50 20;
0062 100 60 50;
0063 ];
0064
0065 offers.Q.qty = [ 60; 60; 60; 60; 60; 60; 0; 0; 0 ];
0066 offers.Q.prc = [ 0; 0; 0; 0; 0; 3; 0; 0; 0 ];
0067 bids.Q.qty = [ 15; 15; 15; 15; 15; 15; 15; 12; 7.5 ];
0068
0069 bids.Q.prc = [ 0; 0; 0; 0; 0; 0; 0; 20; 0 ];
0070
0071 t = 'marginal Q offer, marginal PQ bid, auction_type = 5';
0072 mkt = struct( 'auction_type', 5, ...
0073 't' , [], ...
0074 'u0', [], ...
0075 'lim', [] );
0076 [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0077 co5 = co;
0078 cb5 = cb;
0079
0080
0081
0082
0083
0084
0085 i2e = r.bus(:, BUS_I);
0086 e2i = sparse(max(i2e), 1);
0087 e2i(i2e) = (1:size(r.bus, 1))';
0088 G = find( ~isload(r.gen) );
0089 L = find( isload(r.gen) );
0090 Gbus = e2i(r.gen(G,GEN_BUS));
0091 Lbus = e2i(r.gen(L,GEN_BUS));
0092
0093 t_is( co.P.qty, ones(6, 1) * [12 24 0], 2, [t ' : gen P quantities'] );
0094 t_is( co.P.prc(1,:), 50.1578*ones(1,3), 3, [t ' : gen 1 P prices'] );
0095 t_is( cb.P.qty, [10 10 10; 10 0.196 0; 10 10 0], 2, [t ' : load P quantities'] );
0096 t_is( cb.P.prc(2,:), 56.9853*ones(1,3), 4, [t ' : load 2 P price'] );
0097 t_is( co.P.prc(:,1), r.bus(Gbus, LAM_P), 8, [t ' : gen P prices'] );
0098 t_is( cb.P.prc(:,1), r.bus(Lbus, LAM_P), 8, [t ' : load P prices'] );
0099
0100 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'] );
0101 t_is( co.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q offer prices'] );
0102 t_is( cb.Q.qty, [0;0;0;0;0;0; 15; 4.0785; 5], 2, [t ' : Q bid quantities'] );
0103 t_is( cb.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q bid prices'] );
0104 t_is( co.Q.prc, r.bus([Gbus; Lbus], LAM_Q), 8, [t ' : Q offer prices'] );
0105 t_is( cb.Q.prc, co.Q.prc, 8, [t ' : Q bid prices'] );
0106
0107 t = 'marginal Q offer, marginal PQ bid, auction_type = 0';
0108 mkt.auction_type = 0;
0109 [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0110 t_is( co.P.qty, co5.P.qty, 8, [t ' : gen P quantities'] );
0111 t_is( cb.P.qty, cb5.P.qty, 8, [t ' : load P quantities'] );
0112 t_is( co.P.prc, offers.P.prc, 8, [t ' : gen P prices'] );
0113 t_is( cb.P.prc, bids.P.prc, 8, [t ' : load P prices'] );
0114
0115 t_is( co.Q.qty, co5.Q.qty, 8, [t ' : gen Q quantities'] );
0116 t_is( cb.Q.qty, cb5.Q.qty, 8, [t ' : load Q quantities'] );
0117 t_is( co.Q.prc, offers.Q.prc, 8, [t ' : gen Q prices'] );
0118 t_is( cb.Q.prc, bids.Q.prc, 8, [t ' : load Q prices'] );
0119 end
0120
0121 t_end;