Home > matpower7.0 > lib > t > t_auction_mips.m

t_auction_mips

PURPOSE ^

T_AUCTION_MIPS Tests for code in auction.m, using MIPS solver.

SYNOPSIS ^

function t_auction_mips(quiet)

DESCRIPTION ^

T_AUCTION_MIPS  Tests for code in auction.m, using MIPS solver.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005