Skip to content

x0 close to bounds #6

@lindonroberts

Description

@lindonroberts

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
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions