RUNMKT Runs smart market for PowerWeb. Deprecated, see RUNMARKET. [BASEMVA, CQ, CP, BUS, GEN, GENCOST, BRANCH, F, DISPATCH, SUCCESS, ET] = ... RUNMKT(CASEDATA, Q, P, MKT, MAX_P, U0, T, MPOPT, FNAME, SOLVEDCASE) Computes a new generation schedule from a set of offers and bids, where offers and bids are specified by Q and P, MKT tells it what type of market to use, MAX_P is the price cap, U0 is a vector containing the commitment status of each generator from the previous period (for computing startup/shutdown costs), T is the time duration of the dispatch period in hours, and MPOPT is a MATPOWER options struct (see 'help mpoption' for details). Uses default options if MPOPT is not given. The rows in Q and P correspond to the rows in gen and gencost, and each column corresponds to another block in the marginal offer or bid. The market codes are defined as the sum of the following numbers: 1000 - all markets 100 * adjust4loc - adjust4loc = 0 to ignore network, 1 to compute locational adjustments via AC OPF, 2 to compute them via DC OPF 10 * auction_type - where the values for auction_type are as follows: 0 - discriminative pricing (price equal to offer or bid) 1 - last accepted offer auction 2 - first rejected offer auction 3 - last accepted bid auction 4 - first rejected bid auction 5 - first price auction (marginal unit, offer or bid, sets the price) 6 - second price auction (if offer is marginal, then price is set by min(FRO,LAB), if bid, then max(FRB,LAO) 7 - split the difference pricing (price set by last accepted offer & bid) 8 - LAO sets seller price, LAB sets buyer price If P or Q are empty or not given, they are created from the generator cost function. The default market code is 1150, where the marginal block (offer or bid) sets the price. The default MAX_P is 500, the default U0 is all ones (assume everything was running) and the default duration T is 1 hour. The results may optionally be printed to a file (appended if the file exists) whose name is given in FNAME (in addition to printing to STDOUT). Optionally returns the final values of BASEMVA, CQ, CP, BUS, GEN, GENCOST, BRANCH, F, DISPATCH, SUCCESS, and ET. If a name is given in SOLVEDCASE, the solved case will be written to a case file in MATPOWER format with the specified name with a '.m' extension added.
0001 function [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ... 0002 runmkt(casedata, q, p, mkt, max_p, u0, t, mpopt, fname, solvedcase) 0003 %RUNMKT Runs smart market for PowerWeb. 0004 % 0005 % Deprecated, see RUNMARKET. 0006 % 0007 % [BASEMVA, CQ, CP, BUS, GEN, GENCOST, BRANCH, F, DISPATCH, SUCCESS, ET] = ... 0008 % RUNMKT(CASEDATA, Q, P, MKT, MAX_P, U0, T, MPOPT, FNAME, SOLVEDCASE) 0009 % 0010 % Computes a new generation schedule from a set of offers and bids, 0011 % where offers and bids are specified by Q and P, MKT tells it what 0012 % type of market to use, MAX_P is the price cap, U0 is a vector 0013 % containing the commitment status of each generator from the previous 0014 % period (for computing startup/shutdown costs), T is the time duration 0015 % of the dispatch period in hours, and MPOPT is a MATPOWER options struct 0016 % (see 'help mpoption' for details). Uses default options if MPOPT is not 0017 % given. The rows in Q and P correspond to the rows in gen and gencost, 0018 % and each column corresponds to another block in the marginal offer or 0019 % bid. The market codes are defined as the sum of the 0020 % following numbers: 0021 % 1000 - all markets 0022 % 100 * adjust4loc - adjust4loc = 0 to ignore network, 0023 % 1 to compute locational adjustments via AC OPF, 0024 % 2 to compute them via DC OPF 0025 % 10 * auction_type - where the values for auction_type are as follows: 0026 % 0027 % 0 - discriminative pricing (price equal to offer or bid) 0028 % 1 - last accepted offer auction 0029 % 2 - first rejected offer auction 0030 % 3 - last accepted bid auction 0031 % 4 - first rejected bid auction 0032 % 5 - first price auction (marginal unit, offer or bid, sets the price) 0033 % 6 - second price auction (if offer is marginal, then price is set 0034 % by min(FRO,LAB), if bid, then max(FRB,LAO) 0035 % 7 - split the difference pricing (price set by last accepted offer & bid) 0036 % 8 - LAO sets seller price, LAB sets buyer price 0037 % 0038 % If P or Q are empty or not given, they are created from the generator 0039 % cost function. The default market code is 1150, where the marginal 0040 % block (offer or bid) sets the price. The default MAX_P is 500, the 0041 % default U0 is all ones (assume everything was running) and the default 0042 % duration T is 1 hour. The results may optionally be printed to a file 0043 % (appended if the file exists) whose name is given in FNAME (in addition 0044 % to printing to STDOUT). Optionally returns the final values of BASEMVA, 0045 % CQ, CP, BUS, GEN, GENCOST, BRANCH, F, DISPATCH, SUCCESS, and ET. If a 0046 % name is given in SOLVEDCASE, the solved case will be written to a case file 0047 % in MATPOWER format with the specified name with a '.m' extension added. 0048 0049 % MATPOWER 0050 % Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC) 0051 % by Ray Zimmerman, PSERC Cornell 0052 % 0053 % $Id: runmkt.m 2644 2015-03-11 19:34:22Z ray $ 0054 % 0055 % This file is part of MATPOWER. 0056 % Covered by the 3-clause BSD License (see LICENSE file for details). 0057 % See http://www.pserc.cornell.edu/matpower/ for more info. 0058 0059 %%----- initialize ----- 0060 %% default arguments 0061 if nargin < 10 0062 solvedcase = ''; %% don't save solved case 0063 if nargin < 9 0064 fname = ''; %% don't print results to a file 0065 if nargin < 8 0066 mpopt = mpoption; %% use default options 0067 if nargin < 7 0068 t = []; %% use default dispatch period duration (hours) 0069 if nargin < 6 0070 u0 = []; %% use default for previous gen commitment 0071 if nargin < 5 0072 max_p = 500; %% use default price cap 0073 if nargin < 4 0074 mkt = []; %% use default market 0075 if nargin < 3 0076 q = []; p = []; %% p & q not defined (use gencost) 0077 if nargin < 1 0078 casedata = 'case9'; %% default data file is 'case9.m' 0079 end 0080 end 0081 end 0082 end 0083 end 0084 end 0085 end 0086 end 0087 end 0088 0089 %% read data & convert to internal bus numbering 0090 mpc = loadcase(casedata); 0091 0092 %% find indices for gens and variable loads 0093 G = find( ~isload(mpc.gen) ); %% real generators 0094 L = find( isload(mpc.gen) ); %% variable loads 0095 0096 %% create offers, bids 0097 if isempty(q) || isempty(p) 0098 offers.P.qty = []; 0099 offers.P.prc = []; 0100 bids.P.qty = []; 0101 bids.P.prc = []; 0102 else 0103 offers.P.qty = q(G, :); 0104 offers.P.prc = p(G, :); 0105 bids.P.qty = q(L, :); 0106 bids.P.prc = p(L, :); 0107 end 0108 0109 %% parse market code 0110 code = mkt - 1000; 0111 adjust4loc = fix(code/100); code = rem(code, 100); 0112 auction_type= fix(code/10); 0113 if adjust4loc == 2 0114 OPF = 'DC'; 0115 elseif adjust4loc == 1 0116 OPF = 'AC'; 0117 else 0118 error('invalid market code'); 0119 end 0120 0121 %% eliminates offers (but not bids) above max_p 0122 lim = struct( 'P', struct( 'max_offer', max_p, ... 0123 'max_cleared_offer', max_p ) ); 0124 mkt = struct( 'auction_type', auction_type, 'OPF', OPF, ... 0125 'lim', lim, 't', t', 'u0', u0 ); 0126 [mpc_out, co, cb, f, dispatch, success, et] = ... 0127 runmarket(mpc, offers, bids, mkt, mpopt, fname, solvedcase); 0128 0129 cq(G, :) = co.P.qty; 0130 cp(G, :) = co.P.prc; 0131 cq(L, :) = cb.P.qty; 0132 cp(L, :) = cb.P.prc; 0133 bus = mpc_out.bus; 0134 gen = mpc_out.gen; 0135 gencost = mpc_out.gencost; 0136 branch = mpc_out.branch; 0137 0138 %% this is just to prevent it from printing baseMVA 0139 %% when called with no output arguments 0140 if nargout, MVAbase = mpc_out.baseMVA; end