0001 function t_opf_dc_mips(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if nargin < 1
0015 quiet = 0;
0016 end
0017
0018 num_tests = 23;
0019
0020 t_begin(num_tests, quiet);
0021
0022 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0023 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0024 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0025 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0026 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0027 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0028 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0029 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0030
0031 casefile = 't_case9_opf';
0032 if quiet
0033 verbose = 0;
0034 else
0035 verbose = 0;
0036 end
0037 if have_fcn('octave')
0038 if have_fcn('octave', 'vnum') >= 4
0039 file_in_path_warn_id = 'Octave:data-file-in-path';
0040 else
0041 file_in_path_warn_id = 'Octave:load-file-in-path';
0042 end
0043 s1 = warning('query', file_in_path_warn_id);
0044 warning('off', file_in_path_warn_id);
0045 end
0046
0047 t0 = 'DC OPF (MIPS): ';
0048 mpopt = mpoption('out.all', 0, 'verbose', verbose);
0049 mpopt = mpoption(mpopt, 'opf.dc.solver', 'MIPS');
0050
0051 if have_fcn('octave')
0052 sing_matrix_warn_id = 'Octave:singular-matrix';
0053 else
0054 sing_matrix_warn_id = 'MATLAB:singularMatrix';
0055 end
0056 s2 = warning('query', sing_matrix_warn_id);
0057
0058
0059 ib_data = [1:BUS_AREA BASE_KV:VMIN];
0060 ib_voltage = [VM VA];
0061 ib_lam = [LAM_P LAM_Q];
0062 ib_mu = [MU_VMAX MU_VMIN];
0063 ig_data = [GEN_BUS QMAX QMIN MBASE:APF];
0064 ig_disp = [PG QG VG];
0065 ig_mu = (MU_PMAX:MU_QMIN);
0066 ibr_data = (1:ANGMAX);
0067 ibr_flow = (PF:QT);
0068 ibr_mu = [MU_SF MU_ST];
0069 ibr_angmu = [MU_ANGMIN MU_ANGMAX];
0070
0071
0072 load soln9_dcopf;
0073
0074
0075 t = t0;
0076 [baseMVA, bus, gen, gencost, branch, f, success, et] = rundcopf(casefile, mpopt);
0077 t_ok(success, [t 'success']);
0078 t_is(f, f_soln, 3, [t 'f']);
0079 t_is( bus(:,ib_data ), bus_soln(:,ib_data ), 10, [t 'bus data']);
0080 t_is( bus(:,ib_voltage), bus_soln(:,ib_voltage), 3, [t 'bus voltage']);
0081 t_is( bus(:,ib_lam ), bus_soln(:,ib_lam ), 3, [t 'bus lambda']);
0082 t_is( bus(:,ib_mu ), bus_soln(:,ib_mu ), 2, [t 'bus mu']);
0083 t_is( gen(:,ig_data ), gen_soln(:,ig_data ), 10, [t 'gen data']);
0084 t_is( gen(:,ig_disp ), gen_soln(:,ig_disp ), 3, [t 'gen dispatch']);
0085 t_is( gen(:,ig_mu ), gen_soln(:,ig_mu ), 3, [t 'gen mu']);
0086 t_is(branch(:,ibr_data ), branch_soln(:,ibr_data ), 10, [t 'branch data']);
0087 t_is(branch(:,ibr_flow ), branch_soln(:,ibr_flow ), 3, [t 'branch flow']);
0088 t_is(branch(:,ibr_mu ), branch_soln(:,ibr_mu ), 2, [t 'branch mu']);
0089
0090
0091
0092
0093
0094
0095 mpc = loadcase(casefile);
0096 mpc.A = sparse([1;1;1;2;2;2],[10;11;13;11;12;14],[-1;1;-1;1;-1;-1],2,14);
0097 mpc.u = [0; 0];
0098 mpc.l = [-Inf; -Inf];
0099 mpc.zl = [0; 0];
0100
0101 mpc.N = sparse([1;2], [13;14], [1;1], 2, 14);
0102 mpc.fparm = ones(2,1) * [1 0 0 1];
0103 mpc.H = sparse(2,2);
0104 mpc.Cw = [1000;1];
0105
0106 t = [t0 'w/extra constraints & costs 1 : '];
0107 [r, success] = rundcopf(mpc, mpopt);
0108 t_ok(success, [t 'success']);
0109 t_is(r.gen(1, PG), 116.15974, 4, [t 'Pg1 = 116.15974']);
0110 t_is(r.gen(2, PG), 116.15974, 4, [t 'Pg2 = 116.15974']);
0111 t_is(r.var.val.z, [0; 0.3348], 4, [t 'user vars']);
0112 t_is(r.cost.usr, 0.3348, 3, [t 'user costs']);
0113
0114
0115 mpc = loadcase(casefile);
0116 mpc.A = sparse([1;1;1;2;2;2],[19;20;25;20;21;26],[-1;1;-1;1;-1;-1],2,26);
0117 mpc.u = [0; 0];
0118 mpc.l = [-Inf; -Inf];
0119 mpc.zl = [0; 0];
0120
0121 mpc.N = sparse([1;2], [25;26], [1;1], 2, 26);
0122 mpc.fparm = ones(2,1) * [1 0 0 1];
0123 mpc.H = sparse(2,2);
0124 mpc.Cw = [1000;1];
0125
0126 t = [t0 'w/extra constraints & costs 2 : '];
0127 [r, success] = rundcopf(mpc, mpopt);
0128 t_ok(success, [t 'success']);
0129 t_is(r.gen(1, PG), 116.15974, 4, [t 'Pg1 = 116.15974']);
0130 t_is(r.gen(2, PG), 116.15974, 4, [t 'Pg2 = 116.15974']);
0131 t_is(r.var.val.z, [0; 0.3348], 4, [t 'user vars']);
0132 t_is(r.cost.usr, 0.3348, 3, [t 'user costs']);
0133
0134 t = [t0 'infeasible : '];
0135 warning('off', sing_matrix_warn_id);
0136
0137 mpc = loadcase(casefile);
0138 mpc.A = sparse([1;1], [10;11], [1;1], 1, 14);
0139 mpc.u = Inf;
0140 mpc.l = 600;
0141 [r, success] = rundcopf(mpc, mpopt);
0142 t_ok(~success, [t 'no success']);
0143
0144 if have_fcn('octave')
0145 warning(s1.state, file_in_path_warn_id);
0146 end
0147 warning(s2.state, sing_matrix_warn_id);
0148
0149 t_end;