xref: /petsc/src/tao/leastsquares/tutorials/matlab/ProblemInitialize.m (revision c20d77252dee0f9c80fc6f8b1a6f948e11175edb)
1*c4762a1bSJed Brown% Sample calling syntax for testing taopounders and comparing to fminsearch
2*c4762a1bSJed Brown% ProblemInitialize is called prior to solving the instance
3*c4762a1bSJed Brown%   The taopounders driver sets np, the problem instance number
4*c4762a1bSJed Brown%   This code then initializes the rest of the information needed
5*c4762a1bSJed Brown
6*c4762a1bSJed Brownnprob = dfo(np,1);    % Internal index for the problem
7*c4762a1bSJed Brownn = dfo(np,2);        % Number of variables
8*c4762a1bSJed Brownm = dfo(np,3);        % Number of residuals
9*c4762a1bSJed Brown
10*c4762a1bSJed Brown% Initialize the starting point
11*c4762a1bSJed Brownfactor = 10;
12*c4762a1bSJed Brownfactor_power = dfo(np,4);
13*c4762a1bSJed BrownX0 = dfoxs(n,nprob,factor^factor_power)';
14*c4762a1bSJed Brown
15*c4762a1bSJed Brown% Initialize the function handle for evaluating the residuals
16*c4762a1bSJed Brownfunc = @(x)dfovec_wrap(m,n,x,nprob,1);
17*c4762a1bSJed Brownjac = @(x)jacobian(m,n,x,nprob);
18*c4762a1bSJed Brown
19*c4762a1bSJed Brown% Initialize the algorithmic parameters for taopounders
20*c4762a1bSJed Brownnfmax = nf_const*(n+1);   % Maximum number of function evaluations
21*c4762a1bSJed Brownnpmax = 2*n+1;            % Maximum number of interpolation points
22*c4762a1bSJed Browndelta = 0.1;              % Initial trust region radius
23*c4762a1bSJed Brown
24*c4762a1bSJed Brown% Reset the global history of the evaluations
25*c4762a1bSJed Brownnfev = 0;
26*c4762a1bSJed Brownfvals = zeros(nfmax,1);
27*c4762a1bSJed Brownfvecs = zeros(nfmax,m);
28*c4762a1bSJed BrownX_hist = zeros(nfmax,n);
29*c4762a1bSJed Brown
30*c4762a1bSJed Brown% Control returns to taopounders interface to solve the problem
31*c4762a1bSJed Brown
32