Home > matpower5.1 > extras > misc > check_feasibility.m

check_feasibility

PURPOSE ^

CHECK_FEASIBILITY Returns the maximum constraint violation in p.u.

SYNOPSIS ^

function [v, f, hn, gn, Al, Au, xl, xu] = check_feasibility(mpc, mpopt)

DESCRIPTION ^

CHECK_FEASIBILITY  Returns the maximum constraint violation in p.u.
   V = CHECK_FEASIBILITY(MPC)
   [V, F, HN, GN, AL, AU, XL, XU] = CHECK_FEASIBILITY(MPC, MPOPT)

   Not thoroughly tested.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [v, f, hn, gn, Al, Au, xl, xu] = check_feasibility(mpc, mpopt)
0002 %CHECK_FEASIBILITY  Returns the maximum constraint violation in p.u.
0003 %   V = CHECK_FEASIBILITY(MPC)
0004 %   [V, F, HN, GN, AL, AU, XL, XU] = CHECK_FEASIBILITY(MPC, MPOPT)
0005 %
0006 %   Not thoroughly tested.
0007 
0008 %   MATPOWER
0009 %   Copyright (c) 2010-2015 by Power System Engineering Research Center (PSERC)
0010 %   by Ray Zimmerman, PSERC Cornell
0011 %
0012 %   $Id: check_feasibility.m 2644 2015-03-11 19:34:22Z ray $
0013 %
0014 %   This file is part of MATPOWER.
0015 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0016 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0017 
0018 %%----- initialization -----
0019 %% define named indices into data matrices
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 %% unpack data
0040 mpc = get_mpc(om);
0041 [vv, ll, nn] = get_idx(om);
0042 
0043 %% problem dimensions
0044 nb = size(mpc.bus, 1);      %% number of buses
0045 nl = size(mpc.branch, 1);   %% number of branches
0046 ny = getN(om, 'var', 'y');  %% number of piece-wise linear costs
0047 
0048 %% linear constraints
0049 [A, l, u] = linear_constraints(om);
0050 
0051 %% bounds on optimization vars
0052 [x, xmin, xmax] = getv(om);
0053 
0054 %% build admittance matrices
0055 [Ybus, Yf, Yt] = makeYbus(mpc.baseMVA, mpc.bus, mpc.branch);
0056 
0057 %% set y variables (ONLY IMPLEMENTED FOR PG)
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 %% find branches with flow limits
0065 il = find(mpc.branch(:, RATE_A) ~= 0 & mpc.branch(:, RATE_A) < 1e10);
0066 nl2 = length(il);           %% number of constrained lines
0067 
0068 %%-----  run opf  -----
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]);

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005