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