diff --git a/src/Mod/Sketcher/App/Sketch.h b/src/Mod/Sketcher/App/Sketch.h index 9e613e973..0c7026283 100644 --- a/src/Mod/Sketcher/App/Sketch.h +++ b/src/Mod/Sketcher/App/Sketch.h @@ -386,6 +386,7 @@ public: inline void setConvergence(double conv){GCSsys.convergence=conv;} inline void setConvergenceRedundant(double conv){GCSsys.convergenceRedundant=conv;} inline void setQRAlgorithm(GCS::QRAlgorithm alg){GCSsys.qrAlgorithm=alg;} + inline void setQRPivotThreshold(double val){GCSsys.qrpivotThreshold=val;} inline void setLM_eps(double val){GCSsys.LM_eps=val;} inline void setLM_eps1(double val){GCSsys.LM_eps1=val;} inline void setLM_tau(double val){GCSsys.LM_tau=val;} diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 8c596e2ca..0791b1288 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -166,7 +166,8 @@ System::System() LM_eps(1E-10), LM_eps1(1E-80), LM_tau(1E-3), DL_tolg(1E-80), DL_tolx(1E-80), DL_tolf(1E-10), LM_epsRedundant(1E-10), LM_eps1Redundant(1E-80), LM_tauRedundant(1E-3), - DL_tolgRedundant(1E-80), DL_tolxRedundant(1E-80), DL_tolfRedundant(1E-10) + DL_tolgRedundant(1E-80), DL_tolxRedundant(1E-80), DL_tolfRedundant(1E-10), + qrpivotThreshold(1E-13) { // currently Eigen only supports multithreading for multiplications // There is no appreciable gain from using more threads @@ -1818,7 +1819,7 @@ int System::diagnose(Algorithm alg) paramsNum = qrJT.rows(); constrNum = qrJT.cols(); - qrJT.setThreshold(1e-13); + qrJT.setThreshold(qrpivotThreshold); rank = qrJT.rank(); if (constrNum >= paramsNum) @@ -1839,7 +1840,7 @@ int System::diagnose(Algorithm alg) paramsNum = SqrJT.rows(); constrNum = SqrJT.cols(); - SqrJT.setPivotThreshold(1e-13); + SqrJT.setPivotThreshold(qrpivotThreshold); rank = SqrJT.rank(); if (constrNum >= paramsNum) @@ -1858,7 +1859,8 @@ int System::diagnose(Algorithm alg) stream << ", Threads: " << Eigen::nbThreads() #ifdef EIGEN_VECTORIZE << ", Vectorization: On" - #endif + #endif + << ", Pivot Threshold: " << qrpivotThreshold << ", Params: " << paramsNum << ", Constr: " << constrNum << ", Rank: " << rank << "\n"; diff --git a/src/Mod/Sketcher/App/planegcs/GCS.h b/src/Mod/Sketcher/App/planegcs/GCS.h index 9b0a9488d..9f29afec3 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.h +++ b/src/Mod/Sketcher/App/planegcs/GCS.h @@ -103,6 +103,7 @@ namespace GCS double convergence; double convergenceRedundant; QRAlgorithm qrAlgorithm; + double qrpivotThreshold; DebugMode debugMode; double LM_eps; double LM_eps1; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp index bda2f65c6..8eb6c4687 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp @@ -55,6 +55,7 @@ #define DEFAULT_SOLVER 2 // DL=2, LM=1, BFGS=0 #define DEFAULT_RSOLVER 2 // DL=2, LM=1, BFGS=0 #define DEFAULT_QRSOLVER 0 // DENSE=0, SPARSEQR=1 +#define QR_PIVOT_THRESHOLD 1E-13 // under this value a Jacobian value is regarded as zero #define DEFAULT_SOLVER_DEBUG 1 // None=0, Minimal=1, IterationLevel=2 #define MAX_ITER_MULTIPLIER true @@ -78,6 +79,7 @@ TaskSketcherSolverAdvanced::TaskSketcherSolverAdvanced(ViewProviderSketch *sketc ui->checkBoxSketchSizeMultiplier->onRestore(); ui->lineEditConvergence->onRestore(); ui->comboBoxQRMethod->onRestore(); + ui->lineEditQRPivotThreshold->onRestore(); ui->comboBoxRedundantDefaultSolver->onRestore(); ui->spinBoxRedundantSolverMaxIterations->onRestore(); ui->checkBoxRedundantSketchSizeMultiplier->onRestore(); @@ -401,6 +403,20 @@ void TaskSketcherSolverAdvanced::on_checkBoxSketchSizeMultiplier_stateChanged(in } } +void TaskSketcherSolverAdvanced::on_lineEditQRPivotThreshold_editingFinished() +{ + QString text = ui->lineEditQRPivotThreshold->text(); + double val = text.toDouble(); + QString sci = QString::number(val); + sci.remove(QString::fromLatin1("+")); + sci.replace(QString::fromLatin1("e0"),QString::fromLatin1("E")); + ui->lineEditQRPivotThreshold->setText(sci.toUpper()); + + ui->lineEditQRPivotThreshold->onSave(); + + sketchView->getSketchObject()->getSolvedSketch().setQRPivotThreshold(val); +} + void TaskSketcherSolverAdvanced::on_lineEditConvergence_editingFinished() { QString text = ui->lineEditConvergence->text(); @@ -497,6 +513,7 @@ void TaskSketcherSolverAdvanced::on_pushButtonDefaults_clicked(bool checked/* = hGrp->SetASCII("Convergence",QString::number(CONVERGENCE).toUtf8()); hGrp->SetASCII("RedundantConvergence",QString::number(CONVERGENCE).toUtf8()); hGrp->SetInt("QRMethod",DEFAULT_QRSOLVER); + hGrp->SetASCII("QRPivotThreshold",QString::number(QR_PIVOT_THRESHOLD).toUtf8()); hGrp->SetInt("DebugMode",DEFAULT_SOLVER_DEBUG); ui->comboBoxDefaultSolver->onRestore(); @@ -504,6 +521,7 @@ void TaskSketcherSolverAdvanced::on_pushButtonDefaults_clicked(bool checked/* = ui->checkBoxSketchSizeMultiplier->onRestore(); ui->lineEditConvergence->onRestore(); ui->comboBoxQRMethod->onRestore(); + ui->lineEditQRPivotThreshold->onRestore(); ui->comboBoxRedundantDefaultSolver->onRestore(); ui->spinBoxRedundantSolverMaxIterations->onRestore(); ui->checkBoxRedundantSketchSizeMultiplier->onRestore(); @@ -520,6 +538,7 @@ void TaskSketcherSolverAdvanced::updateSketchObject(void) sketchView->getSketchObject()->getSolvedSketch().setMaxIterRedundant(ui->spinBoxRedundantSolverMaxIterations->value()); sketchView->getSketchObject()->getSolvedSketch().defaultSolverRedundant=(GCS::Algorithm) ui->comboBoxRedundantDefaultSolver->currentIndex(); sketchView->getSketchObject()->getSolvedSketch().setQRAlgorithm((GCS::QRAlgorithm) ui->comboBoxQRMethod->currentIndex()); + sketchView->getSketchObject()->getSolvedSketch().setQRPivotThreshold(ui->lineEditQRPivotThreshold->text().toDouble()); sketchView->getSketchObject()->getSolvedSketch().setConvergenceRedundant(ui->lineEditRedundantConvergence->text().toDouble()); sketchView->getSketchObject()->getSolvedSketch().setConvergence(ui->lineEditConvergence->text().toDouble()); sketchView->getSketchObject()->getSolvedSketch().setSketchSizeMultiplier(ui->checkBoxSketchSizeMultiplier->isChecked()); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.h b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.h index 066017a8e..d387d4edd 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.h +++ b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.h @@ -52,6 +52,7 @@ private Q_SLOTS: void on_checkBoxSketchSizeMultiplier_stateChanged(int state); void on_lineEditConvergence_editingFinished(); void on_comboBoxQRMethod_currentIndexChanged(int index); + void on_lineEditQRPivotThreshold_editingFinished(); void on_comboBoxRedundantDefaultSolver_currentIndexChanged(int index); void on_lineEditRedundantConvergence_editingFinished(); void on_spinBoxRedundantSolverMaxIterations_valueChanged(int i); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.ui b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.ui index 402c0998c..a9e194ad0 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.ui +++ b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.ui @@ -7,7 +7,7 @@ 0 0 326 - 628 + 630 @@ -245,7 +245,7 @@ - 1 + 0 QRMethod @@ -267,6 +267,33 @@ + + + + + + Pivot threshold + + + + + + + 1E-13 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + QRPivotThreshold + + + Mod/Sketcher/SolverAdvanced + + + + +