Home > matpower7.0 > lib > opf_consfcn.m

opf_consfcn

PURPOSE ^

OPF_CONSFCN Evaluates nonlinear constraints and their Jacobian for OPF.

SYNOPSIS ^

function [h, g, dh, dg] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt, il, varargin)

DESCRIPTION ^

OPF_CONSFCN  Evaluates nonlinear constraints and their Jacobian for OPF.
   [H, G, DH, DG] = OPF_CONSFCN(X, OM, YBUS, YF, YT, MPOPT, IL)

   Constraint evaluation function for AC optimal power flow, suitable
   for use with MIPS or FMINCON. Computes constraint vectors and their
   gradients.

   Inputs:
     X : optimization vector
     OM : OPF model object
     YBUS : bus admittance matrix
     YF : admittance matrix for "from" end of constrained branches
     YT : admittance matrix for "to" end of constrained branches
     MPOPT : MATPOWER options struct
     IL : (optional) vector of branch indices corresponding to
          branches with flow limits (all others are assumed to be
          unconstrained). The default is [1:nl] (all branches).
          YF and YT contain only the rows corresponding to IL.

   Outputs:
     H  : vector of inequality constraint values (flow limits)
          where the flow can be apparent power, real power, or
          current, depending on the value of opf.flow_lim in MPOPT
          (only for constrained lines), normally expressed as
          (limit^2 - flow^2), except when opf.flow_lim == 'P',
          in which case it is simply (limit - flow).
     G  : vector of equality constraint values (power balances)
     DH : (optional) inequality constraint gradients, column j is
          gradient of H(j)
     DG : (optional) equality constraint gradients

   Examples:
       [h, g] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt);
       [h, g, dh, dg] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt);
       [h, g, dh, dg] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt, il);

   See also OPF_COSTFCN, OPF_HESSFCN.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [h, g, dh, dg] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt, il, varargin)
0002 %OPF_CONSFCN  Evaluates nonlinear constraints and their Jacobian for OPF.
0003 %   [H, G, DH, DG] = OPF_CONSFCN(X, OM, YBUS, YF, YT, MPOPT, IL)
0004 %
0005 %   Constraint evaluation function for AC optimal power flow, suitable
0006 %   for use with MIPS or FMINCON. Computes constraint vectors and their
0007 %   gradients.
0008 %
0009 %   Inputs:
0010 %     X : optimization vector
0011 %     OM : OPF model object
0012 %     YBUS : bus admittance matrix
0013 %     YF : admittance matrix for "from" end of constrained branches
0014 %     YT : admittance matrix for "to" end of constrained branches
0015 %     MPOPT : MATPOWER options struct
0016 %     IL : (optional) vector of branch indices corresponding to
0017 %          branches with flow limits (all others are assumed to be
0018 %          unconstrained). The default is [1:nl] (all branches).
0019 %          YF and YT contain only the rows corresponding to IL.
0020 %
0021 %   Outputs:
0022 %     H  : vector of inequality constraint values (flow limits)
0023 %          where the flow can be apparent power, real power, or
0024 %          current, depending on the value of opf.flow_lim in MPOPT
0025 %          (only for constrained lines), normally expressed as
0026 %          (limit^2 - flow^2), except when opf.flow_lim == 'P',
0027 %          in which case it is simply (limit - flow).
0028 %     G  : vector of equality constraint values (power balances)
0029 %     DH : (optional) inequality constraint gradients, column j is
0030 %          gradient of H(j)
0031 %     DG : (optional) equality constraint gradients
0032 %
0033 %   Examples:
0034 %       [h, g] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt);
0035 %       [h, g, dh, dg] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt);
0036 %       [h, g, dh, dg] = opf_consfcn(x, om, Ybus, Yf, Yt, mpopt, il);
0037 %
0038 %   See also OPF_COSTFCN, OPF_HESSFCN.
0039 
0040 %   MATPOWER
0041 %   Copyright (c) 1996-2017, Power Systems Engineering Research Center (PSERC)
0042 %   by Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia
0043 %   and Ray Zimmerman, PSERC Cornell
0044 %
0045 %   This file is part of MATPOWER.
0046 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0047 %   See https://matpower.org for more info.
0048 
0049 if nargout == 2     %% contraints only
0050     g = om.eval_nln_constraint(x, 1);       %% equalities (power flow)
0051     h = om.eval_nln_constraint(x, 0);       %% inequalities (branch flow limits)
0052 else                %% constraints and derivatives
0053     [g, dg] = om.eval_nln_constraint(x, 1); %% equalities (power flow)
0054     [h, dh] = om.eval_nln_constraint(x, 0); %% inequalities (branch flow limits)
0055     dg = dg';
0056     dh = dh';
0057 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005