


Computes the maximal step length at point 'x' in direction 'dir' to be still in the inner area of barriered constraints At the moment, the only supported constraints in a barrier are box constraints. For others it is necessary to change this func. Function has to be initiated from the outer loop level (where constraints are not composed to the augmented Lagrangian yet). To init call: get_maxstep(x,[],barind,gx,dgx); where 'barind' is a list of indicies of the constraints in the barrier, gx, dgx are function and gradient values of inequality constraints After the initialization it is possible to use the function in the inner loop: rMaxStep=get_maxstep(x,dir); The step length is limited to maximal length 1.0. If the function is not initializated or no restrictions are given, returns 1.0 always.


0001 function [rRelLength] = get_maxstep(obj,x,dir,varargin) 0002 % Computes the maximal step length at point 'x' in direction 'dir' 0003 % to be still in the inner area of barriered constraints 0004 % At the moment, the only supported constraints in a barrier are 0005 % box constraints. For others it is necessary to change this func. 0006 % 0007 % Function has to be initiated from the outer loop level (where constraints 0008 % are not composed to the augmented Lagrangian yet). To init call: 0009 % get_maxstep(x,[],barind,gx,dgx); 0010 % where 'barind' is a list of indicies of the constraints in the barrier, 0011 % gx, dgx are function and gradient values of inequality constraints 0012 % 0013 % After the initialization it is possible to use the function in 0014 % the inner loop: rMaxStep=get_maxstep(x,dir); 0015 % The step length is limited to maximal length 1.0. 0016 % 0017 % If the function is not initializated or no restrictions are given, 0018 % returns 1.0 always. 0019 % 0020 0021 % 0022 % last update: 10/08/2009 0023 % 0024 0025 error('not adjusted for PenLab yet.'); 0026 % all considered barriered constraints are of the form: +/-1*x_i + c_j<=0 0027 % the j-th constraint is: xsgn(j) * x(xidx(j)) + constants(j) <=0 0028 persistent no_bconst; % number of these (barriered) constraints 0029 persistent constants; % constants c_j, j=1:no_constr 0030 persistent xidx; % there is x(xidx(j)) in the j-th constraint 0031 persistent xsgn; % ... with sign xsgn(j) 0032 0033 % distance from the boundary? 0034 bound_margin = 0.95; 0035 0036 % initialization 0037 if (size(varargin,2) > 0) 0038 rRelLength=1.0; % doesn't really matter 0039 if (size(varargin,2) ~= 3) 0040 pen_out(5,Inf,'Error@get_maxstep.m: Inconsistant call, user error?'); 0041 return; 0042 end 0043 barind=varargin{1}; 0044 gx=varargin{2}; 0045 dgx=varargin{3}; 0046 0047 no_bconst=length(barind); 0048 if (no_bconst~=0) 0049 [xidx,col_ignore,xsgn]=find(dgx(:,barind)); 0050 % in each column there should be exactly one entry +1 or -1 0051 % in the row appropriate to the index of 'x' 0052 % sorted column-wise 0053 constants=gx(barind)-xsgn.*x(xidx); 0054 else 0055 constants=[]; 0056 xidx=[]; 0057 xsgn=[]; 0058 end 0059 return; 0060 end 0061 0062 % normal usage - no restriction/not init 0063 if (isempty(no_bconst) || no_bconst==0) 0064 rRelLength = 1.0; 0065 return; 0066 end 0067 0068 % normal usage - restrictions apply 0069 sdir=xsgn.*dir(xidx); 0070 idx=find(sdir > 0); 0071 rRelLength=min([-bound_margin*(constants(idx) + xsgn(idx).*x(xidx(idx)))./sdir(idx); 1.0]); 0072 %rRelLength=min(1.0, rRelLength); 0073 0074 return; 0075