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