Home > matpower7.0 > 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-2016, 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 
0056 %% summarize results
0057 psi = zeros(nt, nj_max, nc_max+1);
0058 Pg = zeros(ng, nt, nj_max, nc_max+1);
0059 if mdo.idx.ntramp
0060     Rup = [zeros(ng, 1) mdo.results.Rrp];
0061     Rdn = [zeros(ng, 1) mdo.results.Rrm];
0062 else
0063     Rup = [];
0064     Rdn = [];
0065 end
0066 u = zeros(ng, nt);
0067 lamP = zeros(nb, nt, nj_max, nc_max+1);
0068 muF = zeros(nl, nt, nj_max, nc_max+1);
0069 Pf = zeros(nl, nt, nj_max, nc_max+1);
0070 for t = 1:nt
0071   for j = 1:mdo.idx.nj(t)
0072     for k = 1:mdo.idx.nc(t,j)+1
0073       rr = mdo.flow(t,j,k).mpc;
0074       psi(t, j, k) = mdo.CostWeightsAdj(k, j, t);
0075       u(:, t) = rr.gen(:, GEN_STATUS);
0076       Pg(:, t, j, k) = rr.gen(:, PG);
0077       lamP(:, t, j, k) = rr.bus(:, LAM_P);
0078       Pf(:, t, j, k) = rr.branch(:, PF);
0079       muF(:, t, j, k) = rr.branch(:, MU_SF) + rr.branch(:, MU_ST);
0080     end
0081   end
0082 end
0083 
0084 ms = struct(...
0085     'f',    mdo.QP.f + mdo.QP.c1, ...
0086     'nb',   nb, ...
0087     'ng',   ng, ...
0088     'nl',   nl, ...
0089     'nt',   nt, ...
0090     'nj_max', nj_max, ...
0091     'nc_max', nc_max, ...
0092     'psi',  psi, ...
0093     'Pg',   Pg, ...
0094     'Rup',  Rup, ...
0095     'Rdn',  Rdn, ...
0096     'Pf',   Pf, ...
0097     'u',    u, ...
0098     'lamP', lamP, ...
0099     'muF',  muF ...
0100 );    
0101 
0102 %% print results
0103 if verbose
0104     fprintf('\n========== OBJECTIVE  ==========\n');
0105     fprintf('f = %.12g\n', ms.f);
0106 
0107     fprintf('\n========== GEN_STATUS ==========\n');
0108     fprintf(' Gen ');
0109     for t = 1:nt
0110         fprintf('   t =%2d ', t);
0111     end
0112     fprintf('\n');
0113     fprintf('----');
0114     for t = 1:nt
0115         fprintf('  -------');
0116     end
0117     fprintf('\n');
0118     for i = 1:ng
0119         fprintf('%4d', i);
0120 %         fprintf('%9d', u(i, :));
0121         for t = 1:nt
0122             qty = u(i, t);
0123             if abs(qty) > tol
0124                 fprintf('      1  ');
0125             else
0126                 fprintf('    --0--');
0127             end
0128         end
0129         fprintf('\n');
0130     end
0131     fprintf('\n');
0132 
0133     print_most_summary_section('PG', 'Gen', nt, nj_max, nc_max, Pg);
0134     if mdo.idx.ntramp
0135         print_most_summary_section('RAMP UP', 'Gen', nt, 1, 0, Rup);
0136         print_most_summary_section('RAMP DOWN', 'Gen', nt, 1, 0, Rdn);
0137     end
0138     print_most_summary_section('LAM_P', 'Bus', nt, nj_max, nc_max, lamP);
0139     print_most_summary_section('PF',   'Brch', nt, nj_max, nc_max, Pf);
0140     print_most_summary_section('MU_F', 'Brch', nt, nj_max, nc_max, muF);
0141 end
0142 
0143 if nargout
0144     mso = ms;
0145 end
0146 
0147 %%---------------------------------------------------------
0148 function print_most_summary_section(label, section_type, nt, nj_max, nc_max, data, tol)
0149 if nargin < 7
0150     tol = 1e-4;
0151 end
0152 n = size(data, 1);
0153 bl = blanks(fix((12-length(label)) / 2));
0154 fprintf('\n==========%-12s==========\n', sprintf('%s%s', bl, label));
0155 for j = 1:nj_max
0156     for k = 1:nc_max+1
0157         if nj_max > 1 || nc_max > 0
0158             fprintf('\nSCENARIO %d', j);
0159             if nc_max == 0
0160                 fprintf('\n');
0161             elseif k == 1
0162                 fprintf(', base case\n');
0163             else
0164                 fprintf(', contingency %d\n', k-1);
0165             end
0166         end
0167         fprintf('%4s ', section_type);
0168         for t = 1:nt
0169             fprintf('   t =%2d ', t);
0170         end
0171         fprintf('\n');
0172         fprintf('----');
0173         for t = 1:nt
0174             fprintf('  -------');
0175         end
0176         fprintf('\n');
0177         for i = 1:n
0178             fprintf('%4d', i);
0179             for t = 1:nt
0180                 qty = data(i, t, j, k);
0181                 if abs(qty) > tol
0182                     fprintf('%9.2f', qty);
0183                 else
0184                     fprintf('      -  ');
0185                 end
0186             end
0187             fprintf('\n');
0188         end
0189     end
0190 end
0191 fprintf('\n');

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005