Home > matpower6.0 > t > t_runmarket.m

t_runmarket

PURPOSE ^

T_RUNMARKET Tests for code in RUNMKT, SMARTMKT AND AUCTION.

SYNOPSIS ^

function t_runmarket(quiet)

DESCRIPTION ^

T_RUNMARKET  Tests for code in RUNMKT, SMARTMKT AND AUCTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_runmarket(quiet)
0002 %T_RUNMARKET  Tests for code in RUNMKT, SMARTMKT AND AUCTION.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2005-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MATPOWER.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 n_tests = 20;
0017 
0018 t_begin(n_tests, quiet);
0019 
0020 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0021     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0022 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0023     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0024     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0025 
0026 if ~have_fcn('smartmarket')
0027     t_skip(n_tests, 'smartmarket code not available');
0028 else
0029     mpc = loadcase('t_auction_case');
0030     
0031     mpopt = mpoption('opf.ac.solver', 'MIPS', 'out.lim.all', 1, 'out.branch', 0, 'out.sys_sum', 0, 'out.all', 0, 'verbose', 1);
0032     % mpopt = mpoption('out.gen', 1, 'out.branch', 0, 'out.sys_sum', 0);
0033     
0034     offers.P.qty = [
0035         12 24 24; 
0036         12 24 24; 
0037         12 24 24; 
0038         12 24 24; 
0039         12 24 24; 
0040         12 24 24; 
0041     ];
0042     offers.P.prc = [
0043         20 50 60;
0044         20 40 70;
0045         20 42 80;
0046         20 44 90;
0047         20 46 75;
0048         20 48 60;
0049     ];
0050     bids.P.qty = [
0051         10 10 10;
0052         10 10 10;
0053         10 10 10;
0054     ];
0055     bids.P.prc = [
0056         100 70 60;
0057 %         100 64.3 20;
0058 %         100 30.64545 0;
0059         100 50 20;
0060         100 60 50;
0061     ];
0062     
0063     offers.Q.qty = [ 60; 60; 60; 60; 60; 60; 0; 0; 0 ];
0064     offers.Q.prc = [ 0; 0; 0; 0; 0; 3; 0; 0; 0 ];
0065     bids.Q.qty = [ 15; 15; 15; 15; 15; 15; 15; 12; 7.5 ];
0066 %     bids.Q.prc = [ 0; 0; 0; 0; 0; 0; 0; 83.9056; 0 ];
0067     bids.Q.prc = [ 0; 0; 0; 0; 0; 0; 0; 20; 0 ];
0068     
0069     t = 'marginal Q offer, marginal PQ bid, auction_type = 5';
0070     mkt = struct(   'auction_type', 5, ...
0071                     't' , [], ...
0072                     'u0', [], ...
0073                     'lim', []   );
0074     [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0075     co5 = co;
0076     cb5 = cb;
0077     
0078 %     [ co.P.qty co.P.prc ]
0079 %     [ cb.P.qty cb.P.prc ]
0080 %     [ co.Q.qty co.Q.prc ]
0081 %     [ cb.Q.qty cb.Q.prc ]
0082     
0083     i2e = r.bus(:, BUS_I);
0084     e2i = sparse(max(i2e), 1);
0085     e2i(i2e) = (1:size(r.bus, 1))';
0086     G = find( ~isload(r.gen) );   %% real generators
0087     L = find(  isload(r.gen) );   %% dispatchable loads
0088     Gbus = e2i(r.gen(G,GEN_BUS));
0089     Lbus = e2i(r.gen(L,GEN_BUS));
0090     
0091     t_is( co.P.qty, ones(6, 1) * [12 24 0], 2, [t ' : gen P quantities'] );
0092     t_is( co.P.prc(1,:), 50.1578*ones(1,3), 3, [t ' : gen 1 P prices'] );
0093     t_is( cb.P.qty, [10 10 10; 10 0.196 0; 10 10 0], 2, [t ' : load P quantities'] );
0094     t_is( cb.P.prc(2,:), 56.9853*ones(1,3), 4, [t ' : load 2 P price'] );
0095     t_is( co.P.prc(:,1), r.bus(Gbus, LAM_P), 8, [t ' : gen P prices'] );
0096     t_is( cb.P.prc(:,1), r.bus(Lbus, LAM_P), 8, [t ' : load P prices'] );
0097     
0098     t_is( co.Q.qty, [4.2722; 11.3723; 14.1472; 22.8939; 36.7886; 12.3375; 0; 0; 0], 2, [t ' : Q offer quantities'] );
0099     t_is( co.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q offer prices'] );
0100     t_is( cb.Q.qty, [0;0;0;0;0;0; 15; 4.0785; 5], 2, [t ' : Q bid quantities'] );
0101     t_is( cb.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q bid prices'] );
0102     t_is( co.Q.prc, r.bus([Gbus; Lbus], LAM_Q), 8, [t ' : Q offer prices'] );
0103     t_is( cb.Q.prc, co.Q.prc, 8, [t ' : Q bid prices'] );
0104     
0105     t = 'marginal Q offer, marginal PQ bid, auction_type = 0';
0106     mkt.auction_type = 0;
0107     [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0108     t_is( co.P.qty, co5.P.qty, 8, [t ' : gen P quantities'] );
0109     t_is( cb.P.qty, cb5.P.qty, 8, [t ' : load P quantities'] );
0110     t_is( co.P.prc, offers.P.prc, 8, [t ' : gen P prices'] );
0111     t_is( cb.P.prc, bids.P.prc, 8, [t ' : load P prices'] );
0112     
0113     t_is( co.Q.qty, co5.Q.qty, 8, [t ' : gen Q quantities'] );
0114     t_is( cb.Q.qty, cb5.Q.qty, 8, [t ' : load Q quantities'] );
0115     t_is( co.Q.prc, offers.Q.prc, 8, [t ' : gen Q prices'] );
0116     t_is( cb.Q.prc, bids.Q.prc, 8, [t ' : load Q prices'] );
0117 end
0118 
0119 t_end;

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005