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

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005