Home > matpower5.0 > @opt_model > getv.m

getv

PURPOSE ^

GETV Returns initial value, lower bound and upper bound for opt variables.

SYNOPSIS ^

function [v0, vl, vu] = getv(om, name, idx)

DESCRIPTION ^

GETV  Returns initial value, lower bound and upper bound for opt variables.
   [V0, VL, VU] = GETV(OM)
   [V0, VL, VU] = GETV(OM, NAME)
   [V0, VL, VU] = GETV(OM, NAME, IDX)
   Returns the lower bound and upper bound for the full optimization
   variable vector, or for a specific named or name and indexed
   variable set.

   Examples:
       [x, xmin, xmax] = getv(om);
       [Pg, Pmin, Pmax] = getv(om, 'Pg');
       [zij0, zijmin, zijmax] = getv(om, 'z', {i, j});
   
   See also OPT_MODEL.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [v0, vl, vu] = getv(om, name, idx)
0002 %GETV  Returns initial value, lower bound and upper bound for opt variables.
0003 %   [V0, VL, VU] = GETV(OM)
0004 %   [V0, VL, VU] = GETV(OM, NAME)
0005 %   [V0, VL, VU] = GETV(OM, NAME, IDX)
0006 %   Returns the lower bound and upper bound for the full optimization
0007 %   variable vector, or for a specific named or name and indexed
0008 %   variable set.
0009 %
0010 %   Examples:
0011 %       [x, xmin, xmax] = getv(om);
0012 %       [Pg, Pmin, Pmax] = getv(om, 'Pg');
0013 %       [zij0, zijmin, zijmax] = getv(om, 'z', {i, j});
0014 %
0015 %   See also OPT_MODEL.
0016 
0017 %   MATPOWER
0018 %   $Id: getv.m 2048 2012-05-03 12:59:07Z cvs $
0019 %   by Ray Zimmerman, PSERC Cornell
0020 %   Copyright (c) 2008-2012 by Power System Engineering Research Center (PSERC)
0021 %
0022 %   This file is part of MATPOWER.
0023 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0024 %
0025 %   MATPOWER is free software: you can redistribute it and/or modify
0026 %   it under the terms of the GNU General Public License as published
0027 %   by the Free Software Foundation, either version 3 of the License,
0028 %   or (at your option) any later version.
0029 %
0030 %   MATPOWER is distributed in the hope that it will be useful,
0031 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0032 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0033 %   GNU General Public License for more details.
0034 %
0035 %   You should have received a copy of the GNU General Public License
0036 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0037 %
0038 %   Additional permission under GNU GPL version 3 section 7
0039 %
0040 %   If you modify MATPOWER, or any covered work, to interface with
0041 %   other modules (such as MATLAB code and MEX-files) available in a
0042 %   MATLAB(R) or comparable environment containing parts covered
0043 %   under other licensing terms, the licensors of MATPOWER grant
0044 %   you additional permission to convey the resulting work.
0045 
0046 if nargin < 2
0047     v0 = []; vl = []; vu = [];
0048     for k = 1:om.var.NS
0049         name = om.var.order(k).name;
0050         idx = om.var.order(k).idx;
0051         if isempty(idx)
0052             v0 = [ v0; om.var.data.v0.(name) ];
0053             vl = [ vl; om.var.data.vl.(name) ];
0054             vu = [ vu; om.var.data.vu.(name) ];
0055         else
0056             s = substruct('.', name, '{}', idx);
0057             v0 = [ v0; subsref(om.var.data.v0, s) ];
0058             vl = [ vl; subsref(om.var.data.vl, s) ];
0059             vu = [ vu; subsref(om.var.data.vu, s) ];
0060         end
0061     end
0062 else
0063     if isfield(om.var.idx.N, name)
0064         if nargin < 3
0065             v0 = om.var.data.v0.(name);
0066             vl = om.var.data.vl.(name);
0067             vu = om.var.data.vu.(name);
0068         else
0069             s1 = substruct('.', name, '{}', idx);
0070             v0 = subsref(om.var.data.v0, s1);
0071             vl = subsref(om.var.data.vl, s1);
0072             vu = subsref(om.var.data.vu, s1);
0073         end
0074     else
0075         v0 = [];
0076         vl = [];
0077         vu = [];
0078     end
0079 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005