This is a static copy of a profile report

Home

checkbounds (860 calls, 0.131 sec)
Generated 05-Aug-2011 13:03:54 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/shared/optimlib/checkbounds.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
fminconfunction860
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
57
if any(eq(ub, -inf)) 
8600.033 s25.0%
63
x = xin;
8600.022 s16.7%
59
elseif any(eq(lb,inf))
8600.022 s16.7%
45
len = min(lenlb,lenub);
8600.011 s8.3%
26
if lenlb > nvars
8600.011 s8.3%
All other lines  0.033 s25.0%
Totals  0.131 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
23The value assigned to variable 'lenx' might be unused.
Coverage results
[ Show coverage for parent directory ]
Total lines in function63
Non-code lines (comments, blank lines)25
Code lines (lines that can run)38
Code lines that did run16
Code lines that did not run22
Coverage (did run/can run)42.11 %
Function listing
   time   calls  line
1 function [x,lb,ub,msg] = checkbounds(xin,lbin,ubin,nvars)
2 %CHECKBOUNDS Verify that the bounds are valid with respect to initial point.
3 %
4 % This is a helper function.
5
6 % [X,LB,UB,X,FLAG] = CHECKBOUNDS(X0,LB,UB,nvars)
7 % checks that the upper and lower
8 % bounds are valid (LB <= UB) and the same length as X (pad with -inf/inf
9 % if necessary); warn if too long. Also make LB and UB vectors if not
10 % already. Finally, inf in LB or -inf in UB throws an error.
11
12 % Copyright 1990-2006 The MathWorks, Inc.
13 % $Revision: 1.1.4.3 $ $Date: 2010/10/08 17:17:20 $
14
860 15 msg = [];
16 % Turn into column vectors
860 17 lb = lbin(:);
860 18 ub = ubin(:);
860 19 xin = xin(:);
20
860 21 lenlb = length(lb);
860 22 lenub = length(ub);
0.01 860 23 lenx = length(xin);
24
25 % Check maximum length
0.01 860 26 if lenlb > nvars
27 warning(message('optimlib:checkbounds:IgnoringExtraLbs'));
28 lb = lb(1:nvars);
29 lenlb = nvars;
860 30 elseif lenlb < nvars
31 lb = [lb; -inf*ones(nvars-lenlb,1)];
32 lenlb = nvars;
33 end
34
860 35 if lenub > nvars
36 warning(message('optimlib:checkbounds:IgnoringExtraUbs'));
37 ub = ub(1:nvars);
38 lenub = nvars;
860 39 elseif lenub < nvars
40 ub = [ub; inf*ones(nvars-lenub,1)];
41 lenub = nvars;
42 end
43
44 % Check feasibility of bounds
0.01 860 45 len = min(lenlb,lenub);
860 46 if any( lb( (1:len)' ) > ub( (1:len)' ) )
47 count = full(sum(lb>ub));
48 if count == 1
49 msg=sprintf(['Exiting due to infeasibility: %i lower bound exceeds the' ...
50 ' corresponding upper bound.'],count);
51 else
52 msg=sprintf(['Exiting due to infeasibility: %i lower bounds exceed the' ...
53 ' corresponding upper bounds.'],count);
54 end
55 end
56 % check if -inf in ub or inf in lb
0.03 860 57 if any(eq(ub, -inf))
58 error(message('optimlib:checkbounds:MinusInfUb'));
0.02 860 59 elseif any(eq(lb,inf))
60 error(message('optimlib:checkbounds:PlusInfLb'));
61 end
62
0.02 860 63 x = xin;