Home > matpower7.1 > lib > t > t_auction_minopf.m

t_auction_minopf

PURPOSE ^

T_AUCTION_MINOPF Tests for code in auction.m, using MINOPF solver.

SYNOPSIS ^

function t_auction_minopf(quiet)

DESCRIPTION ^

T_AUCTION_MINOPF  Tests for code in auction.m, using MINOPF solver.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_auction_minopf(quiet)
0002 %T_AUCTION_MINOPF  Tests for code in auction.m, using MINOPF solver.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2004-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MATPOWER.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://matpower.org for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 n_tests = 183;
0017 
0018 t_begin(n_tests, quiet);
0019 
0020 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0021     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0022 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0023     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0024     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0025 
0026 if ~have_feature('smartmarket')
0027     t_skip(n_tests, 'smartmarket code not available');
0028 elseif ~have_feature('minopf')
0029     t_skip(n_tests, 't_auction_minopf requires MINOPF');
0030 else
0031     mpopt = mpoption('opf.ac.solver', 'MINOPF', 'out.lim.all', 1, 'out.branch', 0, 'out.sys_sum', 0, 'out.all', 0, 'verbose', 0);
0032     q = [
0033         12 24 24; 
0034         12 24 24; 
0035         12 24 24; 
0036         12 24 24; 
0037         12 24 24; 
0038         12 24 24; 
0039         10 10 10;
0040         10 10 10;
0041         10 10 10;
0042     ];
0043 
0044     %%-----  one offer block marginal @ $50  -----
0045     p = [
0046         20 50 60;
0047         20 40 70;
0048         20 42 80;
0049         20 44 90;
0050         20 46 75;
0051         20 48 60;
0052         100 70 60;
0053         100 50 20;
0054         100 60 50;
0055     ];
0056 
0057     t = 'one marginal offer @ $50, auction_type = 5';
0058     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0059         runmkt('t_auction_case', q, p, 1150, 100, [], [], mpopt);
0060     cq5 = cq;
0061     cp5 = cp;
0062     i2e = bus(:, BUS_I);
0063     e2i = sparse(max(i2e), 1);
0064     e2i(i2e) = (1:size(bus, 1))';
0065     G = find( ~isload(gen) );   %% real generators
0066     L = find(  isload(gen) );   %% dispatchable loads
0067     Gbus = e2i(gen(G,GEN_BUS));
0068     Lbus = e2i(gen(L,GEN_BUS));
0069     Qfudge =  zeros(size(p));
0070     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0071 
0072     t_is( cq(G(1),2:3), [23.32 0], 2, t );
0073     t_is( cp(G(1),:), 50, 4, t );
0074     t_is( cq(L(2),1:2), [10 0], 2, t );
0075     t_is( cp(L(2),:), 54.0312, 4, t );
0076     t_is( cp(G,1), bus(Gbus, LAM_P), 8, [t ' : gen prices'] );
0077     t_is( cp(L,1), bus(Lbus, LAM_P) + Qfudge(L,1), 8, [t ' : load prices'] );
0078 
0079     lao_X = p(G(1),2)/bus(Gbus(1), LAM_P);
0080     fro_X = p(G(6),3)/bus(Gbus(6), LAM_P);
0081     lab_X = p(L(3),2)/(bus(Lbus(3), LAM_P) + Qfudge(L(3),1));
0082     frb_X = p(L(2),2)/(bus(Lbus(2), LAM_P) + Qfudge(L(2),1));
0083 
0084     t_is( lao_X, 1, 4, 'lao_X');
0085     t_is( fro_X, 1.1324, 4, 'fro_X');
0086     t_is( lab_X, 1.0787, 4, 'lab_X');
0087     t_is( frb_X, 0.9254, 4, 'frb_X');
0088 
0089     t = 'one marginal offer @ $50, auction_type = 1';
0090     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0091         runmkt('t_auction_case', q, p, 1110, 100, [], [], mpopt);
0092     cp1 = cp;
0093     t_is( cq, cq5, 8, [t ' : quantities'] );
0094     t_is( cp, cp5, 8, [t ' : prices'] );
0095 
0096     t = 'one marginal offer @ $50, auction_type = 2';
0097     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0098         runmkt('t_auction_case', q, p, 1120, 100, [], [], mpopt);
0099     cp2 = cp;
0100     t_is( cq, cq5, 8, [t ' : quantities'] );
0101     t_is( cp(G,:), cp5(G,:)*fro_X, 8, [t ' : gen prices'] );
0102     t_is( cp(L(1:2),:), cp5(L(1:2),:)*fro_X, 8, [t ' : load 1,2 prices'] );
0103     t_is( cp(L(3),:), 60, 5, [t ' : load 3 price'] );   %% clipped by accepted bid
0104 
0105     t = 'one marginal offer @ $50, auction_type = 3';
0106     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0107         runmkt('t_auction_case', q, p, 1130, 100, [], [], mpopt);
0108     cp3 = cp;
0109     t_is( cq, cq5, 8, [t ' : quantities'] );
0110     t_is( cp, cp5*lab_X, 8, [t ' : prices'] );
0111 
0112     t = 'one marginal offer @ $50, auction_type = 4';
0113     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0114         runmkt('t_auction_case', q, p, 1140, 100, [], [], mpopt);
0115     t_is( cq, cq5, 8, [t ' : quantities'] );
0116     t_is( cp(G(1),:), p(G(1),2), 8, [t ' : gen 1 price'] );
0117     t_is( cp(G(2:6),:), cp5(G(2:6),:)*frb_X, 8, [t ' : gen 2-6 prices'] );
0118     t_is( cp(L,:), cp5(L,:)*frb_X, 8, [t ' : load prices'] );
0119 
0120     t = 'one marginal offer @ $50, auction_type = 6';
0121     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0122         runmkt('t_auction_case', q, p, 1160, 100, [], [], mpopt);
0123     t_is( cq, cq5, 8, [t ' : quantities'] );
0124     t_is( cp, cp3, 8, [t ' : prices'] );
0125     p2 = p;
0126     p2(L,:) = [ 100 100 100;
0127                 100   0   0;
0128                 100 100   0 ];
0129     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0130         runmkt('t_auction_case', q, p2, 1160, 100, [], [], mpopt);
0131     t_is( cq, cq5, 5, [t ' : quantities'] );
0132     t_is( cp(G,:), cp5(G,:)*fro_X, 4, [t ' : gen prices'] );
0133     t_is( cp(L,:), cp5(L,:)*fro_X, 4, [t ' : load prices'] ); %% load 3 not clipped as in FRO
0134 
0135     t = 'one marginal offer @ $50, auction_type = 7';
0136     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0137         runmkt('t_auction_case', q, p, 1170, 100, [], [], mpopt);
0138     t_is( cq, cq5, 8, [t ' : quantities'] );
0139     t_is( cp, cp5 * (lao_X+lab_X)/2, 8, [t ' : prices'] );
0140     t_is( cp, (cp1 + cp3) / 2, 8, [t ' : prices'] );
0141 
0142     t = 'one marginal offer @ $50, auction_type = 8';
0143     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0144         runmkt('t_auction_case', q, p, 1180, 100, [], [], mpopt);
0145     t_is( cq, cq5, 8, [t ' : quantities'] );
0146     t_is( cp(G,:), cp1(G,:), 8, [t ' : gen prices'] );
0147     t_is( cp(L,:), cp3(L,:), 8, [t ' : load prices'] );
0148 
0149     t = 'one marginal offer @ $50, auction_type = 0';
0150     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0151         runmkt('t_auction_case', q, p, 1100, 100, [], [], mpopt);
0152     t_is( cq, cq5, 8, [t ' : quantities'] );
0153     t_is( cp, p, 8, [t ' : prices'] );
0154 
0155 
0156     %%-----  one bid block marginal @ $55  -----
0157     p(L(2),2) = 55;
0158     t = 'one marginal bid @ $55, auction_type = 5';
0159     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0160         runmkt('t_auction_case', q, p, 1150, 100, [], [], mpopt);
0161     cq5 = cq;
0162     cp5 = cp;
0163     Qfudge =  zeros(size(p));
0164     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0165 
0166     t_is( cq(G(1),2:3), [24 0], 2, t );
0167     t_is( cp(G(1),:), 50.016, 3, t );
0168     t_is( cq(L(2),1:2), [10 0.63], 2, t );
0169     t_is( cp(L(2),:), 55, 4, t );
0170     t_is( cp(G,1), bus(Gbus, LAM_P), 8, [t ' : gen prices'] );
0171     t_is( cp(L,1), bus(Lbus, LAM_P) + Qfudge(L,1), 8, [t ' : load prices'] );
0172 
0173     lao_X = p(G(1),2)/bus(Gbus(1), LAM_P);
0174     fro_X = p(G(6),3)/bus(Gbus(6), LAM_P);
0175     lab_X = p(L(2),2)/(bus(Lbus(2), LAM_P) + Qfudge(L(2),1));
0176     frb_X = p(L(3),3)/(bus(Lbus(3), LAM_P) + Qfudge(L(3),1));
0177 
0178     t_is( lao_X, 0.9997, 4, 'lao_X');
0179     t_is( fro_X, 1.1111, 4, 'fro_X');
0180     t_is( lab_X, 1, 4, 'lab_X');
0181     t_is( frb_X, 0.8960, 4, 'frb_X');
0182 
0183     t = 'one marginal bid @ $55, auction_type = 1';
0184     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0185         runmkt('t_auction_case', q, p, 1110, 100, [], [], mpopt);
0186     cp1 = cp;
0187     t_is( cq, cq5, 8, [t ' : quantities'] );
0188     t_is( cp, cp5*lao_X, 8, [t ' : prices'] );
0189 
0190     t = 'one marginal bid @ $55, auction_type = 2';
0191     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0192         runmkt('t_auction_case', q, p, 1120, 100, [], [], mpopt);
0193     cp2 = cp;
0194     t_is( cq, cq5, 8, [t ' : quantities'] );
0195     t_is( cp(G,:), cp5(G,:)*fro_X, 8, [t ' : gen prices'] );
0196     t_is( cp(L(1),:), cp5(L(1),:)*fro_X, 8, [t ' : load 1 price'] );
0197     t_is( cp(L(2),:), 55, 5, [t ' : load 2 price'] );
0198     t_is( cp(L(3),:), 60, 5, [t ' : load 3 price'] );
0199 
0200     t = 'one marginal bid @ $55, auction_type = 3';
0201     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0202         runmkt('t_auction_case', q, p, 1130, 100, [], [], mpopt);
0203     cp3 = cp;
0204     t_is( cq, cq5, 8, [t ' : quantities'] );
0205     t_is( cp, cp5, 8, [t ' : prices'] );
0206 
0207     t = 'one marginal bid @ $55, auction_type = 4';
0208     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0209         runmkt('t_auction_case', q, p, 1140, 100, [], [], mpopt);
0210     cp4 = cp;
0211     t_is( cq, cq5, 8, [t ' : quantities'] );
0212     t_is( cp(G(1),:), 50, 5, [t ' : gen 1 price'] );
0213     t_is( cp(G(2:6),:), cp5(G(2:6),:)*frb_X, 8, [t ' : gen 2-6 prices'] );
0214     t_is( cp(L,:), cp5(L,:)*frb_X, 8, [t ' : load prices'] );
0215 
0216     t = 'one marginal bid @ $55, auction_type = 6';
0217     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0218         runmkt('t_auction_case', q, p, 1160, 100, [], [], mpopt);
0219     t_is( cq, cq5, 8, [t ' : quantities'] );
0220     t_is( cp, cp1, 8, [t ' : prices'] );
0221 
0222     p2 = p;
0223     p2(G,:) = [ 0 0 100;
0224                 0 0 100;
0225                 0 0 100;
0226                 0 0 100;
0227                 0 0 100;
0228                 0 0 100 ];
0229     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0230         runmkt('t_auction_case', q, p2, 1160, 100, [], [], mpopt);
0231     t_is( cq, cq5, 8, [t ' : quantities'] );
0232     t_is( cp(G,:), cp5(G,:)*frb_X, 4, [t ' : gen prices'] );  %% gen 1, not clipped this time
0233     t_is( cp(L,:), cp4(L,:), 4, [t ' : load prices'] );
0234 
0235     t = 'one marginal bid @ $55, auction_type = 7';
0236     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0237         runmkt('t_auction_case', q, p, 1170, 100, [], [], mpopt);
0238     t_is( cq, cq5, 8, [t ' : quantities'] );
0239     t_is( cp, cp5 * (lao_X+lab_X)/2, 8, [t ' : prices'] );
0240     t_is( cp, (cp1 + cp3) / 2, 8, [t ' : prices'] );
0241 
0242     t = 'one marginal bid @ $55, auction_type = 8';
0243     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0244         runmkt('t_auction_case', q, p, 1180, 100, [], [], mpopt);
0245     t_is( cq, cq5, 8, [t ' : quantities'] );
0246     t_is( cp(G,:), cp1(G,:), 8, [t ' : gen prices'] );
0247     t_is( cp(L,:), cp3(L,:), 8, [t ' : load prices'] );
0248 
0249     t = 'one marginal bid @ $55, auction_type = 0';
0250     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0251         runmkt('t_auction_case', q, p, 1100, 100, [], [], mpopt);
0252     t_is( cq, cq5, 8, [t ' : quantities'] );
0253     t_is( cp, p, 8, [t ' : prices'] );
0254 
0255 
0256     %%-----  one bid block marginal @ $54.50 and one offer block marginal @ $50  -----
0257     p(L(2),2) = 54.5;
0258     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 5';
0259     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0260         runmkt('t_auction_case', q, p, 1150, 100, [], [], mpopt);
0261     cq5 = cq;
0262     cp5 = cp;
0263     Qfudge =  zeros(size(p));
0264     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0265 
0266     t_is( cq(G(1),2:3), [23.74 0], 2, t );
0267     t_is( cp(G(1),:), 50, 4, t );
0268     t_is( cq(L(2),1:2), [10 0.39], 2, t );
0269     t_is( cp(L(2),:), 54.5, 4, t );
0270     t_is( cp(G,1), bus(Gbus, LAM_P), 8, [t ' : gen prices'] );
0271     t_is( cp(L,1), bus(Lbus, LAM_P) + Qfudge(L,1), 8, [t ' : load prices'] );
0272 
0273     lao_X = p(G(1),2)/bus(Gbus(1), LAM_P);
0274     fro_X = p(G(6),3)/bus(Gbus(6), LAM_P);
0275     lab_X = p(L(2),2)/(bus(Lbus(2), LAM_P) + Qfudge(L(2),1));
0276     frb_X = p(L(3),3)/(bus(Lbus(3), LAM_P) + Qfudge(L(3),1));
0277 
0278     t_is( lao_X, 1, 4, 'lao_X');
0279     t_is( fro_X, 1.1221, 4, 'fro_X');
0280     t_is( lab_X, 1, 4, 'lab_X');
0281     t_is( frb_X, 0.8976, 4, 'frb_X');
0282 
0283     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 1';
0284     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0285         runmkt('t_auction_case', q, p, 1110, 100, [], [], mpopt);
0286     cp1 = cp;
0287     t_is( cq, cq5, 8, [t ' : quantities'] );
0288     t_is( cp, cp5, 4, [t ' : prices'] );
0289 
0290     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 2';
0291     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0292         runmkt('t_auction_case', q, p, 1120, 100, [], [], mpopt);
0293     cp2 = cp;
0294     t_is( cq, cq5, 8, [t ' : quantities'] );
0295     t_is( cp(G,:), cp5(G,:)*fro_X, 5, [t ' : gen prices'] );
0296     t_is( cp(L(1),:), cp5(L(1),:)*fro_X, 5, [t ' : load 1 price'] );
0297     t_is( cp(L(2),:), 54.5, 5, [t ' : load 2 price'] );
0298     t_is( cp(L(3),:), 60, 5, [t ' : load 3 price'] );
0299 
0300     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 3';
0301     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0302         runmkt('t_auction_case', q, p, 1130, 100, [], [], mpopt);
0303     cp3 = cp;
0304     t_is( cq, cq5, 8, [t ' : quantities'] );
0305     t_is( cp, cp5, 8, [t ' : prices'] );
0306 
0307     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 4';
0308     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0309         runmkt('t_auction_case', q, p, 1140, 100, [], [], mpopt);
0310     cp4 = cp;
0311     t_is( cq, cq5, 8, [t ' : quantities'] );
0312     t_is( cp(G(1),:), 50, 5, [t ' : gen 1 price'] );
0313     t_is( cp(G(2:5),:), cp5(G(2:5),:)*frb_X, 8, [t ' : gen 2-5 prices'] );
0314     t_is( cp(G(6),:), 48, 5, [t ' : gen 6 price'] );
0315     t_is( cp(L,:), cp5(L,:)*frb_X, 8, [t ' : load prices'] );
0316 
0317     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 6';
0318     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0319         runmkt('t_auction_case', q, p, 1160, 100, [], [], mpopt);
0320     t_is( cq, cq5, 8, [t ' : quantities'] );
0321     t_is( cp, cp5, 4, [t ' : prices'] );
0322 
0323     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 7';
0324     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0325         runmkt('t_auction_case', q, p, 1170, 100, [], [], mpopt);
0326     t_is( cq, cq5, 8, [t ' : quantities'] );
0327     t_is( cp, cp5, 4, [t ' : prices'] );
0328 
0329     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 8';
0330     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0331         runmkt('t_auction_case', q, p, 1180, 100, [], [], mpopt);
0332     t_is( cq, cq5, 8, [t ' : quantities'] );
0333     t_is( cp, cp5, 4, [t ' : prices'] );
0334 
0335     t = 'marginal offer @ $50, bid @ $54.50, auction_type = 0';
0336     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0337         runmkt('t_auction_case', q, p, 1100, 100, [], [], mpopt);
0338     t_is( cq, cq5, 8, [t ' : quantities'] );
0339     t_is( cp, p, 8, [t ' : prices'] );
0340 
0341 
0342     %%-----  gen 1 at Pmin, load 3 block 2 marginal @ $60  -----
0343     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 5';
0344     p(L(2),2) = 50;     %% undo previous change
0345     p2 = p;
0346     p2(G(1),2:3) = [65 65];
0347     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0348         runmkt('t_auction_case', q, p2, 1150, 100, [], [], mpopt);
0349     Qfudge =  zeros(size(p));
0350     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0351 
0352     t_is( cp(G(1),:), 65, 4, [t ' : gen 1 price'] );
0353     t_is( cp(G(2),:), 54.2976, 4, [t ' : gen 2 price'] );
0354     cq5 = cq;
0355     cp5 = cp;
0356     cp_lam = cp5;
0357     cp_lam(1,:) = bus(Gbus(1), LAM_P);  %% unclipped
0358 
0359     lao_X = p2(G(6),2)/bus(Gbus(6), LAM_P);
0360     fro_X = p2(G(6),3)/bus(Gbus(6), LAM_P);
0361     lab_X = p2(L(3),2)/(bus(Lbus(3), LAM_P) + Qfudge(L(3),1));
0362     frb_X = p2(L(2),2)/(bus(Lbus(2), LAM_P) + Qfudge(L(2),1));
0363 
0364     t_is( lao_X, 0.8389, 4, 'lao_X');
0365     t_is( fro_X, 1.0487, 4, 'fro_X');
0366     t_is( lab_X, 1, 4, 'lab_X');
0367     t_is( frb_X, 0.8569, 4, 'frb_X');
0368 
0369     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 1';
0370     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0371         runmkt('t_auction_case', q, p2, 1110, 100, [], [], mpopt);
0372     cp1 = cp;
0373     t_is( cq, cq5, 8, [t ' : quantities'] );
0374     t_is( cp(G(1),:), 65, 8, [t ' : gen 1 price'] );
0375     t_is( cp(G(2:6),:), cp_lam(G(2:6),:)*lao_X, 8, [t ' : gen 2-6 prices'] );
0376     t_is( cp(L,:), cp_lam(L,:)*lao_X, 8, [t ' : load prices'] );
0377 
0378     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 2';
0379     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0380         runmkt('t_auction_case', q, p2, 1120, 100, [], [], mpopt);
0381     t_is( cq, cq5, 8, [t ' : quantities'] );
0382     t_is( cp(G(1),:), 65, 8, [t ' : gen 1 price'] );
0383     t_is( cp(G(2:6),:), cp_lam(G(2:6),:)*fro_X, 8, [t ' : gen 2-6 prices'] );
0384     t_is( cp(L(1:2),:), cp_lam(L(1:2),:)*fro_X, 8, [t ' : load 1-2 prices'] );
0385     t_is( cp(L(3),:), 60, 8, [t ' : load 3 price'] );
0386 
0387     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 3';
0388     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0389         runmkt('t_auction_case', q, p2, 1130, 100, [], [], mpopt);
0390     cp3 = cp;
0391     t_is( cq, cq5, 8, [t ' : quantities'] );
0392     t_is( cp(G(1),:), 65, 8, [t ' : gen 1 price'] );
0393     t_is( cp(G(2:6),:), cp_lam(G(2:6),:), 8, [t ' : gen 2-6 prices'] );
0394     t_is( cp(L,:), cp_lam(L,:), 8, [t ' : load prices'] );
0395 
0396     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 4';
0397     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0398         runmkt('t_auction_case', q, p2, 1140, 100, [], [], mpopt);
0399     cp4 = cp;
0400     t_is( cq, cq5, 8, [t ' : quantities'] );
0401     t_is( cp(G(1),:), 65, 5, [t ' : gen 1 price'] );
0402     t_is( cp(G(2:6),:), cp5(G(2:6),:)*frb_X, 8, [t ' : gen 2-6 prices'] );
0403     t_is( cp(L,:), cp5(L,:)*frb_X, 8, [t ' : load prices'] );
0404 
0405     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 6';
0406     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0407         runmkt('t_auction_case', q, p2, 1160, 100, [], [], mpopt);
0408     t_is( cq, cq5, 8, [t ' : quantities'] );
0409     t_is( cp, cp4, 8, [t ' : prices'] );
0410 
0411     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 7';
0412     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0413         runmkt('t_auction_case', q, p2, 1170, 100, [], [], mpopt);
0414     t_is( cq, cq5, 8, [t ' : quantities'] );
0415     t_is( cp(G(1),:), 65, 4, [t ' : gen 1 price'] );
0416     t_is( cp(G(2:6),:), cp_lam(G(2:6),:) * (lao_X+lab_X)/2, 8, [t ' : gen 2-6 prices'] );
0417     t_is( cp(L,:), cp_lam(L,:) * (lao_X+lab_X)/2, 8, [t ' : load prices'] );
0418     t_is( cp, (cp1 + cp3) / 2, 8, [t ' : prices'] );
0419 
0420     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 8';
0421     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0422         runmkt('t_auction_case', q, p2, 1180, 100, [], [], mpopt);
0423     t_is( cq, cq5, 8, [t ' : quantities'] );
0424     t_is( cp(G,:), cp1(G,:), 8, [t ' : prices'] );
0425     t_is( cp(L,:), cp3(L,:), 8, [t ' : prices'] );
0426 
0427     t = 'gen 1 @ Pmin, marginal bid @ $60, auction_type = 0';
0428     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0429         runmkt('t_auction_case', q, p2, 1100, 100, [], [], mpopt);
0430     t_is( cq, cq5, 8, [t ' : quantities'] );
0431     t_is( cp, p2, 8, [t ' : prices'] );
0432 
0433 
0434     %%-----  gen 1 at Pmin, gen 6 block 3 marginal @ $60  -----
0435     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 5';
0436     p2(L,:) = [ 100 100 100;
0437                 100   0   0;
0438                 100 100   0 ];
0439     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0440         runmkt('t_auction_case', q, p2, 1150, 100, [], [], mpopt);
0441     Qfudge =  zeros(size(p));
0442     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0443 
0444     t_is( cp(G(1),:), 65, 4, [t ' : gen 1 price'] );
0445     t_is( cp(G(2),:), 57.1616, 4, [t ' : gen 2 price'] );
0446     cq5 = cq;
0447     cp5 = cp;
0448     cp_lam = cp5;
0449     cp_lam(1,:) = bus(Gbus(1), LAM_P);  %% unclipped
0450 
0451     lao_X = p2(G(6),3)/bus(Gbus(6), LAM_P);
0452     fro_X = p2(G(1),3)/bus(Gbus(1), LAM_P);
0453     lab_X = p2(L(3),2)/(bus(Lbus(3), LAM_P) + Qfudge(L(3),1));
0454     frb_X = p2(L(2),2)/(bus(Lbus(2), LAM_P) + Qfudge(L(2),1));
0455 
0456     t_is( lao_X, 1, 4, 'lao_X');
0457     t_is( fro_X, 1.1425, 4, 'fro_X');
0458     t_is( lab_X, 1.5813, 4, 'lab_X');
0459     t_is( frb_X, 0, 4, 'frb_X');
0460 
0461     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 1';
0462     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0463         runmkt('t_auction_case', q, p2, 1110, 100, [], [], mpopt);
0464     cp1 = cp;
0465     t_is( cq, cq5, 8, [t ' : quantities'] );
0466     t_is( cp, cp5, 8, [t ' : prices'] );
0467 
0468     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 2';
0469     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0470         runmkt('t_auction_case', q, p2, 1120, 100, [], [], mpopt);
0471     t_is( cq, cq5, 8, [t ' : quantities'] );
0472     t_is( cp, cp_lam*fro_X, 8, [t ' : prices'] );
0473 
0474     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 3';
0475     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0476         runmkt('t_auction_case', q, p2, 1130, 100, [], [], mpopt);
0477     cp3 = cp;
0478     t_is( cq, cq5, 8, [t ' : quantities'] );
0479     t_is( cp, cp_lam*lab_X, 8, [t ' : prices'] );
0480 
0481     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 4';
0482     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0483         runmkt('t_auction_case', q, p2, 1140, 100, [], [], mpopt);
0484     t_is( cq, cq5, 8, [t ' : quantities'] );
0485     t_is( cp(G,1), [65;40;42;44;46;60], 4, [t ' : gen prices'] );
0486     t_is( cp(L,:), cp_lam(L,:)*frb_X, 8, [t ' : prices'] );
0487 
0488     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 6';
0489     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0490         runmkt('t_auction_case', q, p2, 1160, 100, [], [], mpopt);
0491     t_is( cq, cq5, 8, [t ' : quantities'] );
0492     t_is( cp, cp_lam*fro_X, 8, [t ' : prices'] );
0493 
0494     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 7';
0495     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0496         runmkt('t_auction_case', q, p2, 1170, 100, [], [], mpopt);
0497     t_is( cq, cq5, 8, [t ' : quantities'] );
0498     t_is( cp, cp_lam * (lao_X+lab_X)/2, 8, [t ' : prices'] );
0499     t_is( cp, (cp_lam + cp3) / 2, 8, [t ' : prices'] );
0500 
0501     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 8';
0502     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0503         runmkt('t_auction_case', q, p2, 1180, 100, [], [], mpopt);
0504     t_is( cq, cq5, 8, [t ' : quantities'] );
0505     t_is( cp(G,:), cp5(G,:), 8, [t ' : prices'] );
0506     t_is( cp(L,:), cp3(L,:), 8, [t ' : prices'] );
0507 
0508     t = 'gen 1 @ Pmin, marginal offer @ $60, auction_type = 0';
0509     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0510         runmkt('t_auction_case', q, p2, 1100, 100, [], [], mpopt);
0511     t_is( cq, cq5, 8, [t ' : quantities'] );
0512     t_is( cp, p2, 8, [t ' : prices'] );
0513 
0514 
0515     %%-----  gen 2 decommitted, one offer block marginal @ $60  -----
0516     p(G(2),:) = p(G(2),:) + 100;
0517 
0518     t = 'price of decommited gen, auction_type = 5';
0519     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0520         runmkt('t_auction_case', q, p, 1150, 200, [], [], mpopt);
0521     cp5 = cp;
0522     Qfudge =  zeros(size(p));
0523     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0524     t_is(sum(cq(2,:)), 0, 8, t);
0525     t_is(cp(2,1), 59.194, 3, t);
0526 
0527 %     Xo = p(1:6, :) ./ (diag(bus(Gbus, LAM_P)) * ones(size(p(G,:))));
0528 %     ao = (cq(1:6, :) ~= 0);
0529 %     ro = (cq(1:6, :) == 0);
0530 %     Xb = p(7:9, :) ./ (diag(bus(Lbus, LAM_P) + gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:))));
0531 %     ab = (cq(7:9, :) ~= 0);
0532 %     rb = (cq(7:9, :) == 0);
0533 %     aXo = ao .* Xo
0534 %     rXo = ro .* Xo
0535 %     aXb = ab .* Xb
0536 %     rXb = rb .* Xb
0537 
0538     lao_X = p(G(6),3)/bus(Gbus(6), LAM_P);
0539     fro_X = p(G(1),3)/bus(Gbus(1), LAM_P);
0540     lab_X = p(L(1),2)/(bus(Lbus(1), LAM_P) + Qfudge(L(1),1));
0541     frb_X = p(L(1),3)/(bus(Lbus(1), LAM_P) + Qfudge(L(1),1));
0542 
0543     t_is( lao_X, 1, 4, 'lao_X');
0544     t_is( fro_X, 1.0212, 4, 'fro_X');
0545     t_is( lab_X, 1.1649, 4, 'lab_X');
0546     t_is( frb_X, 0.9985, 4, 'frb_X');
0547 
0548     t = 'price of decommited gen, auction_type = 1';
0549     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0550         runmkt('t_auction_case', q, p, 1110, 200, [], [], mpopt);
0551     t_is(cp(2,1), 59.194, 3, t);
0552 
0553     t = 'price of decommited gen, auction_type = 2';
0554     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0555         runmkt('t_auction_case', q, p, 1120, 200, [], [], mpopt);
0556     t_is(cp(2,1), cp5(2,1)*fro_X, 3, t);
0557 
0558     t = 'price of decommited gen, auction_type = 3';
0559     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0560         runmkt('t_auction_case', q, p, 1130, 200, [], [], mpopt);
0561     t_is(cp(2,1), cp5(2,1)*lab_X, 3, t);
0562 
0563     t = 'price of decommited gen, auction_type = 4';
0564     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0565         runmkt('t_auction_case', q, p, 1140, 200, [], [], mpopt);
0566     t_is(cp(2,1), cp5(2,1)*frb_X, 3, t);
0567 
0568     t = 'price of decommited gen, auction_type = 6';
0569     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0570         runmkt('t_auction_case', q, p, 1160, 200, [], [], mpopt);
0571     t_is(cp(2,1), cp5(2,1)*fro_X, 3, t);
0572 
0573     t = 'price of decommited gen, auction_type = 7';
0574     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0575         runmkt('t_auction_case', q, p, 1170, 200, [], [], mpopt);
0576     t_is(cp(2,1), cp5(2,1)*(lao_X+lab_X)/2, 3, t);
0577 
0578     t = 'price of decommited gen, auction_type = 0';
0579     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0580         runmkt('t_auction_case', q, p, 1100, 200, [], [], mpopt);
0581     t_is(cp(2,1), 120, 3, t);
0582 
0583     t = 'single block, marginal offer @ $50, auction_type = 5';
0584     q = [
0585         60; 
0586         36; 
0587         36; 
0588         36; 
0589         36; 
0590         36; 
0591         30;
0592         10;
0593         20;
0594     ];
0595 
0596     p = [
0597         50;
0598         40;
0599         42;
0600         44;
0601         46;
0602         48;
0603         100;
0604         100;
0605         100;
0606     ];
0607 
0608     [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
0609         runmkt('t_auction_case', q, p, 1150, 100, [], [], mpopt);
0610     t_is( cq(G(1)), 35.32, 2, t );
0611     t_is( cq(G(2:6)), q(G(2:6)), 8, [t ' : gen qtys'] ); 
0612     t_is( cp(G(1)), 50, 4, t );
0613     t_is( cq(L), q(L), 8, [t ' : load qtys'] );
0614     t_is( cp(L(2),:), 54.03, 2, t );
0615     t_is( cp(G), bus(Gbus, LAM_P), 8, [t ' : gen prices'] );
0616     Qfudge =  zeros(size(p));
0617     Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));
0618     t_is( cp(L), bus(Lbus, LAM_P) + Qfudge(L,1), 8, [t ' : load prices'] );
0619 end
0620 
0621 t_end;

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005