Sketcher: Solver Advanced Control: New Param: QR Pivot Threshold

================================================================

A new parameter added to the form in order to control how low a value should be
to be considered zero (how high a value shall be to be accounted for in rank calculation)

Debug for QR pivot threshold is also added.
This commit is contained in:
Abdullah Tahiri 2015-06-22 06:42:46 +02:00 committed by wmayer
parent 8f68b14627
commit 82e24d830e
6 changed files with 57 additions and 6 deletions

View File

@ -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;}

View File

@ -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";

View File

@ -103,6 +103,7 @@ namespace GCS
double convergence;
double convergenceRedundant;
QRAlgorithm qrAlgorithm;
double qrpivotThreshold;
DebugMode debugMode;
double LM_eps;
double LM_eps1;

View File

@ -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());

View File

@ -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);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>326</width>
<height>628</height>
<height>630</height>
</rect>
</property>
<property name="windowTitle">
@ -245,7 +245,7 @@
<item>
<widget class="Gui::PrefComboBox" name="comboBoxQRMethod">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>QRMethod</cstring>
@ -267,6 +267,33 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="labelPivotThreshold">
<property name="text">
<string>Pivot threshold</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefLineEdit" name="lineEditQRPivotThreshold">
<property name="text">
<string>1E-13</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="prefEntry" stdset="0">
<cstring>QRPivotThreshold</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/SolverAdvanced</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>