Home > matpower6.0 > @opt_model > getN.m

getN

PURPOSE ^

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

SYNOPSIS ^

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

DESCRIPTION ^

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

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

   Examples:
       N = getN(om, 'var')         : total number of variables
       N = getN(om, 'lin')         : total number of linear constraints
       N = getN(om, 'nln')         : total number of nonlinear constraints
       N = getN(om, 'cost')        : total number of cost rows (in N)
       N = getN(om, 'var', name)   : number of variables in named set
       N = getN(om, 'lin', name)   : number of linear constraints in named set
       N = getN(om, 'nln', name)   : number of nonlinear cons. in named set
       N = getN(om, 'cost', name)  : number of cost rows (in N) in named set
       N = getN(om, 'var', name, idx) : number 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, selector, name, idx)
0002 %GETN  Returns the number of variables, constraints or cost rows.
0003 %   N = GETN(OM, SELECTOR)
0004 %   N = GETN(OM, SELECTOR, NAME)
0005 %   N = GETN(OM, SELECTOR, 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 = getN(om, 'var')         : total number of variables
0012 %       N = getN(om, 'lin')         : total number of linear constraints
0013 %       N = getN(om, 'nln')         : total number of nonlinear constraints
0014 %       N = getN(om, 'cost')        : total number of cost rows (in N)
0015 %       N = getN(om, 'var', name)   : number of variables in named set
0016 %       N = getN(om, 'lin', name)   : number of linear constraints in named set
0017 %       N = getN(om, 'nln', name)   : number of nonlinear cons. in named set
0018 %       N = getN(om, 'cost', name)  : number of cost rows (in N) in named set
0019 %       N = getN(om, 'var', name, idx) : number of variables in indexed named set
0020 %
0021 %   See also OPT_MODEL.
0022 
0023 %   MATPOWER
0024 %   Copyright (c) 2008-2016, Power Systems Engineering Research Center (PSERC)
0025 %   by Ray Zimmerman, PSERC Cornell
0026 %
0027 %   This file is part of MATPOWER.
0028 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0029 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0030 
0031 if nargin < 3
0032     N = om.(selector).N;
0033 else
0034     if isfield(om.(selector).idx.N, name)
0035         if nargin < 4
0036             idx = {};
0037         end
0038         s1 = substruct('.', name, '()', idx);
0039         N = subsref(om.(selector).idx.N, s1);
0040     else
0041         N = 0;
0042     end
0043 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005