Home > matpower4.1 > @opf_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)

DESCRIPTION ^

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

   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 OPF_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)
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 %
0006 %   Requires calling BUILD_COST_PARAMS first to build the full set of
0007 %   parameters. Returns the full cost parameter struct for all user-defined
0008 %   costs that incorporates all of the named cost sets added via ADD_COSTS,
0009 %   or, if a name is provided it returns the cost struct corresponding to
0010 %   the named set of cost rows (N still has full number of columns).
0011 %
0012 %   The cost parameters are returned in a struct with the following fields:
0013 %       N      - nw x nx sparse matrix
0014 %       Cw     - nw x 1 vector
0015 %       H      - nw x nw sparse matrix (optional, all zeros by default)
0016 %       dd, mm - nw x 1 vectors (optional, all ones by default)
0017 %       rh, kk - nw x 1 vectors (optional, all zeros by default)
0018 %
0019 %   See also OPF_MODEL, ADD_COSTS, BUILD_COST_PARAMS, COMPUTE_COST.
0020 
0021 %   MATPOWER
0022 %   $Id: get_cost_params.m,v 1.8 2011/12/01 17:03:17 cvs Exp $
0023 %   by Ray Zimmerman, PSERC Cornell
0024 %   Copyright (c) 2008-2010 by Power System Engineering Research Center (PSERC)
0025 %
0026 %   This file is part of MATPOWER.
0027 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0028 %
0029 %   MATPOWER is free software: you can redistribute it and/or modify
0030 %   it under the terms of the GNU General Public License as published
0031 %   by the Free Software Foundation, either version 3 of the License,
0032 %   or (at your option) any later version.
0033 %
0034 %   MATPOWER is distributed in the hope that it will be useful,
0035 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0036 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0037 %   GNU General Public License for more details.
0038 %
0039 %   You should have received a copy of the GNU General Public License
0040 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0041 %
0042 %   Additional permission under GNU GPL version 3 section 7
0043 %
0044 %   If you modify MATPOWER, or any covered work, to interface with
0045 %   other modules (such as MATLAB code and MEX-files) available in a
0046 %   MATLAB(R) or comparable environment containing parts covered
0047 %   under other licensing terms, the licensors of MATPOWER grant
0048 %   you additional permission to convey the resulting work.
0049 
0050 if ~isfield(om.cost, 'params')
0051     error('@opf_model/get_cost_params: must call build_cost_params first');
0052 end
0053 
0054 cp = om.cost.params;
0055 
0056 if nargin > 1
0057     if getN(om, 'cost', name)
0058         idx = om.cost.idx.i1.(name):om.cost.idx.iN.(name);
0059         cp.N  = cp.N(idx,:);
0060         cp.Cw = cp.Cw(idx);
0061         cp.H  = cp.H(idx,idx);
0062         cp.dd = cp.dd(idx);
0063         cp.rh = cp.rh(idx);
0064         cp.kk = cp.kk(idx);
0065         cp.mm = cp.mm(idx);
0066     end
0067 end

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005