cobra.sampling.core

Provide low-level sampling stepper functions and helpers.

Module Contents

Functions

step(→ numpy.ndarray)

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

Attributes

logger

MAX_TRIES

cobra.sampling.core.logger[source]
cobra.sampling.core.MAX_TRIES = 100[source]
cobra.sampling.core.step(sampler: cobra.sampling.hr_sampler.HRSampler, x: numpy.ndarray, delta: numpy.ndarray, fraction: Optional[float] = None, tries: int = 0) numpy.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.