0001 function t_opf_dc_mips(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 = 23;
0038
0039 t_begin(num_tests, quiet);
0040
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 casefile = 't_case9_opf';
0051 if quiet
0052 verbose = 0;
0053 else
0054 verbose = 0;
0055 end
0056 if have_fcn('octave')
0057 s1 = warning('query', 'Octave:load-file-in-path');
0058 warning('off', 'Octave:load-file-in-path');
0059 end
0060
0061 t0 = 'DC OPF (MIPS): ';
0062 mpopt = mpoption('OUT_ALL', 0, 'VERBOSE', verbose);
0063 mpopt = mpoption(mpopt, 'OPF_ALG_DC', 200);
0064
0065
0066 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0067 s2 = warning('query', 'MATLAB:singularMatrix');
0068 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0069
0070
0071 ib_data = [1:BUS_AREA BASE_KV:VMIN];
0072 ib_voltage = [VM VA];
0073 ib_lam = [LAM_P LAM_Q];
0074 ib_mu = [MU_VMAX MU_VMIN];
0075 ig_data = [GEN_BUS QMAX QMIN MBASE:APF];
0076 ig_disp = [PG QG VG];
0077 ig_mu = (MU_PMAX:MU_QMIN);
0078 ibr_data = (1:ANGMAX);
0079 ibr_flow = (PF:QT);
0080 ibr_mu = [MU_SF MU_ST];
0081 ibr_angmu = [MU_ANGMIN MU_ANGMAX];
0082
0083
0084 load soln9_dcopf;
0085
0086
0087 t = t0;
0088 [baseMVA, bus, gen, gencost, branch, f, success, et] = rundcopf(casefile, mpopt);
0089 t_ok(success, [t 'success']);
0090 t_is(f, f_soln, 3, [t 'f']);
0091 t_is( bus(:,ib_data ), bus_soln(:,ib_data ), 10, [t 'bus data']);
0092 t_is( bus(:,ib_voltage), bus_soln(:,ib_voltage), 3, [t 'bus voltage']);
0093 t_is( bus(:,ib_lam ), bus_soln(:,ib_lam ), 3, [t 'bus lambda']);
0094 t_is( bus(:,ib_mu ), bus_soln(:,ib_mu ), 2, [t 'bus mu']);
0095 t_is( gen(:,ig_data ), gen_soln(:,ig_data ), 10, [t 'gen data']);
0096 t_is( gen(:,ig_disp ), gen_soln(:,ig_disp ), 3, [t 'gen dispatch']);
0097 t_is( gen(:,ig_mu ), gen_soln(:,ig_mu ), 3, [t 'gen mu']);
0098 t_is(branch(:,ibr_data ), branch_soln(:,ibr_data ), 10, [t 'branch data']);
0099 t_is(branch(:,ibr_flow ), branch_soln(:,ibr_flow ), 3, [t 'branch flow']);
0100 t_is(branch(:,ibr_mu ), branch_soln(:,ibr_mu ), 2, [t 'branch mu']);
0101
0102
0103
0104
0105
0106
0107 mpc = loadcase(casefile);
0108 mpc.A = sparse([1;1;1;2;2;2],[10;11;13;11;12;14],[-1;1;-1;1;-1;-1],2,14);
0109 mpc.u = [0; 0];
0110 mpc.l = [-Inf; -Inf];
0111 mpc.zl = [0; 0];
0112
0113 mpc.N = sparse([1;2], [13;14], [1;1], 2, 14);
0114 mpc.fparm = ones(2,1) * [1 0 0 1];
0115 mpc.H = sparse(2,2);
0116 mpc.Cw = [1000;1];
0117
0118 t = [t0 'w/extra constraints & costs 1 : '];
0119 [r, success] = rundcopf(mpc, mpopt);
0120 t_ok(success, [t 'success']);
0121 t_is(r.gen(1, PG), 116.15974, 4, [t 'Pg1 = 116.15974']);
0122 t_is(r.gen(2, PG), 116.15974, 4, [t 'Pg2 = 116.15974']);
0123 t_is(r.var.val.z, [0; 0.3348], 4, [t 'user vars']);
0124 t_is(r.cost.usr, 0.3348, 3, [t 'user costs']);
0125
0126
0127 mpc = loadcase(casefile);
0128 mpc.A = sparse([1;1;1;2;2;2],[19;20;25;20;21;26],[-1;1;-1;1;-1;-1],2,26);
0129 mpc.u = [0; 0];
0130 mpc.l = [-Inf; -Inf];
0131 mpc.zl = [0; 0];
0132
0133 mpc.N = sparse([1;2], [25;26], [1;1], 2, 26);
0134 mpc.fparm = ones(2,1) * [1 0 0 1];
0135 mpc.H = sparse(2,2);
0136 mpc.Cw = [1000;1];
0137
0138 t = [t0 'w/extra constraints & costs 2 : '];
0139 [r, success] = rundcopf(mpc, mpopt);
0140 t_ok(success, [t 'success']);
0141 t_is(r.gen(1, PG), 116.15974, 4, [t 'Pg1 = 116.15974']);
0142 t_is(r.gen(2, PG), 116.15974, 4, [t 'Pg2 = 116.15974']);
0143 t_is(r.var.val.z, [0; 0.3348], 4, [t 'user vars']);
0144 t_is(r.cost.usr, 0.3348, 3, [t 'user costs']);
0145
0146 t = [t0 'infeasible : '];
0147 warning('off', 'MATLAB:singularMatrix');
0148
0149 mpc = loadcase(casefile);
0150 mpc.A = sparse([1;1], [10;11], [1;1], 1, 14);
0151 mpc.u = Inf;
0152 mpc.l = 600;
0153 [r, success] = rundcopf(mpc, mpopt);
0154 t_ok(~success, [t 'no success']);
0155
0156 if have_fcn('octave')
0157 warning(s1.state, 'Octave:load-file-in-path');
0158 end
0159 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0160 warning(s2.state, 'MATLAB:singularMatrix');
0161
0162 t_end;