Home > matpower5.1 > @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 %   Copyright (c) 2008-2015 by Power System Engineering Research Center (PSERC)
0046 %   by Ray Zimmerman, PSERC Cornell
0047 %
0048 %   $Id: get_idx.m 2644 2015-03-11 19:34:22Z ray $
0049 %
0050 %   This file is part of MATPOWER.
0051 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0052 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0053 
0054 vv = om.var.idx;
0055 if nargout > 1
0056     ll = om.lin.idx;
0057     if nargout > 2
0058         nn = om.nln.idx;
0059         if nargout > 3
0060             cc = om.cost.idx;
0061          end
0062     end
0063 end

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005