Skip to content

Commit f8462a1

Browse files
yuvaltassacopybara-github
authored andcommitted
Refine line search convergence criteria.
The line search now requires a negative cost (improvement) in addition to a small derivative to declare convergence, preventing premature termination when no actual improvement has been made. Follows the proposal in github.com/google-deepmind/mujoco_warp/pull/1471 PiperOrigin-RevId: 941579503 Change-Id: I8fcd20f7b959e50d77cd5d6de0a3c6d95f86b9e1
1 parent fb259a5 commit f8462a1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/engine/engine_solver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ static mjtNum PrimalSearch(mjPrimalContext* ctx, mjtNum tolerance, mjtNum ls_ite
18551855
PrimalEval(ctx, &p1);
18561856

18571857
// check for initial convergence
1858-
if (mju_abs(p1.deriv[0]) < gtol) {
1858+
if (mju_abs(p1.deriv[0]) < gtol && (p1.alpha == 0 || p1.cost < 0)) {
18591859
if (p1.alpha == 0) {
18601860
ctx->LSresult = 2; // no improvement, initial convergence
18611861
} else {
@@ -1916,7 +1916,7 @@ static mjtNum PrimalSearch(mjPrimalContext* ctx, mjtNum tolerance, mjtNum ls_ite
19161916
PrimalEval(ctx, &p1);
19171917

19181918
// check for convergence
1919-
if (mju_abs(p1.deriv[0]) < gtol) {
1919+
if (mju_abs(p1.deriv[0]) < gtol && p1.cost < 0) {
19201920
ctx->LSslope = mju_abs(p1.deriv[0])*slopescl;
19211921
*improvement = -p1.cost;
19221922
return p1.alpha; // SUCCESS

0 commit comments

Comments
 (0)