From 2be45fc3c12997dd08e7fe33096903291759072e Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 25 Sep 2018 14:23:42 +0300 Subject: [PATCH] Sketcher: Add BFGS to a sequence of solvers when all other are failed. --- .../PlaneGCSSolver/PlaneGCSSolver_Solver.cpp | 9 +++++++-- src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index f4cfa9942..10e453599 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -168,8 +168,13 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve() if (aResult == GCS::Failed) { // DogLeg solver failed without conflicting constraints, try to use Levenberg-Marquardt solver + diagnose(GCS::LevenbergMarquardt); aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters, true, GCS::LevenbergMarquardt); + if (aResult == GCS::Failed) { + diagnose(GCS::BFGS); + aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters, true, GCS::BFGS); + } } Events_LongOp::end(this); @@ -232,10 +237,10 @@ int PlaneGCSSolver_Solver::dof() return myDOF; } -void PlaneGCSSolver_Solver::diagnose() +void PlaneGCSSolver_Solver::diagnose(const GCS::Algorithm& theAlgo) { myEquationSystem->declareUnknowns(myParameters); - myDOF = myEquationSystem->diagnose(); + myDOF = myEquationSystem->diagnose(theAlgo); myDiagnoseBeforeSolve = false; } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h index c1fe8be56..6e1c7740a 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h @@ -78,7 +78,7 @@ public: bool isConflicting(const ConstraintID& theConstraint) const; /// \brief Check conflicting/redundant constraints and DoF - void diagnose(); + void diagnose(const GCS::Algorithm& theAlgo = GCS::DogLeg); /// \brief Degrees of freedom int dof(); -- 2.39.2