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 % Copyright (c) 2005-2015 by Power System Engineering Research Center (PSERC) 0013 % by Ray Zimmerman, PSERC Cornell 0014 % 0015 % $Id: pricelimits.m 2644 2015-03-11 19:34:22Z ray $ 0016 % 0017 % This file is part of MATPOWER. 0018 % Covered by the 3-clause BSD License (see LICENSE file for details). 0019 % See http://www.pserc.cornell.edu/matpower/ for more info. 0020 0021 if isempty(lim) 0022 if haveQ 0023 lim = struct( 'P', fill_lim([]), 'Q', fill_lim([]) ); 0024 else 0025 lim = struct( 'P', fill_lim([]) ); 0026 end 0027 else 0028 if ~isfield(lim, 'P') 0029 lim.P = []; 0030 end 0031 lim.P = fill_lim(lim.P); 0032 if haveQ 0033 if ~isfield(lim, 'Q') 0034 lim.Q = []; 0035 end 0036 lim.Q = fill_lim(lim.Q); 0037 end 0038 end 0039 0040 0041 0042 function lim = fill_lim(lim) 0043 if isempty(lim) 0044 lim = struct( 'max_offer', [], 'min_bid', [], ... 0045 'max_cleared_offer', [], 'min_cleared_bid', [] ); 0046 else 0047 if ~isfield(lim, 'max_offer'), lim.max_offer = []; end 0048 if ~isfield(lim, 'min_bid'), lim.min_bid = []; end 0049 if ~isfield(lim, 'max_cleared_offer'), lim.max_cleared_offer = []; end 0050 if ~isfield(lim, 'min_cleared_bid'), lim.min_cleared_bid = []; end 0051 end