This is a static copy of a profile reportHome
getIpOptions (860 calls, 2.907 sec)
Generated 05-Aug-2011 13:03:52 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/optim/optim/getIpOptions.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
fmincon | function | 860 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
18 | options_ip.(field) = optimget(... | 21500 | 1.749 s | 60.2% |  |
36 | [options_ip.(field),ME] = getN... | 3440 | 0.470 s | 16.2% |  |
94 | SubproblemAlgorithm = optimget... | 860 | 0.098 s | 3.4% |  |
17 | field = fieldsThatDontNeedProc... | 21500 | 0.077 s | 2.6% |  |
19 | end | 21500 | 0.066 s | 2.3% |  |
All other lines | | | 0.448 s | 15.4% |  |
Totals | | | 2.907 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 136 |
Non-code lines (comments, blank lines) | 60 |
Code lines (lines that can run) | 76 |
Code lines that did run | 36 |
Code lines that did not run | 40 |
Coverage (did run/can run) | 47.37 % |
Function listing
time calls line
1 function [options_ip,optionFeedback] = getIpOptions(options,nVar,mEq,nonlconflag,defaultopt,defaultHessMemory,defaultPivotThreshold)
2 %getIpOptions Helper function that creates structure of internal options
3 % options_ip based on the values in user-supplied structure "options" and
4 % on defaultopt
5
6 % Copyright 2007-2010 The MathWorks, Inc.
7 % $Revision: 1.1.6.6 $ $Date: 2010/11/01 19:41:28 $
8
9 % Read in all options fields that don't need processing
0.01 860 10 fieldsThatDontNeedProcessing = {'AlwaysHonorConstraints';'DerivativeCheck'; ...
11 'Diagnostics';'DiffMaxChange';'DiffMinChange';'Display';'FinDiffType'; ...
12 'FunValCheck';'GradConstr';'GradObj';'HessFcn';'HessMult';'InitBarrierParam'; ...
13 'MaxIter';'ObjectiveLimit';'OutputFcn';'PlotFcns';'ScaleProblem'; ...
14 'TolCon';'TolFun';'TolGradCon';'TolProjCG';'TolProjCGAbs';'TolX';'UseParallel'};
15
860 16 for i = 1:numel(fieldsThatDontNeedProcessing)
0.08 21500 17 field = fieldsThatDontNeedProcessing{i};
1.75 21500 18 options_ip.(field) = optimget(options,field,defaultopt,'fast');
0.07 21500 19 end
20
21 % Now read-in all fields that can be either a string or a numeric value
22 % Each row of cell array below contains:
23 % field name, allowed string, equivalent numeric value, datatype (with appropriate article)
24 % for error message
0.02 860 25 numericOrStringFields = ... % NB: This is a *2-dimensional* cell-array
26 {'MaxFunEvals','100*numberofvariables',100*nVar,'an integer';
27 'InitTrustRegionRadius','sqrt(numberofvariables)',sqrt(nVar),'a real';
28 'MaxProjCGIter','2*(numberofvariables-numberofequalities)',max(2*(nVar-mEq),0),'a matrix';
29 'TypicalX','ones(numberofvariables,1)',ones(nVar,1),'a real matrix'};
30
0.03 860 31 for i = 1:size(numericOrStringFields,1)
0.04 3440 32 field = numericOrStringFields{i,1};
0.02 3440 33 allowedString = numericOrStringFields{i,2};
0.02 3440 34 equivNumValue = numericOrStringFields{i,3};
0.01 3440 35 dataType = numericOrStringFields{i,4};
0.47 3440 36 [options_ip.(field),ME] = getNumericOrStringFieldValue(field,allowedString, ...
37 equivNumValue,dataType,options,defaultopt);
0.03 3440 38 if ~isempty(ME)
39 throwAsCaller(ME)
40 end
0.03 3440 41 end
42
43 % TypicalX, the same as x, needs to be a column vector inside algorithm
860 44 options_ip.TypicalX = options_ip.TypicalX(:);
45
46 % Now read-in fields that need special processing
47
48 % Option Hessian can be either a string or a cell array. So as not
49 % to have to check for this inside barrier.m at every iteration,
50 % we create one or two internal options: HessType and HessMemory.
0.05 860 51 Hessian = optimget(options,'Hessian',defaultopt,'fast');
0.01 860 52 options_ip.HessMemory = defaultHessMemory;
0.01 860 53 if ischar(Hessian)
54 % If Hessian user-supplied, on, fin-diff-grads, gradients must be on
860 55 if ( strcmpi(Hessian,'user-supplied') || strcmpi(Hessian,'on') ...
56 || strcmpi(Hessian,'fin-diff-grads') ) && ...
57 ( strcmpi(options_ip.GradObj,'off') || nonlconflag && strcmpi(options_ip.GradConstr,'off') )
58 mexcptn = MException('optim:getIpOptions:HessButNoGrads', ...
59 'Must set GradObj = ''on'' and (if nonlinear constraints are present)\nGradConstr = ''on'' in order to use option Hessian = ''%s''.',Hessian);
60 throwAsCaller(mexcptn);
61 end
860 62 if strcmpi(Hessian,'off')
63 % No Hessian function provided and old value; set to default
64 options_ip.HessType = defaultopt.Hessian;
860 65 elseif strcmpi(Hessian,'user-supplied') || strcmpi(Hessian,'on')
66 % Hessian provided, either via options HessFcn or HessMult
67 if ~isempty(options.HessFcn)
68 options_ip.HessType = 'user-supplied';
69 if ~isempty(options.HessMult)
70 % Both HessFcn and HessMult provided; honor HessFcn
71 warning(message('optim:getIpOptions:BothHessFcnHessMult'))
72 end
73 elseif ~isempty(options.HessMult)
74 options_ip.HessType = 'hessmult';
75 else
76 % Hessian user-supplied but no HessFcn nor HessMult
77 mexcptn = MException('optim:getIpOptions:BadHessOptions', ...
78 'Hessian option set to ''%s'' but no Hessian function provided in options HessFcn nor in HessMult.',Hessian);
79 throwAsCaller(mexcptn);
80 end
860 81 else % any of the current legal string values for Hessian option
860 82 options_ip.HessType = Hessian;
860 83 end
84 elseif iscell(Hessian)
85 options_ip.HessType = Hessian{1};
86 if numel(Hessian) > 1
87 options_ip.HessMemory = Hessian{2};
88 end
89 end
90
91 % SubproblemAlgorithm corresponds to three internal options: IpAlgorithm,
92 % LinearSystemSolver, and PivotThreshold.
93 % The value of SubproblemAlgorithm can be either a string or a cell array
0.10 860 94 SubproblemAlgorithm = optimget(options,'SubproblemAlgorithm',defaultopt,'fast');
95
96 % Store subproblem algorithm in a string for easy processing
97 % and read-in pivot threshold
98 % Because of error checking in options functions, SubproblemAlgorithm
99 % can only be either a string or a cell array.
860 100 if ischar(SubproblemAlgorithm)
860 101 SubproblemAlgorithm_string = SubproblemAlgorithm;
860 102 options_ip.PivotThreshold = defaultPivotThreshold;
103 elseif iscell(SubproblemAlgorithm)
104 SubproblemAlgorithm_string = SubproblemAlgorithm{1};
105 if numel(SubproblemAlgorithm) > 1
106 % Pivot threshold passed in with option
107 options_ip.PivotThreshold = SubproblemAlgorithm{2};
108 else
109 options_ip.PivotThreshold = defaultPivotThreshold;
110 end
111 end
112
860 113 if strcmpi(SubproblemAlgorithm_string,'ldl-factorization')
0.01 860 114 options_ip.IpAlgorithm = 'direct';
0.01 860 115 options_ip.LinearSystemSolver = 'ldl-factorization';
116 elseif strcmpi(SubproblemAlgorithm_string,'cg')
117 options_ip.IpAlgorithm = 'cg';
118 options_ip.LinearSystemSolver = 'ldl-factorization';
119 end
120
121 % Must select SubproblemAlgorithm = 'cg' in order to user fin-diff-grads or HessMult
860 122 if ~strcmpi(options_ip.IpAlgorithm,'cg')
860 123 if strcmpi(options_ip.HessType,'fin-diff-grads')
124 mexcptn = MException('optim:getIpOptions:FinDiffGradsAndNotCG', ...
125 'In order to use option Hessian = ''fin-diff-grads'', option SubproblemAlgorithm\n must be set to ''cg''.');
126 throwAsCaller(mexcptn);
0.01 860 127 elseif strcmpi(options_ip.HessType,'hessmult')
128 mexcptn = MException('optim:getIpOptions:HessMultAndNotCG', ...
129 'In order to use option HessMult, option SubproblemAlgorithm must be set to ''cg''.');
130 throwAsCaller(mexcptn);
131 end
860 132 end
133
134 % Prepare strings to give feedback to users on options they have or have not set.
135 % These are used in the exit messages.
0.05 860 136 optionFeedback = createOptionFeedback(options);