Home > matpower5.1 > 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 struct (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 struct (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 %   Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC)
0014 %   by Ray Zimmerman, PSERC Cornell
0015 %
0016 %   $Id: printmkt.m 2644 2015-03-11 19:34:22Z ray $
0017 %
0018 %   This file is part of MATPOWER.
0019 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0020 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0021 
0022 %%----- initialization -----
0023 %% default arguments
0024 if nargin < 6
0025     mpopt = mpoption;   %% use default options
0026     if nargin < 5
0027         fd = 1;         %% print to stdio by default
0028     end
0029 end
0030 gen = r.gen;
0031 
0032 %% options
0033 OUT_RAW         = 0;
0034 
0035 %% define named indices into data matrices
0036 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0037     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0038     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0039 [QUANTITY, PRICE, FCOST, VCOST, SCOST, PENALTY] = idx_disp;
0040 
0041 %% parameters
0042 ng = size(gen, 1);
0043 
0044 %%----- print the stuff -----
0045 pay = dispatch(:, PRICE) .* dispatch(:, QUANTITY) * t;
0046 cost = dispatch(:, FCOST) + dispatch(:, VCOST) + dispatch(:, SCOST) + dispatch(:, PENALTY);
0047 if mpopt.out.all
0048     %% dispatch data
0049     fprintf(fd, '\n================================================================================');
0050     fprintf(fd, '\n|     Market Summary                                                           |');
0051     fprintf(fd, '\n================================================================================');
0052     fprintf(fd, '\nDispatch period duration: %.2f hours', t);
0053     fprintf(fd, '\nGen  Bus     Pg      Price    Revenue   Fix+Var   Strt/Stp   Total    Earnings');
0054     fprintf(fd, '\n #    #     (MW)    ($/MWh)     ($)     Cost ($)  Cost ($)  Cost ($)     ($)  ');
0055     fprintf(fd, '\n---  ---  --------  --------  --------  --------  --------  --------  --------');
0056     for i = 1:size(gen, 1)
0057         if gen(i, PG)
0058             fprintf(fd, '\n%3d%5d%9.2f%10.3f%10.2f%10.2f%10.2f%10.2f%10.2f', ...
0059                 i, gen(i, GEN_BUS), dispatch(i, QUANTITY), dispatch(i, PRICE), pay(i), ...
0060                 dispatch(i, FCOST) + dispatch(i, VCOST), ...
0061                 dispatch(i, SCOST), cost(i), pay(i) - cost(i));
0062         else
0063             if dispatch(i, SCOST) || dispatch(i, PENALTY)
0064                 fprintf(fd, '\n%3d%5d      -  %10.3f       -         -  %10.2f%10.2f%10.2f', ...
0065                     i, gen(i, GEN_BUS), dispatch(i, PRICE), dispatch(i, SCOST), ...
0066                     cost(i), pay(i) - cost(i));
0067             else
0068                 fprintf(fd, '\n%3d%5d      -  %10.3f       -         -         -         -         -', ...
0069                     i, gen(i, GEN_BUS), dispatch(i, PRICE));
0070             end
0071         end
0072         if dispatch(i, PENALTY)
0073             fprintf(fd, '%10.2f penalty (included in total cost)', dispatch(i, PENALTY));
0074         end
0075     end
0076     fprintf(fd, '\n          --------            --------  --------  --------  --------  --------');
0077     fprintf(fd, '\nTotal:  %9.2f          %10.2f%10.2f%10.2f%10.2f%10.2f', ...
0078         sum(dispatch(:, QUANTITY)), sum(pay), sum(dispatch(:, FCOST)) + sum(dispatch(:, VCOST)), ...
0079         sum(dispatch(:, SCOST)), sum(cost), sum(pay-cost));
0080     if sum(dispatch(:, PENALTY))
0081         fprintf(fd, '%10.2f penalty (included in total cost)', sum(dispatch(:, PENALTY)));
0082     end
0083     fprintf(fd, '\n');
0084 end
0085 
0086 %% print raw data for Perl database interface
0087 if OUT_RAW
0088     fprintf(fd, '----------  raw PW::Dispatch data below  ----------\n');
0089     fprintf(fd, 'dispatch\n');
0090     fprintf(fd, '%d\t%.8g\t%.8g\t%.8g\t%.8g\t%.8g\t%.8g\t%.8g\n', ...
0091                 [(1:ng)' dispatch(:, [QUANTITY, PRICE, FCOST, VCOST, SCOST, PENALTY]) pay-cost]');
0092     fprintf(fd, '----------  raw PW::Dispatch data above  ----------\n');
0093 end
0094 
0095 %% print remaining opf output
0096 printpf(r, fd, mpopt);

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005