0001 function t_printpf(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 if nargin < 1
0034 quiet = 0;
0035 end
0036
0037 num_tests = 2;
0038
0039 t_begin(num_tests, quiet);
0040
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 casefile = 't_auction_case';
0046 if quiet
0047 verbose = 0;
0048 else
0049 verbose = 0;
0050 end
0051 if have_fcn('octave')
0052 s1 = warning('query', 'Octave:load-file-in-path');
0053 warning('off', 'Octave:load-file-in-path');
0054 end
0055 s2 = warning('query', 'MATLAB:singularMatrix');
0056 warning('off', 'MATLAB:singularMatrix');
0057
0058 t = 'printpf : ';
0059 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0060 'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0061 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose);
0062 mpopt = mpoption(mpopt, 'out.sys_sum', 1);
0063 mpopt = mpoption(mpopt, 'out.area_sum', 1);
0064 mpopt = mpoption(mpopt, 'out.bus', 1);
0065 mpopt = mpoption(mpopt, 'out.branch', 1);
0066 mpopt = mpoption(mpopt, 'out.gen', 1);
0067 mpopt = mpoption(mpopt, 'out.lim.all', 2);
0068 mpopt = mpoption(mpopt, 'opf.ac.solver', 'MIPS');
0069 mpopt = mpoption(mpopt, 'opf.dc.solver', 'MIPS');
0070
0071
0072 mpc = loadcase(casefile);
0073 mpc.gencost(1:5, 1:7) = ones(5, 1) * [2 0 0 3 0.1 45 0];
0074 mpc.branch(18, RATE_A) = 25;
0075
0076
0077 [pathstr, name, ext] = fileparts(which('t_printpf'));
0078
0079 fnameac = 'pretty_print_acopf.txt';
0080 fnamedc = 'pretty_print_dcopf.txt';
0081 fname = 'pretty_print';
0082 rn = fix(1e9*rand);
0083 tmpfnameac = sprintf('%s_acopf_%d.txt', fname, rn);
0084 tmpfnamedc = sprintf('%s_dcopf_%d.txt', fname, rn);
0085
0086 r = runopf(mpc, mpopt, tmpfnameac);
0087 got = fileread(tmpfnameac);
0088 if size(got, 1) ~= 1
0089 got = got';
0090 end
0091 got = strrep(got, char([13 10]), char(10));
0092 got = regexprep(got, 'Converged in (.*) seconds', 'Converged in 0.00 seconds');
0093 got = strrep(got, ' -0.0 ', ' 0.0 ');
0094 got = strrep(got, sprintf(' -0.0\n'), sprintf(' 0.0\n'));
0095 got = strrep(got, ' -0.00 ', ' 0.00 ');
0096 got = strrep(got, sprintf(' -0.00\n'), sprintf(' 0.00\n'));
0097 got = strrep(got, ' -0.000 ', ' 0.000 ');
0098 got = strrep(got, ' -0.000*', ' 0.000*');
0099 expected = fileread(fnameac);
0100 expected = strrep(expected, char([13 10]), char(10));
0101 if size(expected, 1) ~= 1
0102 expected = expected';
0103 end
0104 t_ok(strcmp(got, expected), [t 'standard AC OPF']);
0105 delete(tmpfnameac);
0106
0107 r = rundcopf(mpc, mpopt, tmpfnamedc);
0108 got = fileread(tmpfnamedc);
0109 if size(got, 1) ~= 1
0110 got = got';
0111 end
0112 got = strrep(got, char([13 10]), char(10));
0113 got = regexprep(got, 'Converged in (.*) seconds', 'Converged in 0.00 seconds');
0114 got = strrep(got, ' -0.0 ', ' 0.0 ');
0115 got = strrep(got, sprintf(' -0.0\n'), sprintf(' 0.0\n'));
0116 got = strrep(got, ' -0.00 ', ' 0.00 ');
0117 got = strrep(got, sprintf(' -0.00\n'), sprintf(' 0.00\n'));
0118 got = strrep(got, ' -0.000 ', ' 0.000 ');
0119 got = strrep(got, ' -0.000*', ' 0.000*');
0120 got = strrep(got, '51.66 $/MWh @ bus 12', '51.66 $/MWh @ bus 13');
0121 got = strrep(got, '51.66 $/MWh @ bus 16', '51.66 $/MWh @ bus 13');
0122 got = strrep(got, '51.66 $/MWh @ bus 17', '51.66 $/MWh @ bus 13');
0123 got = strrep(got, '53.05 $/MWh @ bus 18', '53.05 $/MWh @ bus 15');
0124 got = strrep(got, '53.05 $/MWh @ bus 19', '53.05 $/MWh @ bus 15');
0125 got = strrep(got, '53.05 $/MWh @ bus 20', '53.05 $/MWh @ bus 15');
0126 expected = fileread(fnamedc);
0127 expected = strrep(expected, char([13 10]), char(10));
0128 if size(expected, 1) ~= 1
0129 expected = expected';
0130 end
0131 t_ok(strcmp(got, expected), [t 'standard DC OPF']);
0132 delete(tmpfnamedc);
0133
0134 if have_fcn('octave')
0135 warning(s1.state, 'Octave:load-file-in-path');
0136 end
0137 warning(s2.state, 'MATLAB:singularMatrix');
0138
0139 t_end;