From 567c80fb67013f6b99fecb66664475f1cdfa384e Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 19 Jan 2021 11:25:05 +0100 Subject: [PATCH] GCS: report partially redundant constraints --- src/Mod/Sketcher/App/planegcs/GCS.cpp | 42 +++++++++++++++++++++++---- src/Mod/Sketcher/App/planegcs/GCS.h | 4 ++- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 5d43564bba..d2c3a04e20 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -226,6 +226,7 @@ public: void LogQRSystemInformation(const System &system, int paramsNum = 0, int constrNum = 0, int rank = 0); void LogGroupOfConstraints(const std::string & str, std::vector< std::vector > constraintgroups); + void LogSetOfConstraints(const std::string & str, std::set constraintset); void LogGroupOfParameters(const std::string & str, std::vector< std::vector > parametergroups); void LogMatrix(const std::string str, Eigen::MatrixXd matrix); @@ -368,6 +369,20 @@ void SolverReportingManager::LogGroupOfConstraints(const std::string & str, std: LogString(tempstream.str()); } +void SolverReportingManager::LogSetOfConstraints(const std::string & str, std::set constraintset) +{ + std::stringstream tempstream; + + tempstream << str << ": ["; + + for(auto c : constraintset) + tempstream << c->getTag() << " "; + + tempstream << "]" << '\n'; + + LogString(tempstream.str()); +} + void SolverReportingManager::LogGroupOfParameters(const std::string & str, std::vector< std::vector > parametergroups) { std::stringstream tempstream; @@ -558,6 +573,7 @@ void System::clear() redundant.clear(); conflictingTags.clear(); redundantTags.clear(); + partiallyRedundantTags.clear(); reference.clear(); clearSubSystems(); @@ -3884,6 +3900,7 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n"); redundant.clear(); conflictingTags.clear(); redundantTags.clear(); + partiallyRedundantTags.clear(); // This QR diagnosis uses a reduced Jacobian matrix to calculate the rank of the system and identify // conflicting and redundant constraints. @@ -4482,6 +4499,11 @@ void System::identifyConflictingRedundantConstraints( Algorithm alg, } } + // Augment information regarding the choice made by popularity contest + if(debugMode==IterationLevel) { + SolverReportingManager::Manager().LogSetOfConstraints("Chosen redundants", skipped); + } + std::vector clistTmp; clistTmp.reserve(clist.size()); for (std::vector::iterator constr=clist.begin(); @@ -4560,20 +4582,28 @@ void System::identifyConflictingRedundantConstraints( Algorithm alg, conflictingTags.begin()); // output of redundant tags - SET_I redundantTagsSet; - for (std::set::iterator constr=redundant.begin(); - constr != redundant.end(); ++constr) + SET_I redundantTagsSet, partiallyRedundantTagsSet; + for (std::set::iterator constr=redundant.begin(); constr != redundant.end(); ++constr) { redundantTagsSet.insert((*constr)->getTag()); + partiallyRedundantTagsSet.insert((*constr)->getTag()); + } + // remove tags represented at least in one non-redundant constraint - for (std::vector::iterator constr=clist.begin(); - constr != clist.end(); ++constr) { + for (std::vector::iterator constr=clist.begin(); constr != clist.end(); ++constr) if (redundant.count(*constr) == 0) redundantTagsSet.erase((*constr)->getTag()); - } + redundantTags.resize(redundantTagsSet.size()); std::copy(redundantTagsSet.begin(), redundantTagsSet.end(), redundantTags.begin()); + for(auto r : redundantTagsSet) + partiallyRedundantTagsSet.erase(r); + + partiallyRedundantTags.resize(partiallyRedundantTagsSet.size()); + std::copy(partiallyRedundantTagsSet.begin(), partiallyRedundantTagsSet.end(), + partiallyRedundantTags.begin()); + nonredundantconstrNum = constrNum; } diff --git a/src/Mod/Sketcher/App/planegcs/GCS.h b/src/Mod/Sketcher/App/planegcs/GCS.h index 506fd8f4a8..89c99983ae 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.h +++ b/src/Mod/Sketcher/App/planegcs/GCS.h @@ -125,7 +125,7 @@ namespace GCS int dofs; std::set redundant; - VEC_I conflictingTags, redundantTags; + VEC_I conflictingTags, redundantTags, partiallyRedundantTags; bool hasUnknowns; // if plist is filled with the unknown parameters bool hasDiagnosis; // if dofs, conflictingTags, redundantTags are up to date @@ -361,6 +361,8 @@ namespace GCS { conflictingOut = hasDiagnosis ? conflictingTags : VEC_I(0); } void getRedundant(VEC_I &redundantOut) const { redundantOut = hasDiagnosis ? redundantTags : VEC_I(0); } + void getPartiallyRedundant (VEC_I &partiallyredundantOut) const + { partiallyredundantOut = hasDiagnosis ? partiallyRedundantTags : VEC_I(0); } void getDependentParams(VEC_pD &pdependentparameterlist) const { pdependentparameterlist = pDependentParameters;} void getDependentParamsGroups(std::vector> &pdependentparametergroups) const