Home > matpower5.1 > @opt_model > get_cost_params.m

get_cost_params

PURPOSE ^

GET_COST_PARAMS Returns the cost parameter struct for user-defined costs.

SYNOPSIS ^

function cp = get_cost_params(om, name, idx)

DESCRIPTION ^

GET_COST_PARAMS  Returns the cost parameter struct for user-defined costs.
   CP = GET_COST_PARAMS(OM)
   CP = GET_COST_PARAMS(OM, NAME)
   CP = GET_COST_PARAMS(OM, NAME, IDX)

   Requires calling BUILD_COST_PARAMS first to build the full set of
   parameters. Returns the full cost parameter struct for all user-defined
   costs that incorporates all of the named cost sets added via ADD_COSTS,
   or, if a name is provided it returns the cost struct corresponding to
   the named set of cost rows (N still has full number of columns).

   The cost parameters are returned in a struct with the following fields:
       N      - nw x nx sparse matrix
       Cw     - nw x 1 vector
       H      - nw x nw sparse matrix (optional, all zeros by default)
       dd, mm - nw x 1 vectors (optional, all ones by default)
       rh, kk - nw x 1 vectors (optional, all zeros by default)

   See also OPT_MODEL, ADD_COSTS, BUILD_COST_PARAMS, COMPUTE_COST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function cp = get_cost_params(om, name, idx)
0002 %GET_COST_PARAMS  Returns the cost parameter struct for user-defined costs.
0003 %   CP = GET_COST_PARAMS(OM)
0004 %   CP = GET_COST_PARAMS(OM, NAME)
0005 %   CP = GET_COST_PARAMS(OM, NAME, IDX)
0006 %
0007 %   Requires calling BUILD_COST_PARAMS first to build the full set of
0008 %   parameters. Returns the full cost parameter struct for all user-defined
0009 %   costs that incorporates all of the named cost sets added via ADD_COSTS,
0010 %   or, if a name is provided it returns the cost struct corresponding to
0011 %   the named set of cost rows (N still has full number of columns).
0012 %
0013 %   The cost parameters are returned in a struct with the following fields:
0014 %       N      - nw x nx sparse matrix
0015 %       Cw     - nw x 1 vector
0016 %       H      - nw x nw sparse matrix (optional, all zeros by default)
0017 %       dd, mm - nw x 1 vectors (optional, all ones by default)
0018 %       rh, kk - nw x 1 vectors (optional, all zeros by default)
0019 %
0020 %   See also OPT_MODEL, ADD_COSTS, BUILD_COST_PARAMS, COMPUTE_COST.
0021 
0022 %   MATPOWER
0023 %   Copyright (c) 2008-2015 by Power System Engineering Research Center (PSERC)
0024 %   by Ray Zimmerman, PSERC Cornell
0025 %
0026 %   $Id: get_cost_params.m 2644 2015-03-11 19:34:22Z ray $
0027 %
0028 %   This file is part of MATPOWER.
0029 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0030 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0031 
0032 if ~isfield(om.cost.params, 'N')
0033     error('@opt_model/get_cost_params: must call build_cost_params first');
0034 end
0035 
0036 cp = om.cost.params;
0037 
0038 if nargin > 1
0039     if getN(om, 'cost', name)
0040         if nargin < 3 || isempty(idx)
0041             if prod(size(om.cost.idx.i1.(name))) == 1
0042                 i1 = om.cost.idx.i1.(name);
0043                 iN = om.cost.idx.iN.(name);
0044             else
0045                 error('@opt_model/get_cost_params: cost set ''%s'' requires an idx arg', name);
0046             end
0047         else
0048             s1 = substruct('.', name, '()', idx);
0049             i1 = subsref(om.cost.idx.i1, s1);
0050             iN = subsref(om.cost.idx.iN, s1);
0051         end
0052         cp.N  = cp.N(i1:iN,:);
0053         cp.Cw = cp.Cw(i1:iN);
0054         cp.H  = cp.H(i1:iN,i1:iN);
0055         cp.dd = cp.dd(i1:iN);
0056         cp.rh = cp.rh(i1:iN);
0057         cp.kk = cp.kk(i1:iN);
0058         cp.mm = cp.mm(i1:iN);
0059     end
0060 end

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