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

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