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

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