octave: try to load the needed package before ending with an error

time-shift
Houtan Bastani 2016-09-27 15:26:39 +02:00
parent 1669b274a2
commit 1c892bb3e9
1 changed files with 10 additions and 2 deletions

View File

@ -135,9 +135,17 @@ switch minimizer_algorithm
simulated_annealing(objective_function,start_par_value,sa_options,LB,UB,varargin{:});
case 3
if isoctave && ~user_has_octave_forge_package('optim')
error('Optimization algorithm 3 requires the optim package')
try
pkg load optim
catch
error('Optimization algorithm 3 requires the optim package')
end
elseif ~isoctave && ~user_has_matlab_license('optimization_toolbox')
error('Optimization algorithm 3 requires the Optimization Toolbox')
try
pkg load optimization_toolbox
catch
error('Optimization algorithm 3 requires the Optimization Toolbox')
end
end
% Set default optimization options for fminunc.
optim_options = optimset('display','iter','MaxFunEvals',100000,'TolFun',1e-8,'TolX',1e-6);