Home > matpower7.1 > 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 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0051 %   by Ray Zimmerman, PSERC Cornell
0052 %
0053 %   This file is part of MATPOWER Extras.
0054 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0055 %   See https://github.com/MATPOWER/matpower-extras for more info.
0056 
0057 %%-----  initialize  -----
0058 %% default arguments
0059 if nargin < 10
0060     solvedcase = '';                        %% don't save solved case
0061     if nargin < 9
0062         fname = '';                         %% don't print results to a file
0063         if nargin < 8
0064             mpopt = mpoption;               %% use default options
0065             if nargin < 7
0066                 t = [];                     %% use default dispatch period duration (hours)
0067                 if nargin < 6
0068                     u0 = [];                %% use default for previous gen commitment
0069                     if nargin < 5
0070                         max_p = 500;        %% use default price cap
0071                         if nargin < 4
0072                             mkt = [];       %% use default market
0073                             if nargin < 3
0074                                 q = []; p = []; %% p & q not defined (use gencost)
0075                                 if nargin < 1
0076                                     casedata = 'case9'; %% default data file is 'case9.m'
0077                                 end
0078                             end
0079                         end
0080                     end
0081                 end
0082             end
0083         end
0084     end
0085 end
0086 
0087 %% read data & convert to internal bus numbering
0088 mpc = loadcase(casedata);
0089 
0090 %% find indices for gens and variable loads
0091 G = find( ~isload(mpc.gen) );   %% real generators
0092 L = find(  isload(mpc.gen) );   %% variable loads
0093 
0094 %% create offers, bids
0095 if isempty(q) || isempty(p)
0096     offers.P.qty = [];
0097     offers.P.prc = [];
0098     bids.P.qty = [];
0099     bids.P.prc = [];
0100 else
0101     offers.P.qty = q(G, :);
0102     offers.P.prc = p(G, :);
0103     bids.P.qty = q(L, :);
0104     bids.P.prc = p(L, :);
0105 end
0106 
0107 %% parse market code
0108 code        = mkt - 1000;
0109 adjust4loc  = fix(code/100);    code = rem(code, 100);
0110 auction_type= fix(code/10);
0111 if adjust4loc == 2
0112     OPF = 'DC';
0113 elseif adjust4loc == 1
0114     OPF = 'AC';
0115 else
0116     error('invalid market code');
0117 end
0118 
0119 %% eliminates offers (but not bids) above max_p
0120 lim = struct( 'P', struct( 'max_offer',         max_p, ...
0121                            'max_cleared_offer', max_p ) );
0122 mkt = struct(   'auction_type', auction_type, 'OPF', OPF, ...
0123                 'lim', lim, 't', t', 'u0', u0   );
0124 [mpc_out, co, cb, f, dispatch, success, et] = ...
0125                 runmarket(mpc, offers, bids, mkt, mpopt, fname, solvedcase);
0126 
0127 cq(G, :) = co.P.qty;
0128 cp(G, :) = co.P.prc;
0129 cq(L, :) = cb.P.qty;
0130 cp(L, :) = cb.P.prc;
0131 bus = mpc_out.bus;
0132 gen = mpc_out.gen;
0133 gencost = mpc_out.gencost;
0134 branch = mpc_out.branch;
0135 
0136 %% this is just to prevent it from printing baseMVA
0137 %% when called with no output arguments
0138 if nargout, MVAbase = mpc_out.baseMVA; end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005