Home > matpower7.1 > most > lib > most_summary.m

most_summary

PURPOSE ^

MOST_SUMMARY Collects and optionally prints a summary of MOST results.

SYNOPSIS ^

function mso = most_summary(mdo)

DESCRIPTION ^

MOST_SUMMARY  Collects and optionally prints a summary of MOST results.
   MS = MOST_SUMMARY(MDO)

   Note: Consider this function experimental. It is included because it
         is often better than nothing, though it is very incomplete.

   Given a MOST data struct returned by MOST, returns a struct with the
   following fields:
       f       - objective function value
       nb      - number of buses
       ng      - number of generators (incl. storage, disp. load, etc.)
       nl      - number of branches
       nt      - number of periods in planning horizon
       nj_max  - max number of scenarios per period
       nc_max  - max number of contingencies per scenario in any period
       Pg      - ng x nt x nj_max x (nc_max+1), real power generation
       Rup     - ng x nt, upward ramping reserve quantities
       Rdn     - ng x nt, downward ramping reserve quantities
       Pf      - nl x nt x nj_max x (nc_max+1), real power generation
       u       - ng x nt x nj_max x (nc_max+1), generator commitment status
       lamP    - nb x nt x nj_max x (nc_max+1), shadow price on power balance
       muF     - nl x nt x nj_max x (nc_max+1), shadow price on flow limits

   Printing to the console is currently controlled by the MDO.QP.verbose
   flag.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function mso = most_summary(mdo)
