1 function [Lip_H,model] = calculate_Lipschitz_const(model, varargin)
2 %
function Lip_H = calculate_Lipschit_const(model, varargin)
4 %
function caluclates the Lipschitz constant
using detailed simulations, which is needed
for the
5 % non-iterative error estimator in optimization.
12 % Markus Dihlmann 03.01.2013
14 compute_derivative_info_old = model.compute_derivative_info;
16 %see
if there
's model_data
18 model_data = varargin{1};
19 if isempty(model_data)
20 model_data = gen_model_data(model);
23 model_data = gen_model_data(model);
26 %see if there's a mu given
30 model = set_mu(model, mu);
34 %claculate the Hessian
35 disp('performing detailed simulations to calculate the Lipschitz constant')
36 H_der = lin_evol_opt_fd_Hessian_der(model, model_data,[]);
38 model = setfield_in_model_and_base_model(model,'compute_derivative_info', 0);
39 HgradJ = zeros(size(H_der));
42 sim_data_dummy.U = H_der{k,l};
43 sim_data_dummy = model.get_output(model, sim_data_dummy,model_data);
44 HgradJ(k,l) = sim_data_dummy.y(end);
49 model = setfield_in_model_and_base_model(model,
'compute_derivative_info', compute_derivative_info_old);
51 %
return Lipschitz constant