From dbe917dcc7bb65101047e887d6e33098e221e011 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 15 Jun 2019 23:22:24 +0200 Subject: [PATCH] GCS: Refactor and additional debug information ============================================== In maximum verbose debug mode, information is given about the groups of Sketcher Constraints that the solver is considering for redundancy or conflict. This is before the popularity contest selects the constraint shown in the solver messages. The main reason for showing this is to enable to diagnose problems with sketches in which the constraint indicated as the redundant one appears not to be the right one. Intended for power users with "iteration level" debug mode. --- src/Mod/Sketcher/App/planegcs/GCS.cpp | 50 +++++++++++++++------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 4836d0fb7e..73204302ce 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -230,8 +230,10 @@ public: void LogQRSystemInformation(const System &system, int paramsNum = 0, int constrNum = 0, int rank = 0); - void LogMatrix(std::string str, Eigen::MatrixXd matrix); - void LogMatrix(std::string str, MatrixIndexType matrix ); + void LogGroupOfConstraints(const std::string & str, std::vector< std::vector > constraintgroups); + + void LogMatrix(const std::string str, Eigen::MatrixXd matrix); + void LogMatrix(const std::string str, MatrixIndexType matrix ); private: SolverReportingManager(); @@ -352,9 +354,27 @@ void SolverReportingManager::LogQRSystemInformation(const System &system, int pa } +void SolverReportingManager::LogGroupOfConstraints(const std::string & str, std::vector< std::vector > constraintgroups) +{ + std::stringstream tempstream; + + tempstream << str << ":" << '\n'; + + for(auto group : constraintgroups) { + tempstream << "["; + + for(auto c :group) + tempstream << c->getTag() << " "; + + tempstream << "]" << '\n';; + } + + LogString(tempstream.str()); +} + #ifdef _GCS_DEBUG -void SolverReportingManager::LogMatrix(std::string str, Eigen::MatrixXd matrix ) +void SolverReportingManager::LogMatrix(const std::string str, Eigen::MatrixXd matrix ) { std::stringstream tempstream; @@ -367,7 +387,7 @@ void SolverReportingManager::LogMatrix(std::string str, Eigen::MatrixXd matrix ) } -void SolverReportingManager::LogMatrix(std::string str, MatrixIndexType matrix ) +void SolverReportingManager::LogMatrix(const std::string str, MatrixIndexType matrix ) { std::stringstream tempstream; @@ -4131,24 +4151,10 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); conflictGroups[j-rank].push_back(clist[jacobianconstraintmap.at(origCol)]); } -#ifdef _GCS_DEBUG_SOLVER_JACOBIAN_QR_DECOMPOSITION_TRIANGULAR_MATRIX - - stream.flush(); - - stream << "ConflictGroups: ["; - for(auto group :conflictGroups) { - stream << "["; - - for(auto c :group) - stream << c->getTag(); - - stream << "]"; - } - stream << "]" << std::endl; - - tmp = stream.str(); - SolverReportingManager::Manager().LogString(tmp); -#endif + // Augment the information regarding the group of constraints that are conflicting or redundant. + if(debugMode==IterationLevel) { + SolverReportingManager::Manager().LogGroupOfConstraints("Analysing groups of constraints of special interest", conflictGroups); + } // try to remove the conflicting constraints and solve the // system in order to check if the removed constraints were