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