Gateway helper function to call a Manopt solver, chosen in the options. function [x, cost, info, options] = manoptsolve(problem) function [x, cost, info, options] = manoptsolve(problem, x0) function [x, cost, info, options] = manoptsolve(problem, x0, options) function [x, cost, info, options] = manoptsolve(problem, [], options) Depending on what is available in the Manopt problem structure, one of the Manopt solvers will be called and the outputs passed along. It is also possible to force the choice of a solver by specifying it in the options structure. For example: options.solver = @trustregions; Simply specify a function handle to a Manopt solver. See also: trustregions conjugategradient steepestdescent
0001 function [x, cost, info, options] = manoptsolve(problem, x0, options) 0002 % Gateway helper function to call a Manopt solver, chosen in the options. 0003 % 0004 % function [x, cost, info, options] = manoptsolve(problem) 0005 % function [x, cost, info, options] = manoptsolve(problem, x0) 0006 % function [x, cost, info, options] = manoptsolve(problem, x0, options) 0007 % function [x, cost, info, options] = manoptsolve(problem, [], options) 0008 % 0009 % Depending on what is available in the Manopt problem structure, one of 0010 % the Manopt solvers will be called and the outputs passed along. It is 0011 % also possible to force the choice of a solver by specifying it in the 0012 % options structure. For example: 0013 % 0014 % options.solver = @trustregions; 0015 % 0016 % Simply specify a function handle to a Manopt solver. 0017 % 0018 % See also: trustregions conjugategradient steepestdescent 0019 0020 % This file is part of Manopt: www.manopt.org. 0021 % Original author: Nicolas Boumal, Aug. 13, 2014. 0022 % Contributors: 0023 % Change log: 0024 0025 % At the very least, we need a cost function. 0026 if ~canGetCost(problem) 0027 error('The problem structure must specify a cost function.'); 0028 end 0029 0030 % Depending on the number of differentials available, pick a different 0031 % default solver. 0032 if ~canGetGradient(problem) 0033 localdefaults.solver = @neldermead; 0034 elseif ~canGetHessian(problem) 0035 localdefaults.solver = @conjugategradient; 0036 else 0037 localdefaults.solver = @trustregions; 0038 end 0039 0040 % Merge local defaults with user options, if any. 0041 if ~exist('options', 'var') || isempty(options) 0042 options = struct(); 0043 end 0044 options = mergeOptions(localdefaults, options); 0045 0046 % If no initial guess was specified, prepare the empty one. 0047 if ~exist('x0', 'var') 0048 x0 = []; 0049 end 0050 0051 % Issue the actual call. 0052 [x, cost, info, options] = options.solver(problem, x0, options); 0053 0054 end