Home > matpower7.1 > lib > @opf_model > init_indexed_name.m

init_indexed_name

PURPOSE ^

INIT_INDEXED_NAME Initializes the dimensions for an indexed named set.

SYNOPSIS ^

function om = init_indexed_name(om, set_type, name, dim_list)

DESCRIPTION ^

INIT_INDEXED_NAME  Initializes the dimensions for an indexed named set.

   OM.INIT_INDEXED_NAME(SET_TYPE, NAME, DIM_LIST)

   Initializes the dimensions for an indexed named variable, constraint
   or cost set.

   Variables, constraints and costs are referenced in OPT_MODEL in terms
   of named sets. The specific type of named set being referenced is
   given by SET_TYPE, with the following valid options:
       SET_TYPE = 'var'   => variable set
       SET_TYPE = 'lin'   => linear constraint set
       SET_TYPE = 'nle'   => nonlinear equality constraint set
       SET_TYPE = 'nli'   => nonlinear inequality constraint set
       SET_TYPE = 'qdc'   => quadratic cost set
       SET_TYPE = 'nlc'   => nonlinear cost set
       SET_TYPE = 'cost'  => legacy cost set

   Indexed Named Sets

   A variable, constraint or cost set can be identified by a single NAME,
   such as 'Pmismatch', or by a name that is indexed by one or more indices,
   such as 'Pmismatch(3,4)'. For an indexed named set, before adding the
   indexed variable, constraint or cost sets themselves, the dimensions of
   the indexed set must be set by calling INIT_INDEXED_NAME, where
   DIM_LIST is a cell array of the dimensions.

   Examples:
       %% linear constraints with indexed named set 'R(i,j)'
       om.init_indexed_name('lin', 'R', {2, 3});
       for i = 1:2
         for j = 1:3
           om.add_lin_constraint('R', {i, j}, A{i,j}, ...);
         end
       end

   See also OPT_MODEL, ADD_VAR, ADD_LIN_CONSTRAINT, ADD_NLN_CONSTRAINT,
            ADD_QUAD_COST, ADD_NLN_COST and ADD_LEGACY_COST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function om = init_indexed_name(om, set_type, name, dim_list)
0002 %INIT_INDEXED_NAME  Initializes the dimensions for an indexed named set.
0003 %
0004 %   OM.INIT_INDEXED_NAME(SET_TYPE, NAME, DIM_LIST)
0005 %
0006 %   Initializes the dimensions for an indexed named variable, constraint
0007 %   or cost set.
0008 %
0009 %   Variables, constraints and costs are referenced in OPT_MODEL in terms
0010 %   of named sets. The specific type of named set being referenced is
0011 %   given by SET_TYPE, with the following valid options:
0012 %       SET_TYPE = 'var'   => variable set
0013 %       SET_TYPE = 'lin'   => linear constraint set
0014 %       SET_TYPE = 'nle'   => nonlinear equality constraint set
0015 %       SET_TYPE = 'nli'   => nonlinear inequality constraint set
0016 %       SET_TYPE = 'qdc'   => quadratic cost set
0017 %       SET_TYPE = 'nlc'   => nonlinear cost set
0018 %       SET_TYPE = 'cost'  => legacy cost set
0019 %
0020 %   Indexed Named Sets
0021 %
0022 %   A variable, constraint or cost set can be identified by a single NAME,
0023 %   such as 'Pmismatch', or by a name that is indexed by one or more indices,
0024 %   such as 'Pmismatch(3,4)'. For an indexed named set, before adding the
0025 %   indexed variable, constraint or cost sets themselves, the dimensions of
0026 %   the indexed set must be set by calling INIT_INDEXED_NAME, where
0027 %   DIM_LIST is a cell array of the dimensions.
0028 %
0029 %   Examples:
0030 %       %% linear constraints with indexed named set 'R(i,j)'
0031 %       om.init_indexed_name('lin', 'R', {2, 3});
0032 %       for i = 1:2
0033 %         for j = 1:3
0034 %           om.add_lin_constraint('R', {i, j}, A{i,j}, ...);
0035 %         end
0036 %       end
0037 %
0038 %   See also OPT_MODEL, ADD_VAR, ADD_LIN_CONSTRAINT, ADD_NLN_CONSTRAINT,
0039 %            ADD_QUAD_COST, ADD_NLN_COST and ADD_LEGACY_COST.
0040 
0041 %   MATPOWER
0042 %   Copyright (c) 2008-2020, Power Systems Engineering Research Center (PSERC)
0043 %   by Ray Zimmerman, PSERC Cornell
0044 %
0045 %   This file is part of MATPOWER.
0046 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0047 %   See https://matpower.org for more info.
0048 
0049 %% call parent method (also checks for valid type for named set)
0050 om = init_indexed_name@opt_model(om, set_type, name, dim_list);
0051 
0052 %% add type-specific info about this named set
0053 switch set_type
0054     case 'cost'         %% cost set
0055         %% use column vector if single dimension
0056         if length(dim_list) == 1
0057             dim_list = {dim_list{:}, 1};
0058         end
0059         empty_cell  = cell(dim_list{:});
0060         om.cost.data.N.(name)   = empty_cell;
0061         om.cost.data.Cw.(name)  = empty_cell;
0062         om.cost.data.vs.(name)  = empty_cell;
0063 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005