0002 %MOST_SUMMARY  Collects and optionally prints a summary of MOST results.
0003 %   MS = MOST_SUMMARY(MDO)
0004 %
0005 %   Note: Consider this function experimental. It is included because it
0006 %         is often better than nothing, though it is very incomplete.
0007 %
0008 %   Given a MOST data struct returned by MOST, returns a struct with the
0009 %   following fields:
0010 %       f       - objective function value
0011 %       nb      - number of buses
0012 %       ng      - number of generators (incl. storage, disp. load, etc.)
0013 %       nl      - number of branches
0014 %       nt      - number of periods in planning horizon
0015 %       nj_max  - max number of scenarios per period
0016 %       nc_max  - max number of contingencies per scenario in any period
0017 %       Pg      - ng x nt x nj_max x (nc_max+1), real power generation
0018 %       Rup     - ng x nt, upward ramping reserve quantities
0019 %       Rdn     - ng x nt, downward ramping reserve quantities
0020 %       Pf      - nl x nt x nj_max x (nc_max+1), real power generation
0021 %       u       - ng x nt x nj_max x (nc_max+1), generator commitment status
0022 %       lamP    - nb x nt x nj_max x (nc_max+1), shadow price on power balance
0023 %       muF     - nl x nt x nj_max x (nc_max+1), shadow price on flow limits
0024 %
0025 %   Printing to the console is currently controlled by the MDO.QP.verbose
0026 %   flag.
0027 
0028 %   MOST
0029 %   Copyright (c) 2015-2020, Power Systems Engineering Research Center (PSERC)
0030 %   by Ray Zimmerman, PSERC Cornell
0031 %
0032 %   This file is part of MOST.
0033 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0034 %   See https://github.com/MATPOWER/most for more info.
0035 
0036 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0037     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0038 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0039     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0040     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0041 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0042     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0043     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0044 
0045 tol = 1e-4;
0046 verbose = mdo.QP.opt.verbose;
0047 % verbose = 1;
0048 mpc = mdo.mpc;
0049 nb = size(mpc.bus, 1);
0050 nl = size(mpc.branch, 1);
0051 ng = size(mpc.gen, 1);
0052 nt = mdo.idx.nt;
0053 nj_max = max(mdo.idx.nj);
0054 nc_max = max(max(mdo.idx.nc));
0055 ns = mdo.idx.ns;
0056 
0057 %% summarize results
0058 psi = zeros(nt, nj_max, nc_max+1);
0059 Pg = zeros(ng, nt, nj_max, nc_max+1);
0060 Pd = zeros(nb, nt, nj_max, nc_max+1);
0061 if mdo.idx.ntramp
0062     Rup = [zeros(ng, 1) mdo.results.Rrp];
0063     Rdn = [zeros(ng, 1) mdo.results.Rrm];
0064 else
0065     Rup = [];
0066     Rdn = [];
0067 end
0068 u = zeros(ng, nt);
0069 lamP = zeros(nb, nt, nj_max, nc_max+1);
0070 muF = zeros(nl, nt, nj_max, nc_max+1);
0071 Pf = zeros(nl, nt, nj_max, nc_max+1);
0072 for t = 1:nt
0073   for j = 1:mdo.idx.nj(t)
0074     for k = 1:mdo.idx.nc(t,j)+1
0075       rr = mdo.flow(t,j,k).mpc;
0076       psi(t, j, k) = mdo.CostWeightsAdj(k, j, t);
0077       u(:, t) = rr.gen(:, GEN_STATUS);
0078       Pg(:, t, j, k) = rr.gen(:, PG);
0079       Pd(:, t, j, k) = rr.bus(:, PD);
0080       lamP(:, t, j, k) = rr.bus(:, LAM_P);
0081       Pf(:, t, j, k) = rr.branch(:, PF);
0082       muF(:, t, j, k) = rr.branch(:, MU_SF) + rr.branch(:, MU_ST);
0083     end
0084   end
0085 end
0086 if ns
0087     SoC = mdo.Storage.ExpectedStorageState;
0088 else
0089     SoC = [];
0090 end
0091 
0092 ms = struct(...
0093     'f',    mdo.QP.f + mdo.QP.c1, ...
0094     'nb',   nb, ...
0095     'ng',   ng, ...
0096     'nl',   nl, ...
0097     'ns',   ns, ...
0098     'nt',   nt, ...
0099     'nj_max', nj_max, ...
0100     'nc_max', nc_max, ...
0101     'psi',  psi, ...
0102     'Pg',   Pg, ...
0103     'Pd',   Pd, ...
0104     'Rup',  Rup, ...
0105     'Rdn',  Rdn, ...
0106     'SoC',  SoC, ...
0107     'Pf',   Pf, ...
0108     'u',    u, ...
0109     'lamP', lamP, ...
0110     'muF',  muF ...
0111 );    
0112 
0113 %% print results
0114 if verbose
0115     fprintf('\n========== OBJECTIVE  ==========\n');
0116     fprintf('f = %.12g\n', ms.f);
0117 
0118     fprintf('\n========== GEN_STATUS ==========\n');
0119     fprintf(' Gen ');
0120     for t = 1:nt
0121         fprintf('   t =%2d ', t);
0122     end
0123     fprintf('\n');
0124     fprintf('----');
0125     for t = 1:nt
0126         fprintf('  -------');
0127     end
0128     fprintf('\n');
0129     for i = 1:ng
0130         fprintf('%4d', i);
0131 %         fprintf('%9d', u(i, :));
0132         for t = 1:nt
0133             qty = u(i, t);
0134             if abs(qty) > tol
0135                 fprintf('      1  ');
0136             else
0137                 fprintf('    --0--');
0138             end
0139         end
0140         fprintf('\n');
0141     end
0142     fprintf('\n');
0143 
0144     print_most_summary_section('PG', 'Gen', nt, nj_max, nc_max, Pg);
0145     if mdo.idx.ntramp
0146         print_most_summary_section('RAMP UP', 'Gen', nt, 1, 0, Rup);
0147         print_most_summary_section('RAMP DOWN', 'Gen', nt, 1, 0, Rdn);
0148     end
0149     print_most_summary_section('FIXED LOAD', 'Bus', nt, nj_max, nc_max, Pd);
0150     if ns
0151         print_most_summary_section('ESS E[SoC]', 'ESS', nt, 1, 0, SoC);
0152     end
0153     if mdo.DCMODEL
0154         print_most_summary_section('LAM_P', 'Bus', nt, nj_max, nc_max, lamP);
0155         print_most_summary_section('PF',   'Brch', nt, nj_max, nc_max, Pf);
0156         print_most_summary_section('MU_F', 'Brch', nt, nj_max, nc_max, muF);
0157     end
0158 end
0159 
0160 if nargout
0161     mso = ms;
0162 end
0163 
0164 %%---------------------------------------------------------
0165 function print_most_summary_section(label, section_type, nt, nj_max, nc_max, data, tol)
0166 if nargin < 7
0167     tol = 1e-4;
0168 end
0169 n = size(data, 1);
0170 bl = blanks(fix((12-length(label)) / 2));
0171 fprintf('\n==========%-12s==========\n', sprintf('%s%s', bl, label));
0172 if any(data(:))
0173     for j = 1:nj_max
0174         for k = 1:nc_max+1
0175             if nj_max > 1 || nc_max > 0
0176                 fprintf('\nSCENARIO %d', j);
0177                 if nc_max == 0
0178                     fprintf('\n');
0179                 elseif k == 1
0180                     fprintf(', base case\n');
0181                 else
0182                     fprintf(', contingency %d\n', k-1);
0183                 end
0184             end
0185             fprintf('%4s ', section_type);
0186             for t = 1:nt
0187                 fprintf('   t =%2d ', t);
0188             end
0189             fprintf('\n');
0190             fprintf('----');
0191             for t = 1:nt
0192                 fprintf('  -------');
0193             end
0194             fprintf('\n');
0195             for i = 1:n
0196                 fprintf('%4d', i);
0197                 for t = 1:nt
0198                     qty = data(i, t, j, k);
0199                     if abs(qty) > tol
0200                         fprintf('%9.2f', qty);
0201                     else
0202                         fprintf('      -  ');
0203                     end
0204                 end
0205                 fprintf('\n');
0206             end
0207         end
0208     end
0209 else
0210     fprintf('All zeros.\n');
0211 end
0212 fprintf('\n');

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