Home > matpower4.0 > extras > smartmarket > printmkt.m

printmkt

PURPOSE ^

PRINTMKT Prints results of ISO computation.

SYNOPSIS ^

function printmkt(r, t, dispatch, success, fd, mpopt)

DESCRIPTION ^

PRINTMKT   Prints results of ISO computation.
   PRINTMKT(RESULTS, T, DISPATCH, SUCCESS, FD, MPOPT)
   Prints results of ISO computation to FD (a file descriptor which
   defaults to STDOUT). MPOPT is a MATPOWER options vector (see
   MPOPTION for details). Uses default options if this parameter is
   not given. The duration of the dispatch period (in hours) is given
   in T. DISPATCH and RESULTS are the values returned by SMARTMKT.

   See also SMARTMKT.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function printmkt(r, t, dispatch, success, fd, mpopt)
0002 %PRINTMKT   Prints results of ISO computation.
0003 %   PRINTMKT(RESULTS, T, DISPATCH, SUCCESS, FD, MPOPT)
0004 %   Prints results of ISO computation to FD (a file descriptor which
0005 %   defaults to STDOUT). MPOPT is a MATPOWER options vector (see
0006 %   MPOPTION for details). Uses default options if this parameter is
0007 %   not given. The duration of the dispatch period (in hours) is given
0008 %   in T. DISPATCH and RESULTS are the values returned by SMARTMKT.
0009 %
0010 %   See also SMARTMKT.
0011 
0012 %   MATPOWER
0013 %   $Id: printmkt.m,v 1.13 2010/04/26 19:45:26 ray Exp $
0014 %   by Ray Zimmerman, PSERC Cornell
0015 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0016 %
0017 %   This file is part of MATPOWER.
0018 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0019 %
0020 %   MATPOWER is free software: you can redistribute it and/or modify
0021 %   it under the terms of the GNU General Public License as published
0022 %   by the Free Software Foundation, either version 3 of the License,
0023 %   or (at your option) any later version.
0024 %
0025 %   MATPOWER is distributed in the hope that it will be useful,
0026 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0027 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0028 %   GNU General Public License for more details.
0029 %
0030 %   You should have received a copy of the GNU General Public License
0031 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0032 %
0033 %   Additional permission under GNU GPL version 3 section 7
0034 %
0035 %   If you modify MATPOWER, or any covered work, to interface with
0036 %   other modules (such as MATLAB code and MEX-files) available in a
0037 %   MATLAB(R) or comparable environment containing parts covered
0038 %   under other licensing terms, the licensors of MATPOWER grant
0039 %   you additional permission to convey the resulting work.
0040 
0041 %%----- initialization -----
0042 %% default arguments
0043 if nargin < 6
0044     mpopt = mpoption;   %% use default options
0045     if nargin < 5
0046         fd = 1;         %% print to stdio by default
0047     end
0048 end
0049 gen = r.gen;
0050 
0051 %% options
0052 OUT_ALL         = mpopt(32);
0053 OUT_RAW         = mpopt(43);
0054 
0055 %% define named indices into data matrices
0056 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0057     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0058     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0059 [QUANTITY, PRICE, FCOST, VCOST, SCOST, PENALTY] = idx_disp;
0060 
0061 %% parameters
0062 ng = size(gen, 1);
0063 
0064 %%----- print the stuff -----
0065 pay = dispatch(:, PRICE) .* dispatch(:, QUANTITY) * t;
0066 cost = dispatch(:, FCOST) + dispatch(:, VCOST) + dispatch(:, SCOST) + dispatch(:, PENALTY);
0067 if OUT_ALL
0068     %% dispatch data
0069     fprintf(fd, '\n================================================================================');
0070     fprintf(fd, '\n|     Market Summary                                                           |');
0071     fprintf(fd, '\n================================================================================');
0072     fprintf(fd, '\nDispatch period duration: %.2f hours', t);
0073     fprintf(fd, '\nGen  Bus     Pg      Price    Revenue   Fix+Var   Strt/Stp   Total    Earnings');
0074     fprintf(fd, '\n #    #     (MW)    ($/MWh)     ($)     Cost ($)  Cost ($)  Cost ($)     ($)  ');
0075     fprintf(fd, '\n---  ---  --------  --------  --------  --------  --------  --------  --------');
0076     for i = 1:size(gen, 1)
0077         if gen(i, PG)
0078             fprintf(fd, '\n%3d%5d%9.2f%10.3f%10.2f%10.2f%10.2f%10.2f%10.2f', ...
0079                 i, gen(i, GEN_BUS), dispatch(i, QUANTITY), dispatch(i, PRICE), pay(i), ...
0080                 dispatch(i, FCOST) + dispatch(i, VCOST), ...
0081                 dispatch(i, SCOST), cost(i), pay(i) - cost(i));
0082         else
0083             if dispatch(i, SCOST) || dispatch(i, PENALTY)
0084                 fprintf(fd, '\n%3d%5d      -  %10.3f       -         -  %10.2f%10.2f%10.2f', ...
0085                     i, gen(i, GEN_BUS), dispatch(i, PRICE), dispatch(i, SCOST), ...
0086                     cost(i), pay(i) - cost(i));
0087             else
0088                 fprintf(fd, '\n%3d%5d      -  %10.3f       -         -         -         -         -', ...
0089                     i, gen(i, GEN_BUS), dispatch(i, PRICE));
0090             end
0091         end
0092         if dispatch(i, PENALTY)
0093             fprintf(fd, '%10.2f penalty (included in total cost)', dispatch(i, PENALTY));
0094         end
0095     end
0096     fprintf(fd, '\n          --------            --------  --------  --------  --------  --------');
0097     fprintf(fd, '\nTotal:  %9.2f          %10.2f%10.2f%10.2f%10.2f%10.2f', ...
0098         sum(dispatch(:, QUANTITY)), sum(pay), sum(dispatch(:, FCOST)) + sum(dispatch(:, VCOST)), ...
0099         sum(dispatch(:, SCOST)), sum(cost), sum(pay-cost));
0100     if sum(dispatch(:, PENALTY))
0101         fprintf(fd, '%10.2f penalty (included in total cost)', sum(dispatch(:, PENALTY)));
0102     end
0103     fprintf(fd, '\n');
0104 end
0105 
0106 %% print raw data for Perl database interface
0107 if OUT_RAW
0108     fprintf(fd, '----------  raw PW::Dispatch data below  ----------\n');
0109     fprintf(fd, 'dispatch\n');
0110     fprintf(fd, '%d\t%.8g\t%.8g\t%.8g\t%.8g\t%.8g\t%.8g\t%.8g\n', ...
0111                 [(1:ng)' dispatch(:, [QUANTITY, PRICE, FCOST, VCOST, SCOST, PENALTY]) pay-cost]');
0112     fprintf(fd, '----------  raw PW::Dispatch data above  ----------\n');
0113 end
0114 
0115 %% print remaining opf output
0116 printpf(r, fd, mpopt);

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