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

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005