Home > matpower5.0 > extras > smartmarket > runmkt.m

runmkt

PURPOSE ^

RUNMKT Runs smart market for PowerWeb.

SYNOPSIS ^

function [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] =runmkt(casedata, q, p, mkt, max_p, u0, t, mpopt, fname, solvedcase)

DESCRIPTION ^

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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 %   $Id: runmkt.m 2229 2013-12-11 01:28:09Z ray $
0051 %   by Ray Zimmerman, PSERC Cornell
0052 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0053 %
0054 %   This file is part of MATPOWER.
0055 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0056 %
0057 %   MATPOWER is free software: you can redistribute it and/or modify
0058 %   it under the terms of the GNU General Public License as published
0059 %   by the Free Software Foundation, either version 3 of the License,
0060 %   or (at your option) any later version.
0061 %
0062 %   MATPOWER is distributed in the hope that it will be useful,
0063 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0064 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0065 %   GNU General Public License for more details.
0066 %
0067 %   You should have received a copy of the GNU General Public License
0068 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0069 %
0070 %   Additional permission under GNU GPL version 3 section 7
0071 %
0072 %   If you modify MATPOWER, or any covered work, to interface with
0073 %   other modules (such as MATLAB code and MEX-files) available in a
0074 %   MATLAB(R) or comparable environment containing parts covered
0075 %   under other licensing terms, the licensors of MATPOWER grant
0076 %   you additional permission to convey the resulting work.
0077 
0078 %%-----  initialize  -----
0079 %% default arguments
0080 if nargin < 10
0081     solvedcase = '';                        %% don't save solved case
0082     if nargin < 9
0083         fname = '';                         %% don't print results to a file
0084         if nargin < 8
0085             mpopt = mpoption;               %% use default options
0086             if nargin < 7
0087                 t = [];                     %% use default dispatch period duration (hours)
0088                 if nargin < 6
0089                     u0 = [];                %% use default for previous gen commitment
0090                     if nargin < 5
0091                         max_p = 500;        %% use default price cap
0092                         if nargin < 4
0093                             mkt = [];       %% use default market
0094                             if nargin < 3
0095                                 q = []; p = []; %% p & q not defined (use gencost)
0096                                 if nargin < 1
0097                                     casedata = 'case9'; %% default data file is 'case9.m'
0098                                 end
0099                             end
0100                         end
0101                     end
0102                 end
0103             end
0104         end
0105     end
0106 end
0107 
0108 %% read data & convert to internal bus numbering
0109 mpc = loadcase(casedata);
0110 
0111 %% find indices for gens and variable loads
0112 G = find( ~isload(mpc.gen) );   %% real generators
0113 L = find(  isload(mpc.gen) );   %% variable loads
0114 
0115 %% create offers, bids
0116 if isempty(q) || isempty(p)
0117     offers.P.qty = [];
0118     offers.P.prc = [];
0119     bids.P.qty = [];
0120     bids.P.prc = [];
0121 else
0122     offers.P.qty = q(G, :);
0123     offers.P.prc = p(G, :);
0124     bids.P.qty = q(L, :);
0125     bids.P.prc = p(L, :);
0126 end
0127 
0128 %% parse market code
0129 code        = mkt - 1000;
0130 adjust4loc  = fix(code/100);    code = rem(code, 100);
0131 auction_type= fix(code/10);
0132 if adjust4loc == 2
0133     OPF = 'DC';
0134 elseif adjust4loc == 1
0135     OPF = 'AC';
0136 else
0137     error('invalid market code');
0138 end
0139 
0140 %% eliminates offers (but not bids) above max_p
0141 lim = struct( 'P', struct( 'max_offer',         max_p, ...
0142                            'max_cleared_offer', max_p ) );
0143 mkt = struct(   'auction_type', auction_type, 'OPF', OPF, ...
0144                 'lim', lim, 't', t', 'u0', u0   );
0145 [mpc_out, co, cb, f, dispatch, success, et] = ...
0146                 runmarket(mpc, offers, bids, mkt, mpopt, fname, solvedcase);
0147 
0148 cq(G, :) = co.P.qty;
0149 cp(G, :) = co.P.prc;
0150 cq(L, :) = cb.P.qty;
0151 cp(L, :) = cb.P.prc;
0152 bus = mpc_out.bus;
0153 gen = mpc_out.gen;
0154 gencost = mpc_out.gencost;
0155 branch = mpc_out.branch;
0156 
0157 %% this is just to prevent it from printing baseMVA
0158 %% when called with no output arguments
0159 if nargout, MVAbase = mpc_out.baseMVA; end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005