I needed to add a call to TaoSetFromOptions to get the runtime options to work. I also set grtol from the default value of 1.0e-7 to 1.0e-15. The calculation goes for a few iterations, but it looks like it keeps pushing into territory where the objective function blows up. It eventually quits with a line search error. The complete output from both the runtime options and the TaoView command looks like
4 TAO, Function value: 9.24265e+85, Residual: 3.11789e+76 TAO solve did not converge due to DIVERGED_LS_FAILURE iteration 4 Tao Object: 1 MPI process type: cg CG Type: prp Gradient steps: 0 Reset steps: 4 TaoLineSearch Object: 1 MPI process type: more-thuente maximum function evaluations=30 tolerances: ftol=0.0001, rtol=1e-10, gtol=0.9 total number of function evaluations=0 total number of gradient evaluations=0 total number of function/gradient evaluations=0 Termination reason: -3 convergence tolerances: gatol=1e-08, steptol=0., gttol=0. Residual in Function/Gradient:=3.11789e+76 Objective value=9.24265e+85 total number of iterations=4, (max: 100) total number of function/gradient evaluations=20, (max: 4000) Solver terminated: -6 Line Search Failure I’ll have to bite the bullet and convert everything into ps, nm, and au to get values down to a range where they are all of order 1 to get this to work. Bruce From: Jed Brown <j...@jedbrown.org> Date: Wednesday, June 26, 2024 at 3:02 PM To: Palmer, Bruce J <bruce.pal...@pnnl.gov>, Barry Smith <bsm...@petsc.dev> Cc: petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov> Subject: Re: [petsc-users] Unconstrained optimization question You can use the PETSC_OPTIONS environment variable to specify options if you don't pass the command line arguments through. You can set -tao_grtol smaller to handle this difference in scales between the objective and the gradient, though applying some nondimensionalization/choice of appropriate units is still recommended. "Palmer, Bruce J via petsc-users" <petsc-users@mcs.anl.gov> writes: > This is a fortran code that doesn’t make use of argc,argv (I tried running > with the runtime options anyway, in case you implemented some magic I’m not > familiar with, but didn’t see anything new in the output). I have a call to > TaoView(tao, PETSC_VIEWER_STDOUT_SELF,ierr) in the code and it reports back > > > > Tao Object: 1 MPI process > > type: cg > > CG Type: prp > > Gradient steps: 0 > > Reset steps: 0 > > TaoLineSearch Object: 1 MPI process > > type: more-thuente > > maximum function evaluations=30 > > tolerances: ftol=0.0001, rtol=1e-10, gtol=0.9 > > total number of function evaluations=0 > > total number of gradient evaluations=0 > > total number of function/gradient evaluations=0 > > Termination reason: 0 > > convergence tolerances: gatol=1e-08, steptol=0., gttol=0. > > Residual in Function/Gradient:=7.54237e+75 > > Objective value=2.96082e+86 > > total number of iterations=0, (max: 100) > > total number of function/gradient evaluations=1, (max: 4000) > > Solution converged: ||g(X)||/|f(X)| <= grtol > > > > Bruce > > From: Barry Smith <bsm...@petsc.dev> > Date: Wednesday, June 26, 2024 at 2:02 PM > To: Palmer, Bruce J <bruce.pal...@pnnl.gov> > Cc: petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov> > Subject: Re: [petsc-users] Unconstrained optimization question > Check twice before you click! This email originated from outside PNNL. > > > Please run with -tao_monitor -tao_converged_reason and see why it has > stopped. > > Barry > > > > On Jun 26, 2024, at 4:34 PM, Palmer, Bruce J via petsc-users > <petsc-users@mcs.anl.gov> wrote: > > This Message Is From an External Sender > This message came from outside your organization. > Hi, > > I’m trying to do an unconstrained optimization on a molecular scale problem. > Previously, I was looking at an artificial molecular problem where all > parameters were of order 1 and so the objective function and variables were > also in the range of 1 or at least within a few orders of magnitude of 1. > > More recently, I’ve been trying to apply this optimization to a real > molecular system. Between Avogadro’s number (6.022e23) and Boltzmann’s > constant (1.38e-16) combined with very small distances (1.0e-8 cm), etc. the > objective function values and the values of the optimization variables have > very large values (~1e86 and ~1e9, respectively). I’ve verified that the > analytic gradients of the objective function that I’m calculating are correct > by comparing them with numerical derivatives. > > I’ve tried using the LMVM and Conjugate Gradient optimizations, both of which > worked previously, but I find that the optimization completes one objective > function evaluation and then declares that the problem is converged and > stops. I could find a set of units where everything is approximately 1 but I > was hoping that there are some parameters I can set in the optimization that > will get it moving again. Any suggestions? > > Bruce Palmer