@@ -654,14 +654,18 @@ def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8,
654654 assert len (bounds ) == 2 , "bounds must be a 2-tuple of (lower, upper), where both are arrays of size(x0)"
655655 xl = bounds [0 ]
656656 if type (xl ) == list :
657- xl = np .array (xl , dtype = np .float )
657+ xl = np .array (xl , dtype = np .float ) if xl is not None else None
658658 else :
659- xl = xl .astype (np .float )
659+ xl = xl .astype (np .float ) if xl is not None else None
660660 xu = bounds [1 ]
661661 if type (xu ) == list :
662- xu = np .array (xu , dtype = np .float )
662+ xu = np .array (xu , dtype = np .float ) if xu is not None else None
663663 else :
664- xu = xu .astype (np .float )
664+ xu = xu .astype (np .float ) if xu is not None else None
665+
666+ if (xl is None or xu is None ) and scaling_within_bounds :
667+ scaling_within_bounds = False
668+ warnings .warn ("Ignoring scaling_within_bounds=True for unconstrained problem/1-sided bounds" , RuntimeWarning )
665669
666670 exit_info = None
667671 if seek_global_minimum and (xl is None or xu is None ):
@@ -760,21 +764,11 @@ def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8,
760764 return results
761765
762766 # Enforce lower & upper bounds on x0
763- idx = (xl < x0 ) & (x0 <= xl + rhobeg )
764- if np .any (idx ):
765- warnings .warn ("x0 too close to lower bound, adjusting" , RuntimeWarning )
766- x0 [idx ] = xl [idx ] + rhobeg
767-
768767 idx = (x0 <= xl )
769768 if np .any (idx ):
770769 warnings .warn ("x0 below lower bound, adjusting" , RuntimeWarning )
771770 x0 [idx ] = xl [idx ]
772771
773- idx = (xu - rhobeg <= x0 ) & (x0 < xu )
774- if np .any (idx ):
775- warnings .warn ("x0 too close to upper bound, adjusting" , RuntimeWarning )
776- x0 [idx ] = xu [idx ] - rhobeg
777-
778772 idx = (x0 >= xu )
779773 if np .any (idx ):
780774 warnings .warn ("x0 above upper bound, adjusting" , RuntimeWarning )
0 commit comments