From 0ef05d4f99f9915ea381599a2695cde86ef091af Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 14 Dec 2020 14:40:13 +0100 Subject: [PATCH] GCS: Detect dependent parameters (geometry) during diagnosis using two SparseQR factorisations --- src/Mod/Sketcher/App/planegcs/GCS.cpp | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 421450777c..12c6f3dcc5 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -3959,6 +3959,43 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); int constrNum = SqrJT.cols(); if (J.rows() > 0) { + + // Get dependent parameters + { + Eigen::MatrixXd Rparams; + Eigen::SparseQR, Eigen::COLAMDOrdering > SqrJ; + + int nontransprank; // will be the same as for the transpose, but better use a different name + + makeSparseQRDecomposition( J, jacobianconstraintmap, SqrJ, nontransprank, Rparams, false); // do not transpose allow to diagnose parameters + + //int constrNum = SqrJ.rows(); // this is the other way around than for the transposed J + //int paramsNum = SqrJ.cols(); + + eliminateNonZerosOverPivotInUpperTriangularMatrix(Rparams, rank); + +#ifdef _GCS_DEBUG + SolverReportingManager::Manager().LogMatrix("Rparams", Rparams); +#endif + //std::vector< std::vector > dependencyGroups(SqrJ.cols()-rank); + for (int j=nontransprank; j < SqrJ.cols(); j++) { + for (int row=0; row < rank; row++) { + if (fabs(Rparams(row,j)) > 1e-10) { + int origCol = SqrJ.colsPermutation().indices()[row]; + + //dependencyGroups[j-rank].push_back(pdiagnoselist[origCol]); + pdependentparameters.push_back(pdiagnoselist[origCol]); + } + } + int origCol = SqrJ.colsPermutation().indices()[j]; + + //dependencyGroups[j-rank].push_back(pdiagnoselist[origCol]); + pdependentparameters.push_back(pdiagnoselist[origCol]); + } + + } + + // Detecting conflicting or redundant constraints if (constrNum > rank) { // conflicting or redundant constraints