Home > matpower4.1 > @opf_model > get_idx.m

get_idx

PURPOSE ^

GET_IDX Returns the idx struct for vars, lin/nln constraints, costs.

SYNOPSIS ^

function [vv, ll, nn, cc] = get_idx(om)

DESCRIPTION ^

GET_IDX  Returns the idx struct for vars, lin/nln constraints, costs.
   VV = GET_IDX(OM)
   [VV, LL] = GET_IDX(OM)
   [VV, LL, NN] = GET_IDX(OM)
   [VV, LL, NN, CC] = GET_IDX(OM)

   Returns a structure for each with the beginning and ending
   index value and the number of elements for each named block.
   The 'i1' field (that's a one) is a struct with all of the
   starting indices, 'iN' contains all the ending indices and
   'N' contains all the sizes. Each is a struct whose fields are
   the named blocks.

   Examples:
       [vv, ll, nn] = get_idx(om);

       For a variable block named 'z' we have ...
           vv.i1.z - starting index for 'z' in optimization vector x
           vv.iN.z - ending index for 'z' in optimization vector x
           vv.N    - number of elements in 'z'

       To extract a 'z' variable from x:
           z = x(vv.i1.z:vv.iN.z);

       To extract the multipliers on a linear constraint set
       named 'foo', where mu_l and mu_u are the full set of
       linear constraint multipliers:
           mu_l_foo = mu_l(ll.i1.foo:ll.iN.foo);
           mu_u_foo = mu_u(ll.i1.foo:ll.iN.foo);

       The number of nonlinear constraints in a set named 'bar':
           nbar = nn.N.bar;
         (note: the following is preferable ...
           nbar = getN(om, 'nln', 'bar');
         ... if you haven't already called get_idx to get nn.)

   See also OPF_MODEL, ADD_VARS, ADD_CONSTRAINTS, ADD_COSTS.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [vv, ll, nn, cc] = get_idx(om)
0002 %GET_IDX  Returns the idx struct for vars, lin/nln constraints, costs.
0003 %   VV = GET_IDX(OM)
0004 %   [VV, LL] = GET_IDX(OM)
0005 %   [VV, LL, NN] = GET_IDX(OM)
0006 %   [VV, LL, NN, CC] = GET_IDX(OM)
0007 %
0008 %   Returns a structure for each with the beginning and ending
0009 %   index value and the number of elements for each named block.
0010 %   The 'i1' field (that's a one) is a struct with all of the
0011 %   starting indices, 'iN' contains all the ending indices and
0012 %   'N' contains all the sizes. Each is a struct whose fields are
0013 %   the named blocks.
0014 %
0015 %   Examples:
0016 %       [vv, ll, nn] = get_idx(om);
0017 %
0018 %       For a variable block named 'z' we have ...
0019 %           vv.i1.z - starting index for 'z' in optimization vector x
0020 %           vv.iN.z - ending index for 'z' in optimization vector x
0021 %           vv.N    - number of elements in 'z'
0022 %
0023 %       To extract a 'z' variable from x:
0024 %           z = x(vv.i1.z:vv.iN.z);
0025 %
0026 %       To extract the multipliers on a linear constraint set
0027 %       named 'foo', where mu_l and mu_u are the full set of
0028 %       linear constraint multipliers:
0029 %           mu_l_foo = mu_l(ll.i1.foo:ll.iN.foo);
0030 %           mu_u_foo = mu_u(ll.i1.foo:ll.iN.foo);
0031 %
0032 %       The number of nonlinear constraints in a set named 'bar':
0033 %           nbar = nn.N.bar;
0034 %         (note: the following is preferable ...
0035 %           nbar = getN(om, 'nln', 'bar');
0036 %         ... if you haven't already called get_idx to get nn.)
0037 %
0038 %   See also OPF_MODEL, ADD_VARS, ADD_CONSTRAINTS, ADD_COSTS.
0039 
0040 %   MATPOWER
0041 %   $Id: get_idx.m,v 1.9 2010/06/09 14:56:58 ray Exp $
0042 %   by Ray Zimmerman, PSERC Cornell
0043 %   Copyright (c) 2008-2010 by Power System Engineering Research Center (PSERC)
0044 %
0045 %   This file is part of MATPOWER.
0046 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0047 %
0048 %   MATPOWER is free software: you can redistribute it and/or modify
0049 %   it under the terms of the GNU General Public License as published
0050 %   by the Free Software Foundation, either version 3 of the License,
0051 %   or (at your option) any later version.
0052 %
0053 %   MATPOWER is distributed in the hope that it will be useful,
0054 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0055 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0056 %   GNU General Public License for more details.
0057 %
0058 %   You should have received a copy of the GNU General Public License
0059 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0060 %
0061 %   Additional permission under GNU GPL version 3 section 7
0062 %
0063 %   If you modify MATPOWER, or any covered work, to interface with
0064 %   other modules (such as MATLAB code and MEX-files) available in a
0065 %   MATLAB(R) or comparable environment containing parts covered
0066 %   under other licensing terms, the licensors of MATPOWER grant
0067 %   you additional permission to convey the resulting work.
0068 
0069 vv = om.var.idx;
0070 if nargout > 1
0071     ll = om.lin.idx;
0072     if nargout > 2
0073         nn = om.nln.idx;
0074         if nargout > 3
0075             cc = om.cost.idx;
0076          end
0077     end
0078 end

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005