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

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005