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