Home > matpower5.1 > t > t_printpf.m

t_printpf

PURPOSE ^

T_PRINTPF Tests for PRINTPF.

SYNOPSIS ^

function t_printpf(quiet)

DESCRIPTION ^

T_PRINTPF  Tests for PRINTPF.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_printpf(quiet)
0002 %T_PRINTPF  Tests for PRINTPF.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2014-2015 by Power System Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   $Id: t_printpf.m 2662 2015-03-20 20:02:08Z ray $
0009 %
0010 %   This file is part of MATPOWER.
0011 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0012 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0013 
0014 if nargin < 1
0015     quiet = 0;
0016 end
0017 
0018 num_tests = 2;
0019 
0020 t_begin(num_tests, quiet);
0021 
0022 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0023     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0024     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0025 
0026 casefile = 't_auction_case';
0027 if quiet
0028     verbose = 0;
0029 else
0030     verbose = 0;
0031 end
0032 if have_fcn('octave')
0033     if have_fcn('octave', 'vnum') >= 4
0034         file_in_path_warn_id = 'Octave:data-file-in-path';
0035     else
0036         file_in_path_warn_id = 'Octave:fopen-file-in-path';
0037     end
0038     s1 = warning('query', file_in_path_warn_id);
0039     warning('off', file_in_path_warn_id);
0040 end
0041 
0042 t = 'printpf : ';
0043 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0044         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0045 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose);
0046 mpopt = mpoption(mpopt, 'out.sys_sum', 1);
0047 mpopt = mpoption(mpopt, 'out.area_sum', 1);
0048 mpopt = mpoption(mpopt, 'out.bus', 1);
0049 mpopt = mpoption(mpopt, 'out.branch', 1);
0050 mpopt = mpoption(mpopt, 'out.gen', 1);
0051 mpopt = mpoption(mpopt, 'out.lim.all', 2);
0052 mpopt = mpoption(mpopt, 'opf.ac.solver', 'MIPS');
0053 mpopt = mpoption(mpopt, 'opf.dc.solver', 'MIPS');
0054 
0055 %% load case
0056 mpc = loadcase(casefile);
0057 mpc.gencost(1:5, 1:7) = ones(5, 1) * [2 0 0 3 0.1 45 0];
0058 mpc.branch(18, RATE_A) = 25;
0059 
0060 %% set up file names
0061 [pathstr, name, ext] = fileparts(which('t_printpf'));
0062 
0063 fnameac = 'pretty_print_acopf.txt';
0064 fnamedc = 'pretty_print_dcopf.txt';
0065 fname = 'pretty_print';
0066 rn = fix(1e9*rand);
0067 tmpfnameac = sprintf('%s_acopf_%d.txt', fname, rn);
0068 tmpfnamedc = sprintf('%s_dcopf_%d.txt', fname, rn);
0069 
0070 r = runopf(mpc, mpopt, tmpfnameac);
0071 got = fileread(tmpfnameac);
0072 if size(got, 1) ~= 1    %% transpose if needed for Octave 3.4
0073     got = got';
0074 end
0075 got = strrep(got, char([13 10]), char(10));             %% Win to Unix EOL chars
0076 got = regexprep(got, 'Converged in (.*) seconds', 'Converged in 0.00 seconds');
0077 got = strrep(got, ' -0.0 ', '  0.0 ');
0078 got = strrep(got, sprintf(' -0.0\n'), sprintf('  0.0\n'));
0079 got = strrep(got, ' -0.00 ', '  0.00 ');
0080 got = strrep(got, sprintf(' -0.00\n'), sprintf('  0.00\n'));
0081 got = strrep(got, ' -0.000 ', '  0.000 ');
0082 got = strrep(got, ' -0.000*', '  0.000*');
0083 expected = fileread(fnameac);
0084 expected = strrep(expected, char([13 10]), char(10));   %% Win to Unix EOL chars
0085 if size(expected, 1) ~= 1   %% transpose if needed for Octave 3.4
0086     expected = expected';
0087 end
0088 t_ok(strcmp(got, expected), [t 'standard AC OPF']);
0089 delete(tmpfnameac);
0090 
0091 r = rundcopf(mpc, mpopt, tmpfnamedc);
0092 got = fileread(tmpfnamedc);
0093 if size(got, 1) ~= 1    %% transpose if needed for Octave 3.4
0094     got = got';
0095 end
0096 got = strrep(got, char([13 10]), char(10));             %% Win to Unix EOL chars
0097 got = regexprep(got, 'Converged in (.*) seconds', 'Converged in 0.00 seconds');
0098 got = strrep(got, ' -0.0 ', '  0.0 ');
0099 got = strrep(got, sprintf(' -0.0\n'), sprintf('  0.0\n'));
0100 got = strrep(got, ' -0.00 ', '  0.00 ');
0101 got = strrep(got, sprintf(' -0.00\n'), sprintf('  0.00\n'));
0102 got = strrep(got, ' -0.000 ', '  0.000 ');
0103 got = strrep(got, ' -0.000*', '  0.000*');
0104 got = strrep(got, '51.66 $/MWh @ bus 12', '51.66 $/MWh @ bus 13');
0105 got = strrep(got, '51.66 $/MWh @ bus 16', '51.66 $/MWh @ bus 13');
0106 got = strrep(got, '51.66 $/MWh @ bus 17', '51.66 $/MWh @ bus 13');
0107 got = strrep(got, '53.05 $/MWh @ bus 18', '53.05 $/MWh @ bus 15');
0108 got = strrep(got, '53.05 $/MWh @ bus 19', '53.05 $/MWh @ bus 15');
0109 got = strrep(got, '53.05 $/MWh @ bus 20', '53.05 $/MWh @ bus 15');
0110 expected = fileread(fnamedc);
0111 expected = strrep(expected, char([13 10]), char(10));   %% Win to Unix EOL chars
0112 if size(expected, 1) ~= 1   %% transpose if needed for Octave 3.4
0113     expected = expected';
0114 end
0115 t_ok(strcmp(got, expected), [t 'standard DC OPF']);
0116 delete(tmpfnamedc);
0117 
0118 if have_fcn('octave')
0119     warning(s1.state, file_in_path_warn_id);
0120 end
0121 
0122 t_end;

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