-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
Can avoid perturbing x0 if it is too close to the bounds? In random initial directions, treat indices 'close to bound' (compared to rhobeg) as at the boundary - a similar logic is already used in initial coordinate directions.
Alternatively, show more information to make perturbation clear:
`
indices=np.arange(0,len(x0))
idx = (xl < x0) & (x0 <= xl + rhobeg)
printValues=False # if find values need adjusting this will be True
if np.any(idx):
printValues=True
warnings.warn(f"x0 too close to lower bound, adjusting {indices[idx]}", RuntimeWarning)
x0[idx] = xl[idx] + rhobeg
idx = (x0 <= xl)
if np.any(idx):
printValues=True
warnings.warn(f"x0 below lower bound, adjusting {indices[idx]}", RuntimeWarning)
x0[idx] = xl[idx]
idx = (xu - rhobeg <= x0) & (x0 < xu)
if np.any(idx):
printValues=True
warnings.warn(f"x0 too close to upper bound, adjusting {indices[idx]}", RuntimeWarning)
x0[idx] = xu[idx] - rhobeg
idx = (x0 >= xu)
if np.any(idx):
printValues=True
warnings.warn(f"x0 above upper bound, adjusting {indices[idx]}", RuntimeWarning)`
And at the end, raise another RuntimeWarning with the adjusted x0: warnings.warn(f"Adjusted: x0: {x0}",RuntimeWarning)
Metadata
Metadata
Assignees
Labels
No labels