17.1.1.6.1.2. cobra.sampling.core
¶
Provide low-level sampling stepper functions and helpers.
17.1.1.6.1.2.1. Module Contents¶
17.1.1.6.1.2.1.1. Functions¶
|
Sample a new feasible point from the point x in direction delta. |
-
cobra.sampling.core.
step
(sampler: HRSampler, x: np.ndarray, delta: np.ndarray, fraction: Optional[float] = None, tries: int = 0) → np.ndarray[source]¶ Sample a new feasible point from the point x in direction delta.
This is the low-level sampling stepper for samplers derived from HRSampler. Currently, it’s used by ACHRSampler and OptGPSampler.
It’s declared outside of the base sampling class to facilitate use of multiprocessing.
- Parameters
sampler (cobra.sampling.HRSampler) – The sampler to sample a step for.
x (np.array) – A point in the sampling region.
delta (np.array) – The direction to take the step in.
fraction (float, optional) – A float controlling the part of alpha difference to contribute to the fraction of delta (default None). If None, alpha is obtained from a normal distribution.
tries (int, optional) – Total number of tries (default 0).
- Returns
The new numpy array obtained after a step of sampling.
- Return type
np.array
- Raises
RuntimeError – If tries exceeds MAX_TRIES.