Home > matpower4.0 > t > t_auction_mips.m

t_auction_mips

PURPOSE ^

T_AUCTION_MIPS Tests for code in auction.m, using MIPS solver.

SYNOPSIS ^

function t_auction_mips(quiet)

DESCRIPTION ^

T_AUCTION_MIPS  Tests for code in auction.m, using MIPS solver.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Mon 26-Jan-2015 14:56:45 by m2html © 2005