Skip to content

Commit 0070694

Browse files
committed
Smooth box constraints when determining search direction
1 parent f9316c0 commit 0070694

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/algs/slsqp/slsqp.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -1922,8 +1922,25 @@ static void slsqpb_(int *m, int *meq, int *la, int *
19221922
dcopy___(n, &xu[1], 1, &v[1], 1);
19231923
d__1 = -one;
19241924
daxpy_sl__(n, &d__1, &x[1], 1, &u[1], 1);
1925-
d__1 = -one;
19261925
daxpy_sl__(n, &d__1, &x[1], 1, &v[1], 1);
1926+
/* Smooth box constraints when determining search direction.
1927+
Otherwise the search magnitude for bounded parameters is
1928+
scaled down in consideration of proximity to bounds. When
1929+
other parameters are unbounded then the bounded parameters
1930+
may be updated much too slowly. Here we approach the bounded
1931+
space gradually from the unbounded space. */
1932+
double away = ddot_sl__(n, &g[1], 1, &g[1], 1);
1933+
for (j = 1; j <= *m; ++j) {
1934+
if (j <= *meq) {
1935+
away += fabs(c__[j]);
1936+
} else {
1937+
away += MAX2(-c__[j], 0.0);
1938+
}
1939+
}
1940+
d__1 = 1.0 + away / MAX2(*f * 10, 1.0);
1941+
//printf("bound scale %f %f %f @%d\n", away, MAX2(*f, 1.0), d__1, d__1 <= 1 + 1e-4);
1942+
dscal_sl__(n, &d__1, &u[1], 1);
1943+
dscal_sl__(n, &d__1, &v[1], 1);
19271944
h4 = one;
19281945
lsq_(m, meq, n, &n3, la, &l[1], &g[1], &a[a_offset], &c__[1], &u[1], &v[1]
19291946
, &s[1], &r__[1], &w[1], &iw[1], mode);

0 commit comments

Comments
 (0)