From: azv Date: Tue, 25 Sep 2018 11:23:42 +0000 (+0300) Subject: Sketcher: Add BFGS to a sequence of solvers when all other are failed. X-Git-Tag: V9_2_0a1~4^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2be45fc3c12997dd08e7fe33096903291759072e;p=modules%2Fshaper.git Sketcher: Add BFGS to a sequence of solvers when all other are failed. --- 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();