Provide low-level sampling stepper functions and helpers. Module Contents Functions

step(sampler: HRSampler, x: np.ndarray, delta: np.ndarray, fraction: Optional[float] = None, tries: int = 0) → np.ndarray

Sample a new feasible point from the point x in direction delta.

cobra.sampling.core.MAX_TRIES = 100[source]
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.

  • 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).


The new numpy array obtained after a step of sampling.

Return type



RuntimeError – If tries exceeds MAX_TRIES.