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
,ABC
Startpoints checked for function value and/or gradient finiteness.
- check_and_resample(xs, lb, ub, objective)[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.) –
- Return type:
- Returns:
xs – Checked and potentially partially resampled startpoints, shape (n_starts, n_par).
- abstract sample(n_starts, lb, ub)[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.) –
- Return type:
- Returns:
xs (Startpoints, shape (n_starts, n_par).)
- class pypesto.startpoint.FunctionStartpoints[source]
Bases:
CheckedStartpoints
Define startpoints via callable.
The callable should take the same arguments as the __call__ method.
- class pypesto.startpoint.LatinHypercubeStartpoints[source]
Bases:
CheckedStartpoints
Generate 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:
StartpointMethod
Dummy class generating nan points. Useful if no startpoints needed.
- class pypesto.startpoint.StartpointMethod[source]
Bases:
ABC
Startpoint 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:
FunctionStartpoints
Generate 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 (
Union
[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. –