Home > matpower5.0 > @opt_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.z  - 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.)

       If 'z', 'foo' and 'bar' are indexed sets, then you can
       replace them with something like 'z(i,j)', 'foo(i,j,k)'
       or 'bar(i)' in the examples above.

   See also OPT_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.z  - 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 %       If 'z', 'foo' and 'bar' are indexed sets, then you can
0039 %       replace them with something like 'z(i,j)', 'foo(i,j,k)'
0040 %       or 'bar(i)' in the examples above.
0041 %
0042 %   See also OPT_MODEL, ADD_VARS, ADD_CONSTRAINTS, ADD_COSTS.
0043 
0044 %   MATPOWER
0045 %   $Id: get_idx.m 2048 2012-05-03 12:59:07Z cvs $
0046 %   by Ray Zimmerman, PSERC Cornell
0047 %   Copyright (c) 2008-2012 by Power System Engineering Research Center (PSERC)
0048 %
0049 %   This file is part of MATPOWER.
0050 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0051 %
0052 %   MATPOWER is free software: you can redistribute it and/or modify
0053 %   it under the terms of the GNU General Public License as published
0054 %   by the Free Software Foundation, either version 3 of the License,
0055 %   or (at your option) any later version.
0056 %
0057 %   MATPOWER is distributed in the hope that it will be useful,
0058 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0059 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0060 %   GNU General Public License for more details.
0061 %
0062 %   You should have received a copy of the GNU General Public License
0063 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0064 %
0065 %   Additional permission under GNU GPL version 3 section 7
0066 %
0067 %   If you modify MATPOWER, or any covered work, to interface with
0068 %   other modules (such as MATLAB code and MEX-files) available in a
0069 %   MATLAB(R) or comparable environment containing parts covered
0070 %   under other licensing terms, the licensors of MATPOWER grant
0071 %   you additional permission to convey the resulting work.
0072 
0073 vv = om.var.idx;
0074 if nargout > 1
0075     ll = om.lin.idx;
0076     if nargout > 2
0077         nn = om.nln.idx;
0078         if nargout > 3
0079             cc = om.cost.idx;
0080          end
0081     end
0082 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005