Home > matpower7.0 > lib > @opt_model > params_nln_cost.m

params_nln_cost

PURPOSE ^

PARAMS_NLN_COST Returns cost parameters for general nonlinear costs.

SYNOPSIS ^

function [N, fcn, vs] = params_nln_cost(om, name, idx)

DESCRIPTION ^

PARAMS_NLN_COST  Returns cost parameters for general nonlinear costs.
   [N, FCN] = OM.PARAMS_NLN_COST(NAME)
   [N, FCN] = OM.PARAMS_NLN_COST(NAME, IDX)
   [N, FCN, VS] = OM.PARAMS_NLN_COST(...)

   Returns the parameters N and FCN for the corresponding named general
   nonlinear cost set. Likewise for indexed named sets specified
   by NAME and IDX.

   An optional 3rd output argument VS indicates the variable sets used by
   this cost set.

   See also OPT_MODEL, ADD_NLN_COST, EVAL_NLN_COST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [N, fcn, vs] = params_nln_cost(om, name, idx)
0002 %PARAMS_NLN_COST  Returns cost parameters for general nonlinear costs.
0003 %   [N, FCN] = OM.PARAMS_NLN_COST(NAME)
0004 %   [N, FCN] = OM.PARAMS_NLN_COST(NAME, IDX)
0005 %   [N, FCN, VS] = OM.PARAMS_NLN_COST(...)
0006 %
0007 %   Returns the parameters N and FCN for the corresponding named general
0008 %   nonlinear cost set. Likewise for indexed named sets specified
0009 %   by NAME and IDX.
0010 %
0011 %   An optional 3rd output argument VS indicates the variable sets used by
0012 %   this cost set.
0013 %
0014 %   See also OPT_MODEL, ADD_NLN_COST, EVAL_NLN_COST.
0015 
0016 %   MATPOWER
0017 %   Copyright (c) 2017, Power Systems Engineering Research Center (PSERC)
0018 %   by Ray Zimmerman, PSERC Cornell
0019 %
0020 %   This file is part of MATPOWER.
0021 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0022 %   See https://matpower.org for more info.
0023 
0024 nlc = om.nlc;
0025 if nargin < 3
0026     idx = {};
0027 end
0028 dims = size(nlc.idx.i1.(name));
0029 if ~isempty(idx) || prod(dims) == 1 %% indexed, or simple named set
0030     %% calls to substruct() are relatively expensive, so we pre-build the
0031     %% structs for addressing cell and numeric array fields
0032     %% sn = substruct('.', name, '()', idx);
0033     %% sc = substruct('.', name, '{}', idx);
0034     sc = struct('type', {'.', '{}'}, 'subs', {name, idx});  %% cell array field
0035     sn = sc; sn(2).type = '()';                             %% num array field
0036 
0037     if isempty(idx)
0038         N = nlc.idx.N.(name);
0039         fcn = nlc.data.fcn.(name);
0040         vs = nlc.data.vs.(name);
0041     else
0042         N = subsref(nlc.idx.N, sn);
0043         fcn = subsref(nlc.data.fcn, sc);
0044         vs = subsref(nlc.data.vs, sc);
0045     end
0046 else
0047     error('@opt_model/params_nln_cost: general nonlinear cost set ''%s'' requires an IDX arg', name)
0048 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005