Home > matpower7.1 > mp-opt-model > lib > @opt_model > eval_lin_constraint.m

eval_lin_constraint

PURPOSE ^

EVAL_LIN_CONSTRAINT Builds and returns full set of linear constraints.

SYNOPSIS ^

function [Ax_u, l_Ax, A] = eval_lin_constraint(om, x, name, idx)

DESCRIPTION ^

EVAL_LIN_CONSTRAINT  Builds and returns full set of linear constraints.
   AX_U = OM.EVAL_LIN_CONSTRAINT(X)
   AX_U = OM.EVAL_LIN_CONSTRAINT(X, NAME)
   AX_U = OM.EVAL_LIN_CONSTRAINT(X, NAME, IDX_LIST)
   [AX_U, L_AX] = OM.EVAL_LIN_CONSTRAINT(...)
   [AX_U, L_AX, A] = OM.EVAL_LIN_CONSTRAINT(...)
   Builds the linear constraints for the full set of constraints or an
   individual named subset for a given value of the vector X, based on
   constraints added by ADD_LIN_CONSTRAINT.

       l <= A * x <= u

   Returns A*X - U, and optionally L - A*X and A.

   Example:
       [Ax_u, l_Ax, A] = om.eval_lin_constraint(x)

   See also OPT_MODEL, ADD_LIN_CONSTRAINT, PARAMS_LIN_CONSTRAINT.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Ax_u, l_Ax, A] = eval_lin_constraint(om, x, name, idx)
0002 %EVAL_LIN_CONSTRAINT  Builds and returns full set of linear constraints.
0003 %   AX_U = OM.EVAL_LIN_CONSTRAINT(X)
0004 %   AX_U = OM.EVAL_LIN_CONSTRAINT(X, NAME)
0005 %   AX_U = OM.EVAL_LIN_CONSTRAINT(X, NAME, IDX_LIST)
0006 %   [AX_U, L_AX] = OM.EVAL_LIN_CONSTRAINT(...)
0007 %   [AX_U, L_AX, A] = OM.EVAL_LIN_CONSTRAINT(...)
0008 %   Builds the linear constraints for the full set of constraints or an
0009 %   individual named subset for a given value of the vector X, based on
0010 %   constraints added by ADD_LIN_CONSTRAINT.
0011 %
0012 %       l <= A * x <= u
0013 %
0014 %   Returns A*X - U, and optionally L - A*X and A.
0015 %
0016 %   Example:
0017 %       [Ax_u, l_Ax, A] = om.eval_lin_constraint(x)
0018 %
0019 %   See also OPT_MODEL, ADD_LIN_CONSTRAINT, PARAMS_LIN_CONSTRAINT.
0020 
0021 %   MP-Opt-Model
0022 %   Copyright (c) 2020, Power Systems Engineering Research Center (PSERC)
0023 %   by Ray Zimmerman, PSERC Cornell
0024 %
0025 %   This file is part of MP-Opt-Model.
0026 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0027 %   See https://github.com/MATPOWER/mp-opt-model for more info.
0028 
0029 if om.lin.N
0030     %% collect cost parameters
0031     if nargin < 3                       %% full set
0032         [A, l, u, vs] = om.params_lin_constraint();
0033         N = 1;
0034     elseif nargin < 4 || isempty(idx)   %% name, no idx provided
0035         dims = size(om.lin.idx.i1.(name));
0036         if prod(dims) == 1              %% simple named set
0037             [A, l, u, vs] = om.params_lin_constraint(name);
0038             N = om.getN('lin', name);
0039         else
0040             error('@opt_model/eval_quad_cost: quadratic cost set ''%s'' requires an IDX_LIST arg when requesting DF output', name)
0041         end
0042     else                                %% indexed named set
0043         [A, l, u, vs] = om.params_lin_constraint(name, idx);
0044         N = om.getN('lin', name, idx);
0045     end
0046     
0047     %% assemble appropriately-sized x vector
0048     xx = om.varsets_x(x, vs, 'vector');
0049 
0050     %% compute constraints
0051     Ax = A * xx;
0052     Ax_u = Ax - u;
0053     if nargout > 1
0054         l_Ax = l - Ax;
0055     end
0056 else
0057     Ax_u = [];
0058     if nargout > 1
0059         l_Ax = [];
0060     end
0061 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005