@@ -1922,8 +1922,25 @@ static void slsqpb_(int *m, int *meq, int *la, int *
1922
1922
dcopy___ (n , & xu [1 ], 1 , & v [1 ], 1 );
1923
1923
d__1 = - one ;
1924
1924
daxpy_sl__ (n , & d__1 , & x [1 ], 1 , & u [1 ], 1 );
1925
- d__1 = - one ;
1926
1925
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 );
1927
1944
h4 = one ;
1928
1945
lsq_ (m , meq , n , & n3 , la , & l [1 ], & g [1 ], & a [a_offset ], & c__ [1 ], & u [1 ], & v [1 ]
1929
1946
, & s [1 ], & r__ [1 ], & w [1 ], & iw [1 ], mode );
0 commit comments