PRICELIMITS Fills in a struct with default values for offer/bid limits. LIM = PRICELIMITS(LIM, HAVEQ) The final structure looks like: LIM.P.min_bid - bids below this are withheld .max_offer - offers above this are withheld .min_cleared_bid - cleared bid prices below this are clipped .max_cleared_offer - cleared offer prices above this are clipped .Q (optional, same structure as P)
0001 function lim = pricelimits(lim, haveQ) 0002 %PRICELIMITS Fills in a struct with default values for offer/bid limits. 0003 % LIM = PRICELIMITS(LIM, HAVEQ) 0004 % The final structure looks like: 0005 % LIM.P.min_bid - bids below this are withheld 0006 % .max_offer - offers above this are withheld 0007 % .min_cleared_bid - cleared bid prices below this are clipped 0008 % .max_cleared_offer - cleared offer prices above this are clipped 0009 % .Q (optional, same structure as P) 0010 0011 % MATPOWER 0012 % $Id: pricelimits.m,v 1.5 2010/04/26 19:45:26 ray Exp $ 0013 % by Ray Zimmerman, PSERC Cornell 0014 % Copyright (c) 2005-2010 by Power System Engineering Research Center (PSERC) 0015 % 0016 % This file is part of MATPOWER. 0017 % See http://www.pserc.cornell.edu/matpower/ for more info. 0018 % 0019 % MATPOWER is free software: you can redistribute it and/or modify 0020 % it under the terms of the GNU General Public License as published 0021 % by the Free Software Foundation, either version 3 of the License, 0022 % or (at your option) any later version. 0023 % 0024 % MATPOWER is distributed in the hope that it will be useful, 0025 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0026 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0027 % GNU General Public License for more details. 0028 % 0029 % You should have received a copy of the GNU General Public License 0030 % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. 0031 % 0032 % Additional permission under GNU GPL version 3 section 7 0033 % 0034 % If you modify MATPOWER, or any covered work, to interface with 0035 % other modules (such as MATLAB code and MEX-files) available in a 0036 % MATLAB(R) or comparable environment containing parts covered 0037 % under other licensing terms, the licensors of MATPOWER grant 0038 % you additional permission to convey the resulting work. 0039 0040 if isempty(lim) 0041 if haveQ 0042 lim = struct( 'P', fill_lim([]), 'Q', fill_lim([]) ); 0043 else 0044 lim = struct( 'P', fill_lim([]) ); 0045 end 0046 else 0047 if ~isfield(lim, 'P') 0048 lim.P = []; 0049 end 0050 lim.P = fill_lim(lim.P); 0051 if haveQ 0052 if ~isfield(lim, 'Q') 0053 lim.Q = []; 0054 end 0055 lim.Q = fill_lim(lim.Q); 0056 end 0057 end 0058 0059 0060 0061 function lim = fill_lim(lim) 0062 if isempty(lim) 0063 lim = struct( 'max_offer', [], 'min_bid', [], ... 0064 'max_cleared_offer', [], 'min_cleared_bid', [] ); 0065 else 0066 if ~isfield(lim, 'max_offer'), lim.max_offer = []; end 0067 if ~isfield(lim, 'min_bid'), lim.min_bid = []; end 0068 if ~isfield(lim, 'max_cleared_offer'), lim.max_cleared_offer = []; end 0069 if ~isfield(lim, 'min_cleared_bid'), lim.min_cleared_bid = []; end 0070 end