Home > matpower4.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 %   $Id: t_runmarket.m,v 1.12 2010/04/26 19:45:26 ray Exp $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2005-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 = 20;
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     mpc = loadcase('t_auction_case');
0051     
0052     mpopt = mpoption('OPF_ALG', 560, 'OUT_ALL_LIM', 1, 'OUT_BRANCH', 0, 'OUT_SYS_SUM', 0, 'OUT_ALL', 0, 'VERBOSE', 1);
0053     % mpopt = mpoption('OUT_GEN', 1, 'OUT_BRANCH', 0, 'OUT_SYS_SUM', 0);
0054     
0055     offers.P.qty = [
0056         12 24 24; 
0057         12 24 24; 
0058         12 24 24; 
0059         12 24 24; 
0060         12 24 24; 
0061         12 24 24; 
0062     ];
0063     offers.P.prc = [
0064         20 50 60;
0065         20 40 70;
0066         20 42 80;
0067         20 44 90;
0068         20 46 75;
0069         20 48 60;
0070     ];
0071     bids.P.qty = [
0072         10 10 10;
0073         10 10 10;
0074         10 10 10;
0075     ];
0076     bids.P.prc = [
0077         100 70 60;
0078 %         100 64.3 20;
0079 %         100 30.64545 0;
0080         100 50 20;
0081         100 60 50;
0082     ];
0083     
0084     offers.Q.qty = [ 60; 60; 60; 60; 60; 60; 0; 0; 0 ];
0085     offers.Q.prc = [ 0; 0; 0; 0; 0; 3; 0; 0; 0 ];
0086     bids.Q.qty = [ 15; 15; 15; 15; 15; 15; 15; 12; 7.5 ];
0087 %     bids.Q.prc = [ 0; 0; 0; 0; 0; 0; 0; 83.9056; 0 ];
0088     bids.Q.prc = [ 0; 0; 0; 0; 0; 0; 0; 20; 0 ];
0089     
0090     t = 'marginal Q offer, marginal PQ bid, auction_type = 5';
0091     mkt = struct(   'auction_type', 5, ...
0092                     't' , [], ...
0093                     'u0', [], ...
0094                     'lim', []   );
0095     [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0096     co5 = co;
0097     cb5 = cb;
0098     
0099 %     [ co.P.qty co.P.prc ]
0100 %     [ cb.P.qty cb.P.prc ]
0101 %     [ co.Q.qty co.Q.prc ]
0102 %     [ cb.Q.qty cb.Q.prc ]
0103     
0104     i2e = r.bus(:, BUS_I);
0105     e2i = sparse(max(i2e), 1);
0106     e2i(i2e) = (1:size(r.bus, 1))';
0107     G = find( ~isload(r.gen) );   %% real generators
0108     L = find(  isload(r.gen) );   %% dispatchable loads
0109     Gbus = e2i(r.gen(G,GEN_BUS));
0110     Lbus = e2i(r.gen(L,GEN_BUS));
0111     
0112     t_is( co.P.qty, ones(6, 1) * [12 24 0], 2, [t ' : gen P quantities'] );
0113     t_is( co.P.prc(1,:), 50.1578, 3, [t ' : gen 1 P prices'] );
0114     t_is( cb.P.qty, [10 10 10; 10 0.196 0; 10 10 0], 2, [t ' : load P quantities'] );
0115     t_is( cb.P.prc(2,:), 56.9853, 4, [t ' : load 2 P price'] );
0116     t_is( co.P.prc(:,1), r.bus(Gbus, LAM_P), 8, [t ' : gen P prices'] );
0117     t_is( cb.P.prc(:,1), r.bus(Lbus, LAM_P), 8, [t ' : load P prices'] );
0118     
0119     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'] );
0120     t_is( co.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q offer prices'] );
0121     t_is( cb.Q.qty, [0;0;0;0;0;0; 15; 4.0785; 5], 2, [t ' : Q bid quantities'] );
0122     t_is( cb.Q.prc, [0;0;0;0;0;3; 0.4861; 2.5367; 1.3763], 4, [t ' : Q bid prices'] );
0123     t_is( co.Q.prc, r.bus([Gbus; Lbus], LAM_Q), 8, [t ' : Q offer prices'] );
0124     t_is( cb.Q.prc, co.Q.prc, 8, [t ' : Q bid prices'] );
0125     
0126     t = 'marginal Q offer, marginal PQ bid, auction_type = 0';
0127     mkt.auction_type = 0;
0128     [r, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt, mpopt);
0129     t_is( co.P.qty, co5.P.qty, 8, [t ' : gen P quantities'] );
0130     t_is( cb.P.qty, cb5.P.qty, 8, [t ' : load P quantities'] );
0131     t_is( co.P.prc, offers.P.prc, 8, [t ' : gen P prices'] );
0132     t_is( cb.P.prc, bids.P.prc, 8, [t ' : load P prices'] );
0133     
0134     t_is( co.Q.qty, co5.Q.qty, 8, [t ' : gen Q quantities'] );
0135     t_is( cb.Q.qty, cb5.Q.qty, 8, [t ' : load Q quantities'] );
0136     t_is( co.Q.prc, offers.Q.prc, 8, [t ' : gen Q prices'] );
0137     t_is( cb.Q.prc, bids.Q.prc, 8, [t ' : load Q prices'] );
0138 end
0139 
0140 t_end;

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