0001 function [v, f, hn, gn, Al, Au, xl, xu] = check_feasibility(mpc, mpopt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0019 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0020 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0021 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0022 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0023 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0024 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0025 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0026 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0027
0028 if nargin < 2
0029 mpopt = mpoption;
0030 end
0031
0032 [mpc, mpopt] = opf_args(mpc, mpopt);
0033 mpc = ext2int(mpc);
0034 om = opf_setup(mpc, mpopt);
0035 om = build_cost_params(om);
0036
0037
0038 mpc = get_mpc(om);
0039 [vv, ll, nn] = get_idx(om);
0040
0041
0042 nb = size(mpc.bus, 1);
0043 nl = size(mpc.branch, 1);
0044 ny = getN(om, 'var', 'y');
0045
0046
0047 [A, l, u] = linear_constraints(om);
0048
0049
0050 [x, xmin, xmax] = getv(om);
0051
0052
0053 [Ybus, Yf, Yt] = makeYbus(mpc.baseMVA, mpc.bus, mpc.branch);
0054
0055
0056 if ny > 0
0057 ipwl = find(mpc.gencost(:, MODEL) == PW_LINEAR);
0058 ig = vv.i1.Pg:vv.iN.Pg;
0059 x(vv.i1.y:vv.iN.y) = totcost(mpc.gencost(ipwl, :), x(ig(ipwl)) * mpc.baseMVA);
0060 end
0061
0062
0063 il = find(mpc.branch(:, RATE_A) ~= 0 & mpc.branch(:, RATE_A) < 1e10);
0064 nl2 = length(il);
0065
0066
0067 f_fcn = @(x)opf_costfcn(x, om);
0068 gh_fcn = @(x)opf_consfcn(x, om, Ybus, Yf(il,:), Yt(il,:), mpopt, il);
0069 hess_fcn = @(x, lambda, cost_mult)opf_hessfcn(x, lambda, cost_mult, om, Ybus, Yf(il,:), Yt(il,:), mpopt, il);
0070
0071 [f, df, d2f] = f_fcn(x);
0072 [hn, gn, dhn, dgn] = gh_fcn(x);
0073
0074 Ax = A * x;
0075 Au = Ax - u;
0076 Al = l - Ax;
0077
0078 xu = x - xmax;
0079 xl = xmin - x;
0080
0081 v = max([hn; abs(gn); Au; Al; xu; xl]);