Home > matpower6.0 > t > t_auction_tspopf_pdipm.m

t_auction_tspopf_pdipm

PURPOSE ^

T_AUCTION_TSPOPF_PDIPM Tests for code in auction.m, using PDIPMOPF solver.

SYNOPSIS ^

function t_auction_tspopf_pdipm(quiet)

DESCRIPTION ^

T_AUCTION_TSPOPF_PDIPM  Tests for code in auction.m, using PDIPMOPF solver.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005