Home > matpower7.0 > lib > @opt_model > getN.m

getN

PURPOSE ^

GETN Returns the number of variables, constraints or cost rows.

SYNOPSIS ^

function N = getN(om, set_type, name, idx)

DESCRIPTION ^

GETN  Returns the number of variables, constraints or cost rows.
   N = OM.GETN(SET_TYPE)
   N = OM.GETN(SET_TYPE, NAME)
   N = OM.GETN(SET_TYPE, NAME, IDX)

   Returns either the total number of variables/constraints/cost rows
   or the number corresponding to a specified named block.

   Examples:
       N = om.getN('var')      : total number of variables
       N = om.getN('lin')      : total number of linear constraints
       N = om.getN('nle')      : total number of nonlin equality constraints
       N = om.getN('nli')      : total number of nonlin inequality constraints
       N = om.getN('qdc')      : total number of quadratic cost rows
       N = om.getN('nlc')      : total number of general nonlinear cost rows
       N = om.getN('cost')     : total number of legacy cost rows (in N)
       N = om.getN('var', name)    : # of variables in named set
       N = om.getN('lin', name)    : # of linear constraints in named set
       N = om.getN('nle', name)    : # of nonlin eq cons. in named set
       N = om.getN('nli', name)    : # of nonlin ineq cons. in named set
       N = om.getN('qdc', name)    : # of quadratic cost rows in named set
       N = om.getN('nlc', name)    : # of gen nonlin cost rows in named set
       N = om.getN('cost', name)   : # of legacy cost rows (in N) in named set
       N = om.getN('var', name, idx) : # of variables in indexed named set

   See also OPT_MODEL.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function N = getN(om, set_type, name, idx)
0002 %GETN  Returns the number of variables, constraints or cost rows.
0003 %   N = OM.GETN(SET_TYPE)
0004 %   N = OM.GETN(SET_TYPE, NAME)
0005 %   N = OM.GETN(SET_TYPE, NAME, IDX)
0006 %
0007 %   Returns either the total number of variables/constraints/cost rows
0008 %   or the number corresponding to a specified named block.
0009 %
0010 %   Examples:
0011 %       N = om.getN('var')      : total number of variables
0012 %       N = om.getN('lin')      : total number of linear constraints
0013 %       N = om.getN('nle')      : total number of nonlin equality constraints
0014 %       N = om.getN('nli')      : total number of nonlin inequality constraints
0015 %       N = om.getN('qdc')      : total number of quadratic cost rows
0016 %       N = om.getN('nlc')      : total number of general nonlinear cost rows
0017 %       N = om.getN('cost')     : total number of legacy cost rows (in N)
0018 %       N = om.getN('var', name)    : # of variables in named set
0019 %       N = om.getN('lin', name)    : # of linear constraints in named set
0020 %       N = om.getN('nle', name)    : # of nonlin eq cons. in named set
0021 %       N = om.getN('nli', name)    : # of nonlin ineq cons. in named set
0022 %       N = om.getN('qdc', name)    : # of quadratic cost rows in named set
0023 %       N = om.getN('nlc', name)    : # of gen nonlin cost rows in named set
0024 %       N = om.getN('cost', name)   : # of legacy cost rows (in N) in named set
0025 %       N = om.getN('var', name, idx) : # of variables in indexed named set
0026 %
0027 %   See also OPT_MODEL.
0028 
0029 %   MATPOWER
0030 %   Copyright (c) 2008-2017, Power Systems Engineering Research Center (PSERC)
0031 %   by Ray Zimmerman, PSERC Cornell
0032 %
0033 %   This file is part of MATPOWER.
0034 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0035 %   See https://matpower.org for more info.
0036 
0037 if nargin < 3
0038     N = om.(set_type).N;
0039 else
0040     if isfield(om.(set_type).idx.N, name)
0041         if nargin < 4
0042             idx = {};
0043         end
0044         s1 = substruct('.', name, '()', idx);
0045         N = subsref(om.(set_type).idx.N, s1);
0046     else
0047         N = 0;
0048     end
0049 end

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