pypesto.startpoint
Startpoint
Methods for selecting points that can be used as startpoints
for multi-start optimization.
Startpoint methods can be implemented by deriving from
pypesto.startpoint.StartpointMethod.
- class pypesto.startpoint.CheckedStartpoints[source]
Bases:
StartpointMethod,ABCStartpoints checked for function value and/or gradient finiteness.
- check_and_resample(xs, lb, ub, objective, priors=None)[source]
Check sampled points for fval, grad, and potentially resample ones.
- Parameters:
xs (Startpoints candidates, shape (n_starts, n_par).)
lb (Lower parameter bound.)
ub (Upper parameter bound.)
objective (Objective function, for evaluation.)
priors (Parameter priors, if available.)
- Return type:
- Returns:
xs – Checked and potentially partially resampled startpoints, shape (n_starts, n_par).
- abstractmethod sample(n_starts, lb, ub, priors=None)[source]
Actually sample startpoints.
While in this implementation, __call__ handles the checking of guesses and resampling, this method defines the actual sampling.
- Parameters:
n_starts (Number of startpoints to generate.)
lb (Lower parameter bound.)
ub (Upper parameter bound.)
priors (Parameter priors, if available. Some sampling methods may) – utilize this information.
- Return type:
- Returns:
xs (Startpoints, shape (n_starts, n_par).)
- class pypesto.startpoint.FunctionStartpoints[source]
Bases:
CheckedStartpointsDefine startpoints via callable.
The callable should take the same arguments as the __call__ method.
- class pypesto.startpoint.LatinHypercubeStartpoints[source]
Bases:
CheckedStartpointsGenerate latin hypercube-sampled startpoints.
See e.g. https://en.wikipedia.org/wiki/Latin_hypercube_sampling.
- __init__(use_guesses=True, check_fval=False, check_grad=False, smooth=True)[source]
Initialize.
- Parameters:
use_guesses (
bool) – As in CheckedStartpoints.check_fval (
bool) – As in CheckedStartpoints.check_grad (
bool) – As in CheckedStartpoints.smooth (
bool) – Whether a (uniformly chosen) random starting point within the hypercube [i/n_starts, (i+1)/n_starts] should be chosen (True) or the midpoint of the interval (False).
- class pypesto.startpoint.NoStartpoints[source]
Bases:
StartpointMethodDummy class generating nan points. Useful if no startpoints needed.
- class pypesto.startpoint.PriorStartpoints[source]
Bases:
CheckedStartpointsGenerate startpoints from prior distribution.
Samples from the prior distribution if available, otherwise falls back to uniform sampling. Ensures all samples are within bounds by resampling out-of-bounds values.
- sample(n_starts, lb, ub, priors=None, max_iterations=100)[source]
Sample startpoints from prior or uniform distribution.
- Parameters:
n_starts (Number of startpoints to generate.)
lb (Lower parameter bound.)
ub (Upper parameter bound.)
priors (Parameter priors. If available, samples from priors;) – otherwise falls back to uniform sampling.
max_iterations (Maximum number of resampling iterations to ensure) – all samples are within bounds.
- Return type:
- Returns:
xs (Startpoints, shape (n_starts, n_par).)
- class pypesto.startpoint.StartpointMethod[source]
Bases:
ABCStartpoint generation, in particular for multi-start optimization.
Abstract base class, specific sampling method needs to be defined in sub-classes.
- class pypesto.startpoint.UniformStartpoints[source]
Bases:
FunctionStartpointsGenerate uniformly sampled startpoints.
- pypesto.startpoint.latin_hypercube(n_starts, lb, ub, smooth=True)[source]
Generate latin hypercube points.
- Parameters:
- Return type:
- Returns:
xs – Latin hypercube points, shape (n_starts, n_x).
- pypesto.startpoint.to_startpoint_method(maybe_startpoint_method)[source]
Create StartpointMethod instance if possible, otherwise raise.
- Parameters:
maybe_startpoint_method (
StartpointMethod|Callable|bool) – A StartpointMethod instance, or a Callable as expected by FunctionStartpoints.- Return type:
- Returns:
startpoint_method – A StartpointMethod instance.
- Raises:
TypeError if arguments cannot be converted to a StartpointMethod. –