<div dir="ltr">Hi, I have a question about the TAO BRGN algorithm for least-squares optimization. It seems to be calling the user-supplied Jacobian routine twice for each point in the parameter space, unnecessarily increasing the amount of computation. This can be seen by inserting the lines<br>printf("EvaluateFunction called at x = %.15e, %.15e, %.15e\n",x[0],x[1],x[2]);<br>and<br>printf("EvaluateJacobian called at x = %.15e, %.15e, %.15e\n",x[0],x[1],x[2]);<br>into the petsc example src/tao/leastsquares/examples/tutorials/chwirut1.c at line numbers 128 and 150 respectively. Then running<br>./chwirut1 -tao_type brgn<br>the output is<br>EvaluateFunction called at x = 1.500000000000000e-01, 8.000000000000000e-03, 1.000000000000000e-02<br>EvaluateJacobian called at x = 1.500000000000000e-01, 8.000000000000000e-03, 1.000000000000000e-02<br>EvaluateJacobian called at x = 1.500000000000000e-01, 8.000000000000000e-03, 1.000000000000000e-02<br>EvaluateFunction called at x = 1.678609230300274e-01, 5.606199685573443e-03, 1.143975621188315e-02<br>EvaluateJacobian called at x = 1.678609230300274e-01, 5.606199685573443e-03, 1.143975621188315e-02<br>EvaluateJacobian called at x = 1.678609230300274e-01, 5.606199685573443e-03, 1.143975621188315e-02<br>EvaluateFunction called at x = 1.895677598936882e-01, 6.141611118905459e-03, 1.052387574144709e-02<br>EvaluateJacobian called at x = 1.895677598936882e-01, 6.141611118905459e-03, 1.052387574144709e-02<br>EvaluateJacobian called at x = 1.895677598936882e-01, 6.141611118905459e-03, 1.052387574144709e-02<br>EvaluateFunction called at x = 1.901553874099915e-01, 6.129649283393148e-03, 1.053528933460132e-02<br>EvaluateJacobian called at x = 1.901553874099915e-01, 6.129649283393148e-03, 1.053528933460132e-02<br>EvaluateJacobian called at x = 1.901553874099915e-01, 6.129649283393148e-03, 1.053528933460132e-02<br>EvaluateFunction called at x = 1.902758303510814e-01, 6.131413563754055e-03, 1.053093200323840e-02<br>EvaluateJacobian called at x = 1.902758303510814e-01, 6.131413563754055e-03, 1.053093200323840e-02<br>EvaluateJacobian called at x = 1.902758303510814e-01, 6.131413563754055e-03, 1.053093200323840e-02<br>EvaluateFunction called at x = 1.902779152522651e-01, 6.131396913966817e-03, 1.053091761136939e-02<br>EvaluateJacobian called at x = 1.902779152522651e-01, 6.131396913966817e-03, 1.053091761136939e-02<br>EvaluateJacobian called at x = 1.902779152522651e-01, 6.131396913966817e-03, 1.053091761136939e-02<br>EvaluateFunction called at x = 1.902781772105115e-01, 6.131400452825695e-03, 1.053090850459907e-02<br>EvaluateJacobian called at x = 1.902781772105115e-01, 6.131400452825695e-03, 1.053090850459907e-02<br>EvaluateJacobian called at x = 1.902781772105115e-01, 6.131400452825695e-03, 1.053090850459907e-02<br>EvaluateFunction called at x = 1.902781831060656e-01, 6.131400440501068e-03, 1.053090841847083e-02<br>EvaluateJacobian called at x = 1.902781831060656e-01, 6.131400440501068e-03, 1.053090841847083e-02<br>EvaluateJacobian called at x = 1.902781831060656e-01, 6.131400440501068e-03, 1.053090841847083e-02<br>EvaluateFunction called at x = 1.902781836794117e-01, 6.131400447676857e-03, 1.053090839927484e-02<br>EvaluateJacobian called at x = 1.902781836794117e-01, 6.131400447676857e-03, 1.053090839927484e-02<br>EvaluateJacobian called at x = 1.902781836794117e-01, 6.131400447676857e-03, 1.053090839927484e-02<br>EvaluateFunction called at x = 1.902781836950446e-01, 6.131400447696052e-03, 1.053090839897943e-02<br>EvaluateJacobian called at x = 1.902781836950446e-01, 6.131400447696052e-03, 1.053090839897943e-02<br>This shows that every call to EvaluateJacobian (except the last) is actually two calls at the same point. Is there a way to eliminate these redundant Jacobian evaluations? <div><br>Thanks,<br>Matt Landreman<br><br><br>P.S. I'm using petsc 3.12.2, and in case it's helpful, the output of -tao_view is copied here:<br>Tao Object: 1 MPI processes<br>  type: brgn<br>    Tao Object: (tao_brgn_subsolver_) 1 MPI processes<br>      type: bnls<br>        Rejected BFGS updates: 0<br>        CG steps: 0<br>        Newton steps: 9<br>        BFGS steps: 0<br>        Scaled gradient steps: 0<br>        Gradient steps: 0<br>        KSP termination reasons:<br>          atol: 0<br>          rtol: 9<br>          ctol: 0<br>          negc: 0<br>          dtol: 0<br>          iter: 0<br>          othr: 0<br>      TaoLineSearch Object: (tao_brgn_subsolver_) 1 MPI processes<br>        type: more-thuente<br>        maximum function evaluations=30<br>        tolerances: ftol=0.0001, rtol=1e-10, gtol=0.9<br>        total number of function evaluations=0<br>        total number of gradient evaluations=0<br>        total number of function/gradient evaluations=1<br>        Termination reason: 1<br>      KSP Object: (tao_brgn_subsolver_) 1 MPI processes<br>        type: stcg<br>        maximum iterations=10000, initial guess is zero<br>        tolerances:  relative=1e-05, absolute=1e-50, divergence=10000.<br>        left preconditioning<br>        using UNPRECONDITIONED norm type for convergence test<br>      PC Object: (tao_brgn_subsolver_) 1 MPI processes<br>        type: lmvm<br>        Mat Object: (pc_lmvm_) 1 MPI processes<br>          type: lmvmbfgs<br>          rows=3, cols=3<br>            Scale type: diagonal<br>            Scale history: 1<br>            Scale params: alpha=1., beta=0.5, rho=1.<br>            Convex factors: phi=0., theta=0.125<br>            Max. storage: 5<br>            Used storage: 5<br>            Number of updates: 8<br>            Number of rejects: 0<br>            Number of resets: 0<br>            Mat Object: (J0_) 1 MPI processes<br>              type: lmvmdiagbrdn<br>              rows=3, cols=3<br>                Scale history: 1<br>                Scale params: alpha=1., beta=0.5, rho=1.<br>                Convex factor: theta=0.125<br>                Max. storage: 1<br>                Used storage: 1<br>                Number of updates: 8<br>                Number of rejects: 0<br>                Number of resets: 0<br>        linear system matrix = precond matrix:<br>        Mat Object: 1 MPI processes<br>          type: shell<br>          rows=3, cols=3<br>      total KSP iterations: 27<br>      Active Set subset type: subvec<br>      convergence tolerances: gatol=1e-08,       steptol=0.,       gttol=0.<br>      Residual in Function/Gradient:=4.30981e-07<br>      Objective value=1192.24<br>      total number of iterations=9,                              (max: 2000)<br>      total number of function evaluations=10,                      max: 4000<br>      total number of function/gradient evaluations=10,          (max: 4000)<br>      total number of Hessian evaluations=9<br>      total number of Jacobian evaluations=19<br>      Solution converged:        ||g(X)||/|f(X)| <= grtol<br>  convergence tolerances: gatol=1e-08,   steptol=0.,   gttol=0.<br>  Residual in Function/Gradient:=0.<br>  Objective value=0.<br>  total number of iterations=9,                          (max: 2000)<br>  total number of function evaluations=10,                  max: 4000<br>  total number of function/gradient evaluations=10,      (max: 4000)<br>  total number of Hessian evaluations=9<br>  Solution converged:    ||g(X)||/|f(X)| <= grtol<br><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>=======================================</div><div>Dr. Matt Landreman</div><div>Associate Research Scientist</div><div>Institute for Research in Electronics & Applied Physics</div><div>University of Maryland</div><div>8223 Paint Branch Drive, College Park MD 20742, USA</div><div>(+1) 651-366-9306</div><div><a href="mailto:mattland@umd.edu" target="_blank">mattland@umd.edu</a></div></div></div></div></div>