Home > matpower6.0 > printpf.m

printpf

PURPOSE ^

PRINTPF Prints power flow results.

SYNOPSIS ^

function printpf(baseMVA, bus, gen, branch, f, success, et, fd, mpopt)

DESCRIPTION ^

PRINTPF   Prints power flow results.
   PRINTPF(RESULTS, FD, MPOPT)
   PRINTPF(BASEMVA, BUS, GEN, BRANCH, F, SUCCESS, ET, FD, MPOPT)

   Prints power flow and optimal power flow results to FD (a file
   descriptor which defaults to STDOUT), with the details of what
   gets printed controlled by the optional MPOPT argument, which is a
   MATPOWER options struct (see MPOPTION for details).

   The data can either be supplied in a single RESULTS struct, or
   in the individual arguments: BASEMVA, BUS, GEN, BRANCH, F, SUCCESS
   and ET, where F is the OPF objective function value, SUCCESS is
   true if the solution converged and false otherwise, and ET is the
   elapsed time for the computation in seconds. If F is given, it is
   assumed that the output is from an OPF run, otherwise it is assumed
   to be a simple power flow run.

   Examples:
       mpopt = mpoptions('out.gen', 1, 'out.bus', 0, 'out.branch', 0);
       [fd, msg] = fopen(fname, 'at');
       results = runopf(mpc);
       printpf(results);
       printpf(results, fd);
       printpf(results, fd, mpopt);
       printpf(baseMVA, bus, gen, branch, f, success, et);
       printpf(baseMVA, bus, gen, branch, f, success, et, fd);
       printpf(baseMVA, bus, gen, branch, f, success, et, fd, mpopt);
       fclose(fd);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function printpf(baseMVA, bus, gen, branch, f, success, et, fd, mpopt)
0002 %PRINTPF   Prints power flow results.
0003 %   PRINTPF(RESULTS, FD, MPOPT)
0004 %   PRINTPF(BASEMVA, BUS, GEN, BRANCH, F, SUCCESS, ET, FD, MPOPT)
0005 %
0006 %   Prints power flow and optimal power flow results to FD (a file
0007 %   descriptor which defaults to STDOUT), with the details of what
0008 %   gets printed controlled by the optional MPOPT argument, which is a
0009 %   MATPOWER options struct (see MPOPTION for details).
0010 %
0011 %   The data can either be supplied in a single RESULTS struct, or
0012 %   in the individual arguments: BASEMVA, BUS, GEN, BRANCH, F, SUCCESS
0013 %   and ET, where F is the OPF objective function value, SUCCESS is
0014 %   true if the solution converged and false otherwise, and ET is the
0015 %   elapsed time for the computation in seconds. If F is given, it is
0016 %   assumed that the output is from an OPF run, otherwise it is assumed
0017 %   to be a simple power flow run.
0018 %
0019 %   Examples:
0020 %       mpopt = mpoptions('out.gen', 1, 'out.bus', 0, 'out.branch', 0);
0021 %       [fd, msg] = fopen(fname, 'at');
0022 %       results = runopf(mpc);
0023 %       printpf(results);
0024 %       printpf(results, fd);
0025 %       printpf(results, fd, mpopt);
0026 %       printpf(baseMVA, bus, gen, branch, f, success, et);
0027 %       printpf(baseMVA, bus, gen, branch, f, success, et, fd);
0028 %       printpf(baseMVA, bus, gen, branch, f, success, et, fd, mpopt);
0029 %       fclose(fd);
0030 
0031 %   MATPOWER
0032 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0033 %   by Ray Zimmerman, PSERC Cornell
0034 %
0035 %   This file is part of MATPOWER.
0036 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0037 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0038 
0039 %%----- initialization -----
0040 %% define named indices into bus, gen, branch matrices
0041 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0042     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0043 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0044     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0045     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0046 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0047     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0048     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0049 
0050 %% default arguments
0051 if isstruct(baseMVA)
0052     have_results_struct = 1;
0053     results = baseMVA;
0054     if nargin < 3 || isempty(gen)
0055         mpopt = mpoption;   %% use default options
0056     else
0057         mpopt = gen;
0058     end
0059     if mpopt.out.all == 0
0060         return;         %% nothin' to see here, bail out now
0061     end
0062     if nargin < 2 || isempty(bus)
0063         fd = 1;         %% print to stdio by default
0064     else
0065         fd = bus;
0066     end
0067     [baseMVA, bus, gen, branch, success, et] = ...
0068         deal(results.baseMVA, results.bus, results.gen, results.branch, ...
0069             results.success, results.et);
0070     if isfield(results, 'f') && ~isempty(results.f)
0071         f = results.f;
0072     else
0073         f = [];
0074     end
0075 else
0076     have_results_struct = 0;
0077     if nargin < 9
0078         mpopt = mpoption;   %% use default options
0079         if nargin < 8
0080             fd = 1;         %% print to stdio by default
0081         end
0082     end
0083     if mpopt.out.all == 0
0084         return;         %% nothin' to see here, bail out now
0085     end
0086 end
0087 isOPF = ~isempty(f);    %% FALSE -> only simple PF data, TRUE -> OPF data
0088 
0089 %% options
0090 isDC            = strcmp(upper(mpopt.model), 'DC');
0091 
0092 SUPPRESS        = mpopt.out.suppress_detail;
0093 if SUPPRESS == -1
0094     if size(bus, 1) > 500
0095         SUPPRESS = 1;
0096     else
0097         SUPPRESS = 0;
0098     end
0099 end
0100 OUT_ALL         = mpopt.out.all;
0101 OUT_FORCE       = mpopt.out.force;
0102 OUT_ANY         = OUT_ALL == 1;     %% set to true if any pretty output is to be generated
0103 OUT_SYS_SUM     = OUT_ALL == 1 || (OUT_ALL == -1 && mpopt.out.sys_sum);
0104 OUT_AREA_SUM    = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.area_sum);
0105 OUT_BUS         = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.bus);
0106 OUT_BRANCH      = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.branch);
0107 OUT_GEN         = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.gen);
0108 OUT_ANY         = OUT_ANY || (OUT_ALL == -1 && ...
0109                     (OUT_SYS_SUM || OUT_AREA_SUM || OUT_BUS || ...
0110                     OUT_BRANCH || OUT_GEN));
0111 if OUT_ALL == -1
0112     OUT_ALL_LIM = ~SUPPRESS * mpopt.out.lim.all;
0113 elseif OUT_ALL == 1
0114     OUT_ALL_LIM = 2;
0115 else
0116     OUT_ALL_LIM = 0;
0117 end
0118 OUT_ANY         = OUT_ANY || OUT_ALL_LIM >= 1;
0119 if OUT_ALL_LIM == -1
0120     OUT_V_LIM       = ~SUPPRESS * mpopt.out.lim.v;
0121     OUT_LINE_LIM    = ~SUPPRESS * mpopt.out.lim.line;
0122     OUT_PG_LIM      = ~SUPPRESS * mpopt.out.lim.pg;
0123     OUT_QG_LIM      = ~SUPPRESS * mpopt.out.lim.qg;
0124 else
0125     OUT_V_LIM       = OUT_ALL_LIM;
0126     OUT_LINE_LIM    = OUT_ALL_LIM;
0127     OUT_PG_LIM      = OUT_ALL_LIM;
0128     OUT_QG_LIM      = OUT_ALL_LIM;
0129 end
0130 OUT_ANY         = OUT_ANY || (OUT_ALL_LIM == -1 && (OUT_V_LIM || OUT_LINE_LIM || OUT_PG_LIM || OUT_QG_LIM));
0131 
0132 %%----- print the stuff -----
0133 if OUT_ANY
0134     ptol = 1e-4;        %% tolerance for displaying shadow prices
0135     if isOPF && ~isDC && strcmp(upper(mpopt.opf.ac.solver), 'SDPOPF')
0136         isSDP = 1;
0137         ptol = 0.1;     %% tolerance for displaying shadow prices
0138         if have_results_struct && isfield(results, 'mineigratio') && ~isempty(results.mineigratio)
0139             mineigratio = results.mineigratio;
0140         else
0141             mineigratio = [];
0142         end
0143         if have_results_struct && isfield(results, 'zero_eval') && ~isempty(results.zero_eval)
0144             zero_eval = results.zero_eval;
0145         else
0146             zero_eval = [];
0147         end
0148     else
0149         isSDP = 0;
0150     end
0151 
0152     %% create map of external bus numbers to bus indices
0153     i2e = bus(:, BUS_I);
0154     e2i = sparse(max(i2e), 1);
0155     e2i(i2e) = (1:size(bus, 1))';
0156 
0157     %% sizes of things
0158     nb = size(bus, 1);      %% number of buses
0159     nl = size(branch, 1);   %% number of branches
0160     ng = size(gen, 1);      %% number of generators
0161 
0162     %% zero out some data to make printout consistent for DC case
0163     if isDC
0164         bus(:, [QD, BS])            = zeros(nb, 2);
0165         gen(:, [QG, QMAX, QMIN])    = zeros(ng, 3);
0166         branch(:, [BR_R, BR_B])     = zeros(nl, 2);
0167     end
0168 
0169     %% parameters
0170     ties = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) ~= bus(e2i(branch(:, T_BUS)), BUS_AREA));
0171                             %% area inter-ties
0172     xfmr = find(branch(:, TAP));                    %% indices of transformers
0173     nzld = find((bus(:, PD) | bus(:, QD)) & bus(:, BUS_TYPE) ~= NONE);
0174     sorted_areas = sort(bus(:, BUS_AREA));
0175     s_areas = sorted_areas([1; find(diff(sorted_areas))+1]);    %% area numbers
0176     nzsh = find((bus(:, GS) | bus(:, BS)) & bus(:, BUS_TYPE) ~= NONE);
0177     allg = find( ~isload(gen) );
0178     alld = find(  isload(gen) );
0179     ong  = find( gen(:, GEN_STATUS) > 0 & ~isload(gen) );
0180     onld = find( gen(:, GEN_STATUS) > 0 &  isload(gen) );
0181     V = bus(:, VM) .* exp(sqrt(-1) * pi/180 * bus(:, VA));
0182     opt = struct('type', 'FIXED');
0183     [Pdf, Qdf] = total_load(bus, gen, 'bus', struct('type', 'FIXED'), mpopt);
0184     [Pdd, Qdd] = total_load(bus, gen, 'bus', struct('type', 'DISPATCHABLE'), mpopt);
0185     if isDC
0186         loss = zeros(nl, 1);
0187         fchg = loss;
0188         tchg = loss;
0189     else
0190         [loss, fchg, tchg] = get_losses(baseMVA, bus, branch);
0191     end
0192 
0193     %% convergence & elapsed time
0194     if success
0195         if isSDP
0196             fprintf(fd, '\nSolution satisfies rank and consistency conditions, %.2f seconds.\nmineigratio = %0.5g, zero_eval = %0.5g', et, mineigratio, zero_eval);
0197         else
0198             fprintf(fd, '\nConverged in %.2f seconds', et);
0199         end
0200     else
0201         if isSDP
0202             fprintf(fd, '\n>>>>>  Solution does NOT satisfy rank and/or consistency conditions (%.2f seconds).  <<<<<\nmineigratio = %0.5g, zero_eval = %0.5g\n', et, mineigratio, zero_eval);
0203         else
0204             fprintf(fd, '\n>>>>>  Did NOT converge (%.2f seconds)  <<<<<\n', et);
0205         end
0206     end
0207 
0208     %% objective function value
0209     if isOPF && (success || OUT_FORCE)
0210         fprintf(fd, '\nObjective Function Value = %.2f $/hr', f);
0211     end
0212 end
0213 if OUT_SYS_SUM && (success || OUT_FORCE)
0214     fprintf(fd, '\n================================================================================');
0215     fprintf(fd, '\n|     System Summary                                                           |');
0216     fprintf(fd, '\n================================================================================');
0217     fprintf(fd, '\n\nHow many?                How much?              P (MW)            Q (MVAr)');
0218     fprintf(fd, '\n---------------------    -------------------  -------------  -----------------');
0219     fprintf(fd, '\nBuses         %6d     Total Gen Capacity   %7.1f       %7.1f to %.1f', nb, sum(gen(allg, PMAX)), sum(gen(allg, QMIN)), sum(gen(allg, QMAX)));
0220     fprintf(fd, '\nGenerators     %5d     On-line Capacity     %7.1f       %7.1f to %.1f', length(allg), sum(gen(ong, PMAX)), sum(gen(ong, QMIN)), sum(gen(ong, QMAX)));
0221     fprintf(fd, '\nCommitted Gens %5d     Generation (actual)  %7.1f           %7.1f', length(ong), sum(gen(ong, PG)), sum(gen(ong, QG)));
0222     fprintf(fd, '\nLoads          %5d     Load                 %7.1f           %7.1f', length(nzld)+length(onld), sum(Pdf(nzld))-sum(gen(onld, PG)), sum(Qdf(nzld))-sum(gen(onld, QG)));
0223     fprintf(fd, '\n  Fixed        %5d       Fixed              %7.1f           %7.1f', length(nzld), sum(Pdf(nzld)), sum(Qdf(nzld)));
0224     fprintf(fd, '\n  Dispatchable %5d       Dispatchable       %7.1f of %-7.1f%7.1f', length(onld), -sum(gen(onld, PG)), -sum(gen(onld, PMIN)), -sum(gen(onld, QG)));
0225     fprintf(fd, '\nShunts         %5d     Shunt (inj)          %7.1f           %7.1f', length(nzsh), ...
0226         -sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, GS)), sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, BS)) );
0227     fprintf(fd, '\nBranches       %5d     Losses (I^2 * Z)     %8.2f          %8.2f', nl, sum(real(loss)), sum(imag(loss)) );
0228     fprintf(fd, '\nTransformers   %5d     Branch Charging (inj)     -            %7.1f', length(xfmr), sum(fchg) + sum(tchg) );
0229     fprintf(fd, '\nInter-ties     %5d     Total Inter-tie Flow %7.1f           %7.1f', length(ties), sum(abs(branch(ties, PF)-branch(ties, PT))) / 2, sum(abs(branch(ties, QF)-branch(ties, QT))) / 2);
0230     fprintf(fd, '\nAreas          %5d', length(s_areas));
0231     fprintf(fd, '\n');
0232     fprintf(fd, '\n                          Minimum                      Maximum');
0233     fprintf(fd, '\n                 -------------------------  --------------------------------');
0234     [minv, mini] = min(bus(:, VM));
0235     [maxv, maxi] = max(bus(:, VM));
0236     fprintf(fd, '\nVoltage Magnitude %7.3f p.u. @ bus %-4d     %7.3f p.u. @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0237     [minv, mini] = min(bus(:, VA));
0238     [maxv, maxi] = max(bus(:, VA));
0239     fprintf(fd, '\nVoltage Angle   %8.2f deg   @ bus %-4d   %8.2f deg   @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0240     if ~isDC
0241         [maxv, maxi] = max(real(loss));
0242         fprintf(fd, '\nP Losses (I^2*R)             -              %8.2f MW    @ line %d-%d', maxv, branch(maxi, F_BUS), branch(maxi, T_BUS));
0243         [maxv, maxi] = max(imag(loss));
0244         fprintf(fd, '\nQ Losses (I^2*X)             -              %8.2f MVAr  @ line %d-%d', maxv, branch(maxi, F_BUS), branch(maxi, T_BUS));
0245     end
0246     if isOPF
0247         [minv, mini] = min(bus(:, LAM_P));
0248         [maxv, maxi] = max(bus(:, LAM_P));
0249         fprintf(fd, '\nLambda P        %8.2f $/MWh @ bus %-4d   %8.2f $/MWh @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0250         [minv, mini] = min(bus(:, LAM_Q));
0251         [maxv, maxi] = max(bus(:, LAM_Q));
0252         fprintf(fd, '\nLambda Q        %8.2f $/MWh @ bus %-4d   %8.2f $/MWh @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0253     end
0254     fprintf(fd, '\n');
0255 end
0256 
0257 if OUT_AREA_SUM && (success || OUT_FORCE)
0258     fprintf(fd, '\n================================================================================');
0259     fprintf(fd, '\n|     Area Summary                                                             |');
0260     fprintf(fd, '\n================================================================================');
0261     fprintf(fd, '\nArea  # of      # of Gens        # of Loads         # of    # of   # of   # of');
0262     fprintf(fd, '\n Num  Buses   Total  Online   Total  Fixed  Disp    Shunt   Brchs  Xfmrs   Ties');
0263     fprintf(fd, '\n----  -----   -----  ------   -----  -----  -----   -----   -----  -----  -----');
0264     for i=1:length(s_areas)
0265         a = s_areas(i);
0266         ib = find(bus(:, BUS_AREA) == a);
0267         ig = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & ~isload(gen));
0268         igon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & ~isload(gen));
0269         ildon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & isload(gen));
0270         inzld = find(bus(:, BUS_AREA) == a & (Pdf | Qdf) & bus(:, BUS_TYPE) ~= NONE);
0271         inzsh = find(bus(:, BUS_AREA) == a & (bus(:, GS) | bus(:, BS)) & bus(:, BUS_TYPE) ~= NONE);
0272         ibrch = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a);
0273         in_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) ~= a);
0274         out_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) ~= a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a);
0275         if isempty(xfmr)
0276             nxfmr = 0;
0277         else
0278             nxfmr = length(find(bus(e2i(branch(xfmr, F_BUS)), BUS_AREA) == a & bus(e2i(branch(xfmr, T_BUS)), BUS_AREA) == a));
0279         end
0280         fprintf(fd, '\n%3d  %6d   %5d  %5d   %5d  %5d  %5d   %5d   %5d  %5d  %5d', ...
0281             a, length(ib), length(ig), length(igon), ...
0282             length(inzld)+length(ildon), length(inzld), length(ildon), ...
0283             length(inzsh), length(ibrch), nxfmr, length(in_tie)+length(out_tie));
0284     end
0285     fprintf(fd, '\n----  -----   -----  ------   -----  -----  -----   -----   -----  -----  -----');
0286     fprintf(fd, '\nTot: %6d   %5d  %5d   %5d  %5d  %5d   %5d   %5d  %5d  %5d', ...
0287         nb, length(allg), length(ong), length(nzld)+length(onld), ...
0288         length(nzld), length(onld), length(nzsh), nl, length(xfmr), length(ties));
0289     fprintf(fd, '\n');
0290     fprintf(fd, '\nArea      Total Gen Capacity           On-line Gen Capacity         Generation');
0291     fprintf(fd, '\n Num     MW           MVAr            MW           MVAr             MW    MVAr');
0292     fprintf(fd, '\n----   ------  ------------------   ------  ------------------    ------  ------');
0293     for i=1:length(s_areas)
0294         a = s_areas(i);
0295         ig = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & ~isload(gen));
0296         igon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & ~isload(gen));
0297         fprintf(fd, '\n%3d   %7.1f  %7.1f to %-7.1f  %7.1f  %7.1f to %-7.1f   %7.1f %7.1f', ...
0298             a, sum(gen(ig, PMAX)), sum(gen(ig, QMIN)), sum(gen(ig, QMAX)), ...
0299             sum(gen(igon, PMAX)), sum(gen(igon, QMIN)), sum(gen(igon, QMAX)), ...
0300             sum(gen(igon, PG)), sum(gen(igon, QG)) );
0301     end
0302     fprintf(fd, '\n----   ------  ------------------   ------  ------------------    ------  ------');
0303     fprintf(fd, '\nTot:  %7.1f  %7.1f to %-7.1f  %7.1f  %7.1f to %-7.1f   %7.1f %7.1f', ...
0304             sum(gen(allg, PMAX)), sum(gen(allg, QMIN)), sum(gen(allg, QMAX)), ...
0305             sum(gen(ong, PMAX)), sum(gen(ong, QMIN)), sum(gen(ong, QMAX)), ...
0306             sum(gen(ong, PG)), sum(gen(ong, QG)) );
0307     fprintf(fd, '\n');
0308     fprintf(fd, '\nArea    Disp Load Cap       Disp Load         Fixed Load        Total Load');
0309     fprintf(fd, '\n Num      MW     MVAr       MW     MVAr       MW     MVAr       MW     MVAr');
0310     fprintf(fd, '\n----    ------  ------    ------  ------    ------  ------    ------  ------');
0311     Qlim = (gen(:, QMIN) == 0) .* gen(:, QMAX) + (gen(:, QMAX) == 0) .* gen(:, QMIN);
0312     for i=1:length(s_areas)
0313         a = s_areas(i);
0314         ildon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & isload(gen));
0315         inzld = find(bus(:, BUS_AREA) == a & (Pdf | Qdf));
0316         fprintf(fd, '\n%3d    %7.1f %7.1f   %7.1f %7.1f   %7.1f %7.1f   %7.1f %7.1f', ...
0317             a, -sum(gen(ildon, PMIN)), ...
0318             -sum(Qlim(ildon)), ...
0319             -sum(gen(ildon, PG)), -sum(gen(ildon, QG)), ...
0320             sum(Pdf(inzld)), sum(Qdf(inzld)), ...
0321             -sum(gen(ildon, PG)) + sum(Pdf(inzld)), ...
0322             -sum(gen(ildon, QG)) + sum(Qdf(inzld)) );
0323     end
0324     fprintf(fd, '\n----    ------  ------    ------  ------    ------  ------    ------  ------');
0325     fprintf(fd, '\nTot:   %7.1f %7.1f   %7.1f %7.1f   %7.1f %7.1f   %7.1f %7.1f', ...
0326             -sum(gen(onld, PMIN)), ...
0327             -sum(Qlim(onld)), ...
0328             -sum(gen(onld, PG)), -sum(gen(onld, QG)), ...
0329             sum(Pdf(nzld)), sum(Qdf(nzld)), ...
0330             -sum(gen(onld, PG)) + sum(Pdf(nzld)), ...
0331             -sum(gen(onld, QG)) + sum(Qdf(nzld)) );
0332     fprintf(fd, '\n');
0333     fprintf(fd, '\nArea      Shunt Inj        Branch      Series Losses      Net Export');
0334     fprintf(fd, '\n Num      MW     MVAr     Charging      MW     MVAr       MW     MVAr');
0335     fprintf(fd, '\n----    ------  ------    --------    ------  ------    ------  ------');
0336     for i=1:length(s_areas)
0337         a = s_areas(i);
0338         inzsh = find(bus(:, BUS_AREA) == a & (bus(:, GS) | bus(:, BS)));
0339         ibrch = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a & branch(:, BR_STATUS));
0340         in_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) ~= a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a & branch(:, BR_STATUS));
0341         out_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) ~= a & branch(:, BR_STATUS));
0342         fprintf(fd, '\n%3d    %7.1f %7.1f    %7.1f    %7.2f %7.2f   %7.1f %7.1f', ...
0343             a, -sum(bus(inzsh, VM) .^ 2 .* bus(inzsh, GS)), ...
0344             sum(bus(inzsh, VM) .^ 2 .* bus(inzsh, BS)), ...
0345             sum(fchg(ibrch)) + sum(tchg(ibrch)) + sum(fchg(out_tie)) + sum(tchg(in_tie)), ...
0346             sum(real(loss(ibrch))) + sum(real(loss([in_tie; out_tie]))) / 2, ...
0347             sum(imag(loss(ibrch))) + sum(imag(loss([in_tie; out_tie]))) / 2, ...
0348             sum(branch(in_tie, PT))+sum(branch(out_tie, PF)) - sum(real(loss([in_tie; out_tie]))) / 2, ...
0349             sum(branch(in_tie, QT))+sum(branch(out_tie, QF)) - sum(imag(loss([in_tie; out_tie]))) / 2  );
0350     end
0351     fprintf(fd, '\n----    ------  ------    --------    ------  ------    ------  ------');
0352     fprintf(fd, '\nTot:   %7.1f %7.1f    %7.1f    %7.2f %7.2f       -       -', ...
0353         -sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, GS)), ...
0354         sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, BS)), ...
0355         sum(fchg) + sum(tchg), sum(real(loss)), sum(imag(loss)) );
0356     fprintf(fd, '\n');
0357 end
0358 
0359 %% generator data
0360 if OUT_GEN && (success || OUT_FORCE)
0361     if isOPF
0362         genlamP = bus(e2i(gen(:, GEN_BUS)), LAM_P);
0363         genlamQ = bus(e2i(gen(:, GEN_BUS)), LAM_Q);
0364     end
0365     fprintf(fd, '\n================================================================================');
0366     fprintf(fd, '\n|     Generator Data                                                           |');
0367     fprintf(fd, '\n================================================================================');
0368     fprintf(fd, '\n Gen   Bus   Status     Pg        Qg   ');
0369     if isOPF, fprintf(fd, '   Lambda ($/MVA-hr)'); end
0370     fprintf(fd, '\n  #     #              (MW)     (MVAr) ');
0371     if isOPF, fprintf(fd, '     P         Q    '); end
0372     fprintf(fd, '\n----  -----  ------  --------  --------');
0373     if isOPF, fprintf(fd, '  --------  --------'); end
0374     for k = 1:length(allg)
0375         i = allg(k);
0376         fprintf(fd, '\n%3d %6d     %2d ', i, gen(i, GEN_BUS), gen(i, GEN_STATUS));
0377         if gen(i, GEN_STATUS) > 0 && (gen(i, PG) || gen(i, QG))
0378             fprintf(fd, '%10.2f%10.2f', gen(i, PG), gen(i, QG));
0379         else
0380             fprintf(fd, '       -         -  ');
0381         end
0382         if isOPF, fprintf(fd, '%10.2f%10.2f', genlamP(i), genlamQ(i)); end
0383     end
0384     fprintf(fd, '\n                     --------  --------');
0385     fprintf(fd, '\n            Total: %9.2f%10.2f', sum(gen(ong, PG)), sum(gen(ong, QG)));
0386     fprintf(fd, '\n');
0387     if ~isempty(alld)
0388         fprintf(fd, '\n================================================================================');
0389         fprintf(fd, '\n|     Dispatchable Load Data                                                   |');
0390         fprintf(fd, '\n================================================================================');
0391         fprintf(fd, '\n Gen   Bus   Status     Pd        Qd   ');
0392         if isOPF, fprintf(fd, '   Lambda ($/MVA-hr)'); end
0393         fprintf(fd, '\n  #     #              (MW)     (MVAr) ');
0394         if isOPF, fprintf(fd, '     P         Q    '); end
0395         fprintf(fd, '\n----  -----  ------  --------  --------');
0396         if isOPF, fprintf(fd, '  --------  --------'); end
0397         for k = 1:length(alld)
0398             i = alld(k);
0399             fprintf(fd, '\n%3d %6d     %2d ', i, gen(i, GEN_BUS), gen(i, GEN_STATUS));
0400             if gen(i, GEN_STATUS) > 0 && (gen(i, PG) || gen(i, QG))
0401                 fprintf(fd, '%10.2f%10.2f', -gen(i, PG), -gen(i, QG));
0402             else
0403                 fprintf(fd, '       -         -  ');
0404             end
0405             if isOPF, fprintf(fd, '%10.2f%10.2f', genlamP(i), genlamQ(i)); end
0406         end
0407         fprintf(fd, '\n                     --------  --------');
0408         fprintf(fd, '\n            Total: %9.2f%10.2f', -sum(gen(onld, PG)), -sum(gen(onld, QG)));
0409         fprintf(fd, '\n');
0410     end
0411 end
0412 
0413 %% bus data
0414 if OUT_BUS && (success || OUT_FORCE)
0415     fprintf(fd, '\n================================================================================');
0416     fprintf(fd, '\n|     Bus Data                                                                 |');
0417     fprintf(fd, '\n================================================================================');
0418     fprintf(fd, '\n Bus      Voltage          Generation             Load        ');
0419     if isOPF, fprintf(fd, '  Lambda($/MVA-hr)'); end
0420     fprintf(fd, '\n  #   Mag(pu) Ang(deg)   P (MW)   Q (MVAr)   P (MW)   Q (MVAr)');
0421     if isOPF, fprintf(fd, '     P        Q   '); end
0422     fprintf(fd, '\n----- ------- --------  --------  --------  --------  --------');
0423     if isOPF, fprintf(fd, '  -------  -------'); end
0424     for i = 1:nb
0425         fprintf(fd, '\n%5d%7.3f%9.3f', bus(i, [BUS_I, VM, VA]));
0426         if bus(i, BUS_TYPE) == REF
0427             fprintf(fd, '*');
0428         elseif bus(i, BUS_TYPE) == NONE
0429             fprintf(fd, 'x');
0430         else
0431             fprintf(fd, ' ');
0432         end
0433         g  = find(gen(:, GEN_STATUS) > 0 & gen(:, GEN_BUS) == bus(i, BUS_I) & ...
0434                     ~isload(gen));
0435         ld = find(gen(:, GEN_STATUS) > 0 & gen(:, GEN_BUS) == bus(i, BUS_I) & ...
0436                     isload(gen));
0437         if ~isempty(g)
0438             fprintf(fd, '%9.2f%10.2f', sum(gen(g, PG)), sum(gen(g, QG)));
0439         else
0440             fprintf(fd, '      -         -  ');
0441         end
0442         if Pdf(i) || Qdf(i) || ~isempty(ld)
0443             if ~isempty(ld)
0444                 fprintf(fd, '%10.2f*%9.2f*', Pdf(i) - sum(gen(ld, PG)), ...
0445                                              Qdf(i) - sum(gen(ld, QG)));
0446             else
0447                 fprintf(fd, '%10.2f%10.2f ', [ Pdf(i) Qdf(i) ]);
0448             end
0449         else
0450             fprintf(fd, '       -         -   ');
0451         end
0452         if isOPF
0453             fprintf(fd, '%9.3f', bus(i, LAM_P));
0454             if abs(bus(i, LAM_Q)) > ptol
0455                 fprintf(fd, '%8.3f', bus(i, LAM_Q));
0456             else
0457                 fprintf(fd, '     -');
0458             end
0459         end
0460     end
0461     fprintf(fd, '\n                        --------  --------  --------  --------');
0462     fprintf(fd, '\n               Total: %9.2f %9.2f %9.2f %9.2f', ...
0463         sum(gen(ong, PG)), sum(gen(ong, QG)), ...
0464         sum(Pdf(nzld)) - sum(gen(onld, PG)), ...
0465         sum(Qdf(nzld)) - sum(gen(onld, QG)));
0466     fprintf(fd, '\n');
0467 end
0468 
0469 %% branch data
0470 if OUT_BRANCH && (success || OUT_FORCE)
0471     fprintf(fd, '\n================================================================================');
0472     fprintf(fd, '\n|     Branch Data                                                              |');
0473     fprintf(fd, '\n================================================================================');
0474     fprintf(fd, '\nBrnch   From   To    From Bus Injection   To Bus Injection     Loss (I^2 * Z)  ');
0475     fprintf(fd, '\n  #     Bus    Bus    P (MW)   Q (MVAr)   P (MW)   Q (MVAr)   P (MW)   Q (MVAr)');
0476     fprintf(fd, '\n-----  -----  -----  --------  --------  --------  --------  --------  --------');
0477     fprintf(fd, '\n%4d%7d%7d%10.2f%10.2f%10.2f%10.2f%10.3f%10.2f', ...
0478             [   (1:nl)', branch(:, [F_BUS, T_BUS]), ...
0479                 branch(:, [PF, QF]), branch(:, [PT, QT]), ...
0480                 real(loss), imag(loss) ...
0481             ]');
0482     fprintf(fd, '\n                                                             --------  --------');
0483     fprintf(fd, '\n                                                    Total:%10.3f%10.2f', ...
0484             sum(real(loss)), sum(imag(loss)));
0485     fprintf(fd, '\n');
0486 end
0487 
0488 %%-----  constraint data  -----
0489 if isOPF && (success || OUT_FORCE)
0490     ctol = mpopt.opf.violation; %% constraint violation tolerance
0491     %% voltage constraints
0492     if ~isDC && (OUT_V_LIM == 2 || (OUT_V_LIM == 1 && ...
0493                          (any(bus(:, VM) < bus(:, VMIN) + ctol) || ...
0494                           any(bus(:, VM) > bus(:, VMAX) - ctol) || ...
0495                           any(bus(:, MU_VMIN) > ptol) || ...
0496                           any(bus(:, MU_VMAX) > ptol))))
0497         fprintf(fd, '\n================================================================================');
0498         fprintf(fd, '\n|     Voltage Constraints                                                      |');
0499         fprintf(fd, '\n================================================================================');
0500         fprintf(fd, '\nBus #  Vmin mu    Vmin    |V|   Vmax    Vmax mu');
0501         fprintf(fd, '\n-----  --------   -----  -----  -----   --------');
0502         for i = 1:nb
0503             if OUT_V_LIM == 2 || (OUT_V_LIM == 1 && ...
0504                          (bus(i, VM) < bus(i, VMIN) + ctol || ...
0505                           bus(i, VM) > bus(i, VMAX) - ctol || ...
0506                           bus(i, MU_VMIN) > ptol || bus(i, MU_VMAX) > ptol))
0507                 fprintf(fd, '\n%5d', bus(i, BUS_I));
0508                 if bus(i, VM) < bus(i, VMIN) + ctol || bus(i, MU_VMIN) > ptol
0509                     fprintf(fd, '%10.3f', bus(i, MU_VMIN));
0510                 else
0511                     fprintf(fd, '      -   ');
0512                 end
0513                 fprintf(fd, '%8.3f%7.3f%7.3f', bus(i, [VMIN, VM, VMAX]));
0514                 if bus(i, VM) > bus(i, VMAX) - ctol || bus(i, MU_VMAX) > ptol
0515                     fprintf(fd, '%10.3f', bus(i, MU_VMAX));
0516                 else
0517                     fprintf(fd, '      -    ');
0518                 end
0519             end
0520         end
0521         fprintf(fd, '\n');
0522     end
0523 
0524     %% generator P constraints
0525     if OUT_PG_LIM == 2 || ...
0526             (OUT_PG_LIM == 1 && (any(gen(ong, PG) < gen(ong, PMIN) + ctol) || ...
0527                                 any(gen(ong, PG) > gen(ong, PMAX) - ctol) || ...
0528                                 any(gen(ong, MU_PMIN) > ptol) || ...
0529                                 any(gen(ong, MU_PMAX) > ptol))) || ...
0530             (~isDC && (OUT_QG_LIM == 2 || ...
0531             (OUT_QG_LIM == 1 && (any(gen(ong, QG) < gen(ong, QMIN) + ctol) || ...
0532                                 any(gen(ong, QG) > gen(ong, QMAX) - ctol) || ...
0533                                 any(gen(ong, MU_QMIN) > ptol) || ...
0534                                 any(gen(ong, MU_QMAX) > ptol)))))
0535         fprintf(fd, '\n================================================================================');
0536         fprintf(fd, '\n|     Generation Constraints                                                   |');
0537         fprintf(fd, '\n================================================================================');
0538     end
0539     if OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0540                              (any(gen(ong, PG) < gen(ong, PMIN) + ctol) || ...
0541                               any(gen(ong, PG) > gen(ong, PMAX) - ctol) || ...
0542                               any(gen(ong, MU_PMIN) > ptol) || ...
0543                               any(gen(ong, MU_PMAX) > ptol)))
0544         fprintf(fd, '\n Gen   Bus                  Active Power Limits');
0545         fprintf(fd, '\n  #     #     Pmin mu     Pmin       Pg       Pmax    Pmax mu');
0546         fprintf(fd, '\n----  -----   -------   --------  --------  --------  -------');
0547         for k = 1:length(ong)
0548             i = ong(k);
0549             if OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0550                         (gen(i, PG) < gen(i, PMIN) + ctol || ...
0551                          gen(i, PG) > gen(i, PMAX) - ctol || ...
0552                          gen(i, MU_PMIN) > ptol || gen(i, MU_PMAX) > ptol))
0553                 fprintf(fd, '\n%4d%6d ', i, gen(i, GEN_BUS));
0554                 if gen(i, PG) < gen(i, PMIN) + ctol || gen(i, MU_PMIN) > ptol
0555                     fprintf(fd, '%10.3f', gen(i, MU_PMIN));
0556                 else
0557                     fprintf(fd, '      -   ');
0558                 end
0559                 if gen(i, PG)
0560                     fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [PMIN, PG, PMAX]));
0561                 else
0562                     fprintf(fd, '%10.2f       -  %10.2f', gen(i, [PMIN, PMAX]));
0563                 end
0564                 if gen(i, PG) > gen(i, PMAX) - ctol || gen(i, MU_PMAX) > ptol
0565                     fprintf(fd, '%10.3f', gen(i, MU_PMAX));
0566                 else
0567                     fprintf(fd, '      -   ');
0568                 end
0569             end
0570         end
0571         fprintf(fd, '\n');
0572     end
0573 
0574     %% generator Q constraints
0575     if ~isDC && (OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0576                              (any(gen(ong, QG) < gen(ong, QMIN) + ctol) || ...
0577                               any(gen(ong, QG) > gen(ong, QMAX) - ctol) || ...
0578                               any(gen(ong, MU_QMIN) > ptol) || ...
0579                               any(gen(ong, MU_QMAX) > ptol))))
0580         fprintf(fd, '\n Gen   Bus                 Reactive Power Limits');
0581         fprintf(fd, '\n  #     #     Qmin mu     Qmin       Qg       Qmax    Qmax mu');
0582         fprintf(fd, '\n----  -----   -------   --------  --------  --------  -------');
0583         for k = 1:length(ong)
0584             i = ong(k);
0585             if OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0586                         (gen(i, QG) < gen(i, QMIN) + ctol || ...
0587                          gen(i, QG) > gen(i, QMAX) - ctol || ...
0588                          gen(i, MU_QMIN) > ptol || gen(i, MU_QMAX) > ptol))
0589                 fprintf(fd, '\n%4d%6d ', i, gen(i, GEN_BUS));
0590                 if gen(i, QG) < gen(i, QMIN) + ctol || gen(i, MU_QMIN) > ptol
0591                     fprintf(fd, '%10.3f', gen(i, MU_QMIN));
0592                 else
0593                     fprintf(fd, '      -   ');
0594                 end
0595                 if gen(i, QG)
0596                     fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [QMIN, QG, QMAX]));
0597                 else
0598                     fprintf(fd, '%10.2f       -  %10.2f', gen(i, [QMIN, QMAX]));
0599                 end
0600                 if gen(i, QG) > gen(i, QMAX) - ctol || gen(i, MU_QMAX) > ptol
0601                     fprintf(fd, '%10.3f', gen(i, MU_QMAX));
0602                 else
0603                     fprintf(fd, '      -   ');
0604                 end
0605             end
0606         end
0607         fprintf(fd, '\n');
0608     end
0609 
0610     %% dispatchable load P constraints
0611     if ~isempty(onld) && (OUT_PG_LIM == 2 || ...
0612             (OUT_PG_LIM == 1 && (any(gen(onld, PG) < gen(onld, PMIN) + ctol) || ...
0613                                 any(gen(onld, PG) > gen(onld, PMAX) - ctol) || ...
0614                                 any(gen(onld, MU_PMIN) > ptol) || ...
0615                                 any(gen(onld, MU_PMAX) > ptol))) || ...
0616             (~isDC && (OUT_QG_LIM == 2 || ...
0617             (OUT_QG_LIM == 1 && (any(gen(onld, QG) < gen(onld, QMIN) + ctol) || ...
0618                                 any(gen(onld, QG) > gen(onld, QMAX) - ctol) || ...
0619                                 any(gen(onld, MU_QMIN) > ptol) || ...
0620                                 any(gen(onld, MU_QMAX) > ptol))))))
0621         fprintf(fd, '\n================================================================================');
0622         fprintf(fd, '\n|     Dispatchable Load Constraints                                            |');
0623         fprintf(fd, '\n================================================================================');
0624     end
0625     if ~isempty(onld) && (OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0626                              (any(gen(onld, PG) < gen(onld, PMIN) + ctol) || ...
0627                               any(gen(onld, PG) > gen(onld, PMAX) - ctol) || ...
0628                               any(gen(onld, MU_PMIN) > ptol) || ...
0629                               any(gen(onld, MU_PMAX) > ptol))))
0630         fprintf(fd, '\n Gen   Bus                  Active Power Limits');
0631         fprintf(fd, '\n  #     #     Pmin mu     Pmin       Pg       Pmax    Pmax mu');
0632         fprintf(fd, '\n----  -----   -------   --------  --------  --------  -------');
0633         for k = 1:length(onld)
0634             i = onld(k);
0635             if OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0636                         (gen(i, PG) < gen(i, PMIN) + ctol || ...
0637                          gen(i, PG) > gen(i, PMAX) - ctol || ...
0638                          gen(i, MU_PMIN) > ptol || gen(i, MU_PMAX) > ptol))
0639                 fprintf(fd, '\n%4d%6d ', i, gen(i, GEN_BUS));
0640                 if gen(i, PG) < gen(i, PMIN) + ctol || gen(i, MU_PMIN) > ptol
0641                     fprintf(fd, '%10.3f', gen(i, MU_PMIN));
0642                 else
0643                     fprintf(fd, '      -   ');
0644                 end
0645                 if gen(i, PG)
0646                     fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [PMIN, PG, PMAX]));
0647                 else
0648                     fprintf(fd, '%10.2f       -  %10.2f', gen(i, [PMIN, PMAX]));
0649                 end
0650                 if gen(i, PG) > gen(i, PMAX) - ctol || gen(i, MU_PMAX) > ptol
0651                     fprintf(fd, '%10.3f', gen(i, MU_PMAX));
0652                 else
0653                     fprintf(fd, '      -   ');
0654                 end
0655             end
0656         end
0657         fprintf(fd, '\n');
0658     end
0659 
0660     %% dispatchable load Q constraints
0661     if ~isDC && ~isempty(onld) && (OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0662                              (any(gen(onld, QG) < gen(onld, QMIN) + ctol) || ...
0663                               any(gen(onld, QG) > gen(onld, QMAX) - ctol) || ...
0664                               any(gen(onld, MU_QMIN) > ptol) || ...
0665                               any(gen(onld, MU_QMAX) > ptol))))
0666         fprintf(fd, '\n Gen   Bus                 Reactive Power Limits');
0667         fprintf(fd, '\n  #     #     Qmin mu     Qmin       Qg       Qmax    Qmax mu');
0668         fprintf(fd, '\n----  -----   -------   --------  --------  --------  -------');
0669         for k = 1:length(onld)
0670             i = onld(k);
0671             if OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0672                         (gen(i, QG) < gen(i, QMIN) + ctol || ...
0673                          gen(i, QG) > gen(i, QMAX) - ctol || ...
0674                          gen(i, MU_QMIN) > ptol || gen(i, MU_QMAX) > ptol))
0675                 fprintf(fd, '\n%4d%6d ', i, gen(i, GEN_BUS));
0676                 if gen(i, QG) < gen(i, QMIN) + ctol || gen(i, MU_QMIN) > ptol
0677                     fprintf(fd, '%10.3f', gen(i, MU_QMIN));
0678                 else
0679                     fprintf(fd, '      -   ');
0680                 end
0681                 if gen(i, QG)
0682                     fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [QMIN, QG, QMAX]));
0683                 else
0684                     fprintf(fd, '%10.2f       -  %10.2f', gen(i, [QMIN, QMAX]));
0685                 end
0686                 if gen(i, QG) > gen(i, QMAX) - ctol || gen(i, MU_QMAX) > ptol
0687                     fprintf(fd, '%10.3f', gen(i, MU_QMAX));
0688                 else
0689                     fprintf(fd, '      -   ');
0690                 end
0691             end
0692         end
0693         fprintf(fd, '\n');
0694     end
0695 
0696     %% line flow constraints
0697     if upper(mpopt.opf.flow_lim(1)) == 'P' || isDC  %% |P| limit
0698         Ff = branch(:, PF);
0699         Ft = branch(:, PT);
0700         str = '\n  #     Bus    Pf  mu     Pf      |Pmax|      Pt      Pt  mu   Bus';
0701     elseif upper(mpopt.opf.flow_lim(1)) == 'I'      %% |I| limit
0702         Ff = abs( (branch(:, PF) + 1j * branch(:, QF)) ./ V(e2i(branch(:, F_BUS))) );
0703         Ft = abs( (branch(:, PT) + 1j * branch(:, QT)) ./ V(e2i(branch(:, T_BUS))) );
0704         str = '\n  #     Bus   |If| mu    |If|     |Imax|     |It|    |It| mu   Bus';
0705     else                                            %% |S| limit
0706         Ff = abs(branch(:, PF) + 1j * branch(:, QF));
0707         Ft = abs(branch(:, PT) + 1j * branch(:, QT));
0708         str = '\n  #     Bus   |Sf| mu    |Sf|     |Smax|     |St|    |St| mu   Bus';
0709     end
0710     if any(branch(:, RATE_A) ~= 0) && (OUT_LINE_LIM == 2 || (OUT_LINE_LIM == 1 && ...
0711                         (any(abs(Ff) > branch(:, RATE_A) - ctol) || ...
0712                          any(abs(Ft) > branch(:, RATE_A) - ctol) || ...
0713                          any(branch(:, MU_SF) > ptol) || ...
0714                          any(branch(:, MU_ST) > ptol))))
0715         fprintf(fd, '\n================================================================================');
0716         fprintf(fd, '\n|     Branch Flow Constraints                                                  |');
0717         fprintf(fd, '\n================================================================================');
0718         fprintf(fd, '\nBrnch   From     "From" End        Limit       "To" End        To');
0719         fprintf(fd, str);
0720         fprintf(fd, '\n-----  -----  -------  --------  --------  --------  -------  -----');
0721         for i = 1:nl
0722             if branch(i, RATE_A) ~= 0 && (OUT_LINE_LIM == 2 || (OUT_LINE_LIM == 1 && ...
0723                    (abs(Ff(i)) > branch(i, RATE_A) - ctol || ...
0724                     abs(Ft(i)) > branch(i, RATE_A) - ctol || ...
0725                     branch(i, MU_SF) > ptol || branch(i, MU_ST) > ptol)))
0726                 fprintf(fd, '\n%4d%7d', i, branch(i, F_BUS));
0727                 if Ff(i) > branch(i, RATE_A) - ctol || branch(i, MU_SF) > ptol
0728                     fprintf(fd, '%10.3f', branch(i, MU_SF));
0729                 else
0730                     fprintf(fd, '      -   ');
0731                 end
0732                 fprintf(fd, '%9.2f%10.2f%10.2f', ...
0733                     [Ff(i), branch(i, RATE_A), Ft(i)]);
0734                 if Ft(i) > branch(i, RATE_A) - ctol || branch(i, MU_ST) > ptol
0735                     fprintf(fd, '%10.3f', branch(i, MU_ST));
0736                 else
0737                     fprintf(fd, '      -   ');
0738                 end
0739                 fprintf(fd, '%6d', branch(i, T_BUS));
0740             end
0741         end
0742         fprintf(fd, '\n');
0743     end
0744 end
0745 
0746 %% execute userfcn callbacks for 'printpf' stage
0747 if have_results_struct && isfield(results, 'userfcn') && (success || OUT_FORCE)
0748     if ~isOPF   %% turn off option for all constraints if it isn't an OPF
0749         mpopt = mpoption(mpopt, 'out.lim.all', 0);
0750     end
0751     run_userfcn(results.userfcn, 'printpf', results, fd, mpopt);
0752 end
0753 if OUT_ANY && ~success
0754     if OUT_FORCE
0755         if isSDP
0756             fprintf(fd, '\n>>>>>  Solution does NOT satisfy rank and/or consistency conditions (%.2f seconds).  <<<<<\nmineigratio = %0.5g, zero_eval = %0.5g\n', et, mineigratio, zero_eval);
0757         else
0758             fprintf(fd, '\n>>>>>  Did NOT converge (%.2f seconds)  <<<<<\n', et);
0759         end
0760     end
0761     fprintf('\n');
0762 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005