[petsc-users] TAO PDIPM handling of objective evaluation failures (NaN / PDE non-convergence)

Barry Smith bsmith at petsc.dev
Thu Dec 4 09:31:55 CST 2025


  Simon,

    Thanks for the question. We would love to have such functionality in TAO, but we do not currently have it. 

    For SNES, we provide SNESSetFunctionDomainError() and SNESSetJacobianDomainError() which can be called (on any subset of the MPI processes in the MPI communicator) to indicate such a domain error. Currently, SNES simply checks this way (in a collective, friendly manner without extra communication) and returns a clean SNES_DIVERGED_FUNCTION_DOMAIN via the SNESConvergedReason.  We would like at least some of the SNES solvers to handle this better, as you suggest, by backtracking to find a valid point in the domain.

  For TS we provide TSSetFunctionDomainError(), which allows the user to pass in a function to check if a point is in the domain. It is currently unused. I think it should use the same approach as SNES.

  So for TAO, I envision a similar TaoSetFunctionDomainError(), TaoSetJacobianDomainError(), and TaoSetHessianDomainError(), which would allow particular TAO solvers to "back off" but continue running as you request. 

  Would you be interested in collaborating with us on adding such support to Tao? In particular, focusing exactly on the Tao solver algorithm you are using?  We don't currently have PETSc developers focusing on Tao, so can only make progress on it by actively collaborating with others who need new/improved functionality.


   Barry


> On Dec 4, 2025, at 3:03 AM, Simon Wiesheier <simon.wiesheier at gmail.com> wrote:
> 
> Dear PETSc developers and users,
> I am considering using TAO’s Primal-Dual Interior-Point Method (PDIPM) for a constrained optimization problem in solid mechanics. The objective involves solving a nonlinear PDE (hyperelasticity) for each parameter vector, and for some parameter combinations the PDE solver may fail to converge or produce non-physical states.
> 
> With MATLAB’s fmincon, it is possible to signal such failures by returning NaN/Inf for the objective, and the solver will then backtrack or try a different step without crashing.
> 
> My questions are:
> 
> How does TAO’s PDIPM handle cases where the user objective or gradient callback returns NaN/Inf (e.g., due to PDE solver failure)?
> 
> Is there a recommended way in TAO/PETSc to gracefully signal an evaluation failure (like “bad point in parameter space”) so that the algorithm can back off and try a smaller step, instead of aborting?
> 
> If the recommended pattern is not to return NaNs, what is the best practice in TAO for such PDE-constrained problems?
> 
> Any guidance on how TAO/PDIPM is intended to behave in the presence of evaluation failures would be greatly appreciated.
> 
> Best regards,
> 
> Simon
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20251204/694da685/attachment.html>


More information about the petsc-users mailing list