Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Being optimistic for better performance
authorBruno Donassolo <bruno.donassolo@inria.fr>
Mon, 7 Mar 2022 18:10:11 +0000 (19:10 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Mon, 7 Mar 2022 18:10:11 +0000 (19:10 +0100)
If the matrix isn't singular (which is true most of the cases) this
PartialPivLU is much faster than FullPivLU.

Let's be optimistic, what can go wrong? ;)

src/kernel/lmm/bmf.cpp

index 537e869..5f21896 100644 (file)
@@ -184,7 +184,14 @@ Eigen::VectorXd BmfSolver::equilibrium(const allocation_map_t& alloc) const
   XBT_DEBUG("A':\n%s", debug_eigen(A_p).c_str());
 
   XBT_DEBUG("C':\n%s", debug_eigen(C_p).c_str());
-  Eigen::VectorXd rho = Eigen::FullPivLU<Eigen::MatrixXd>(A_p).solve(C_p);
+  /* Being optimist, PartialPivLU is much faster than FullPivLU but requires that the matrix is invertible
+   * FullPivLU however assures that it finds come solution even if the matrix is singular */
+  Eigen::VectorXd rho = Eigen::PartialPivLU<Eigen::MatrixXd>(A_p).solve(C_p);
+  if (rho.array().isNaN().any()) {
+    XBT_DEBUG("rho with nan values, falling back to FullPivLU, rho:\n%s", debug_eigen(rho).c_str());
+    rho = Eigen::FullPivLU<Eigen::MatrixXd>(A_p).solve(C_p);
+  }
+
   for (int p : bounded_players) {
     rho[p] = phi_[p];
   }