From e6c980fb05fa34e8b011e5c6d62125ea81c2988b Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Tue, 7 Jan 2025 07:31:46 +0100
Subject: [PATCH] IPOpt: Name the arguments of Statistics()->Infeasibilites

This makes the code slightly longer, but also easier to understand.
---
 dune/solvers/solvers/quadraticipopt.hh | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/dune/solvers/solvers/quadraticipopt.hh b/dune/solvers/solvers/quadraticipopt.hh
index 65b695c1..1e516f02 100644
--- a/dune/solvers/solvers/quadraticipopt.hh
+++ b/dune/solvers/solvers/quadraticipopt.hh
@@ -813,10 +813,18 @@ void QuadraticIPOptSolver<MatrixType,VectorType,JacobianType>::solve()
   if (status == Ipopt::Solved_To_Acceptable_Level)
       std::cout<<"WARNING: Desired tolerance could not be reached, but still acceptable tolerance is reached.\n";
   else if (status == Ipopt::Search_Direction_Becomes_Too_Small) {
-      std::array<Ipopt::Number,4> inf;
-      app->Statistics()->Infeasibilities(inf[0],inf[1],inf[2],inf[3]);
-      if (inf[3]>std::max(1e-10,this->tolerance_))
-              DUNE_THROW(Dune::Exception,Dune::formatString("Problem could not be solved to acceptable accuracy %d",inf[3]));
+      Ipopt::Number dual_inf;        // dual infeasibility (Gradient of Lagrangian not zero)
+      Ipopt::Number constr_viol;     // violation of constraints
+      Ipopt::Number complementarity; // violation of complementarity
+      Ipopt::Number kkt_error;       // KKT error
+
+      app->Statistics()->Infeasibilities(dual_inf,
+                                         constr_viol,
+                                         complementarity,
+                                         kkt_error);
+
+      if (kkt_error>std::max(1e-10,this->tolerance_))
+              DUNE_THROW(Dune::Exception,Dune::formatString("Problem could not be solved to acceptable accuracy %d", kkt_error));
 
   } else if (status != Ipopt::Solve_Succeeded)
       DUNE_THROW(Dune::Exception, "IPOpt: Error during optimization!");
-- 
GitLab