Home > matpower7.1 > extras > syngrid > lib > sgvm_collection_stats.m

sgvm_collection_stats

PURPOSE ^

SGVM_COLLECTION_STATS prints statistics for an array of mpc cases.

SYNOPSIS ^

function sgvm_collection_stats(obj, field)

DESCRIPTION ^

SGVM_COLLECTION_STATS prints statistics for an array of mpc cases.
   SGVM_COLLECTION_STATS(OBJ, FIELD)

   Inputs
     OBJ - object containting a collection of MATPOWER cases
           i.e SGVM_GENERATIONCLASS or SGVM_SOLNSTASH
     FIELD - the property of OBJ that contains a cell array of MATPOWER cases

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sgvm_collection_stats(obj, field)
0002 %SGVM_COLLECTION_STATS prints statistics for an array of mpc cases.
0003 %   SGVM_COLLECTION_STATS(OBJ, FIELD)
0004 %
0005 %   Inputs
0006 %     OBJ - object containting a collection of MATPOWER cases
0007 %           i.e SGVM_GENERATIONCLASS or SGVM_SOLNSTASH
0008 %     FIELD - the property of OBJ that contains a cell array of MATPOWER cases
0009 
0010 %   SynGrid
0011 %   Copyright (c) 2018, Power Systems Engineering Research Center (PSERC)
0012 %   by Eran Schweitzer, Arizona State University
0013 %
0014 %   This file is part of SynGrid.
0015 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0016 
0017 if nargin == 1
0018     field = 'inds';
0019 end
0020 fprintf(['===========================', repmat('===========', 1, length(obj.(field))), '\n']);
0021 tmp  = cellfun(@(x) x.id(1:6), obj.(field), 'UniformOutput', false);
0022 stmp = sprintf(['Ind #(id)                 |', repmat('%%2.1d(%6s)|',1, length(obj.(field))), '\n'],tmp{:});
0023 fprintf(stmp, 1:length(obj.(field)));
0024 %fprintf(['Ind #                     |', repmat('%10.1d|',1, length(obj.(field))), '\n'],...
0025 %    1:length(obj.(field)));
0026 fprintf(['--------------------------|', repmat('----------|', 1, length(obj.(field))), '\n']);
0027 
0028 tmp  = cellfun(@(x) x.call, obj.(field), 'UniformOutput', false);
0029 stmp = sprintf(['From Generation           |', repmat('%%3.1d%7s|', 1, length(obj.(field))), '\n'],tmp{:});
0030 fprintf(stmp, cellfun(@(x) x.gen, obj.(field)));
0031 fprintf(['Success flag              |', repmat('%10.1d|',1, length(obj.(field))), '\n'],...
0032     cellfun(@(x) double(x.mpc.success), obj.(field)));
0033 fprintf(['Objective                 |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0034     cellfun(@(x) x.mpc.f, obj.(field)));
0035 fprintf(['---------------------     |', repmat('      ----|', 1, length(obj.(field))), '\n']);
0036 tmpcost = zeros(1, length(obj.(field)));
0037 fprintf(['  Generation Cost         |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0038     cellfun(@(x) sum(totcost(x.mpc.gencost, x.mpc.gen(:, 2))), obj.(field)));
0039 tmpcost = tmpcost + cellfun(@(x) sum(totcost(x.mpc.gencost, x.mpc.gen(:, 2))), obj.(field));
0040 if isfield(obj.(field){1}.mpc, 'softlims')
0041     fprintf(['  Line Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0042         cellfun(@(x) x.mpc.softlims.RATE_A.cost(1)*sum(x.mpc.softlims.RATE_A.overload), obj.(field)));
0043      tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.RATE_A.cost(1)*sum(x.mpc.softlims.RATE_A.overload), obj.(field));
0044     fprintf(['  VMAX Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0045         cellfun(@(x) x.mpc.softlims.VMAX.cost(1)*sum(x.mpc.softlims.VMAX.overload), obj.(field)));
0046      tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.VMAX.cost(1)*sum(x.mpc.softlims.VMAX.overload), obj.(field));
0047     fprintf(['  VMIN Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0048         cellfun(@(x) x.mpc.softlims.VMIN.cost(1)*sum(x.mpc.softlims.VMIN.overload), obj.(field)));
0049      tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.VMIN.cost(1)*sum(x.mpc.softlims.VMIN.overload), obj.(field));
0050     if ~strcmp(obj.(field){1}.mpc.softlims.QMAX.hl_mod, 'none')
0051         fprintf(['  QMAX Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0052             cellfun(@(x) x.mpc.softlims.QMAX.cost(1)*sum(x.mpc.softlims.QMAX.overload), obj.(field)));
0053              tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.QMAX.cost(1)*sum(x.mpc.softlims.QMAX.overload), obj.(field));
0054         fprintf(['  QMIN Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0055             cellfun(@(x) x.mpc.softlims.QMIN.cost(1)*sum(x.mpc.softlims.QMIN.overload), obj.(field)));
0056          tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.QMIN.cost(1)*sum(x.mpc.softlims.QMIN.overload), obj.(field));
0057     end
0058      try
0059         if ~strcmp(obj.(field){1}.mpc.softlims.PMAX.hl_mod, 'none')
0060             fprintf(['  PMAX Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0061                 cellfun(@(x) x.mpc.softlims.PMAX.cost(1)*sum(x.mpc.softlims.PMAX.overload), obj.(field)));
0062                  tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.PMAX.cost(1)*sum(x.mpc.softlims.PMAX.overload), obj.(field));
0063             fprintf(['  PMIN Violation Cost     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0064                 cellfun(@(x) x.mpc.softlims.PMIN.cost(1)*sum(x.mpc.softlims.PMIN.overload), obj.(field)));
0065             tmpcost = tmpcost + cellfun(@(x) x.mpc.softlims.PMIN.cost(1)*sum(x.mpc.softlims.PMIN.overload), obj.(field));
0066         end
0067      catch
0068     end
0069 end
0070 fprintf(['---------------------     |', repmat('      ----|', 1, length(obj.(field))), '\n']);
0071 fprintf(['        Component Sum     |', repmat('%10.3g|',1, length(obj.(field))), '\n'], tmpcost);
0072 fprintf(['--------------------------|', repmat('----------|', 1, length(obj.(field))), '\n']);
0073 fprintf(['Min LMP                   |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0074     cellfun(@(x) min(x.mpc.bus(:,14)), obj.(field)));
0075 fprintf(['Max LMP                   |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0076     cellfun(@(x) max(x.mpc.bus(:,14)), obj.(field)));
0077 fprintf(['Avg LMP                   |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0078     cellfun(@(x) mean(x.mpc.bus(:,14)), obj.(field)));
0079 if isfield(obj.(field){1}.mpc, 'softlims')
0080          fprintf(['--------------------------|', repmat('----------|', 1, length(obj.(field))), '\n']);
0081     fprintf(['max line violations [MVA] |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0082         cellfun(@(x) max(x.mpc.softlims.RATE_A.overload), obj.(field)));
0083     fprintf(['# line violations         |', repmat('%10.1d|',1, length(obj.(field))), '\n'],...
0084         cellfun(@(x) sum(x.mpc.softlims.RATE_A.overload > 1e-4), obj.(field)));
0085     fprintf(['Max |V| [p.u]             |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0086         cellfun(@(x) max(x.mpc.bus(:,8)), obj.(field)));
0087     fprintf(['Min |V| [p.u]             |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0088     cellfun(@(x) min(x.mpc.bus(:,8)), obj.(field)));
0089     if ~strcmp(obj.(field){1}.mpc.softlims.QMAX.hl_mod, 'none')
0090         fprintf(['Total up MVAr support     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0091             cellfun(@(x) sum(x.mpc.softlims.QMAX.overload), obj.(field)));
0092         fprintf(['Total down MVAr support   |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0093             cellfun(@(x) sum(x.mpc.softlims.QMIN.overload), obj.(field)));
0094     end
0095      try
0096         if ~strcmp(obj.(field){1}.mpc.softlims.PMAX.hl_mod, 'none')
0097             fprintf(['Total up MW support       |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0098                 cellfun(@(x) sum(x.mpc.softlims.PMAX.overload), obj.(field)));
0099             fprintf(['Total down MW support     |', repmat('%10.3g|',1, length(obj.(field))), '\n'],...
0100                 cellfun(@(x) sum(x.mpc.softlims.PMIN.overload), obj.(field)));
0101         end
0102     catch
0103     end
0104 end
0105 fprintf(['===========================', repmat('===========', 1, length(obj.(field))), '\n']);
0106 end

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