optilab.metamodels package
Submodules
optilab.metamodels.approximate_ranking_metamodel module
Approximate ranking metamodel based on lmm-CMA-ES.
- class ApproximateRankingMetamodel(population_size: int, mu: int, objective_function: ObjectiveFunction, surrogate_function: SurrogateObjectiveFunction, *, buffer_size: int | None = None)[source]
Bases:
objectApproximate ranking metamodel based on lmm-CMA-ES
- __init__(population_size: int, mu: int, objective_function: ObjectiveFunction, surrogate_function: SurrogateObjectiveFunction, *, buffer_size: int | None = None) None[source]
Class constructor.
- Parameters:
population_size – The population size (lambda).
mu – The number of points compared in the ranking procedure (mu).
objective_function – The objective function that’s being optimized.
surrogate_function – Surrogate function used to estimate the optimized function.
buffer_size – Number of last evaluated samples to use for training the surrogate function. If None, all samples are used.
- _update_n(num_iters: int) None[source]
Updates n_init and n_step values base on the number of algorithm iterations.
- Parameters:
num_iters – The number of iterations done by the algorithm.
- __call__(points: PointList) PointList[source]
Approximates the values of provided points with surrogate objective function.
- Parameters:
points – List of points to evaluate.
- Returns:
List of evaluated points.
- evaluate(xs: PointList) PointList[source]
Evaluate provided point with the objective function and append results to the training set and retrain the surrogate function on new training data.
- Parameters:
xs – List of point to evaluate with the objective function.
- Returns:
List of evaluated points.
optilab.metamodels.iepolation_surrogate module
Inter-extra-polation surrogate metamodel. It uses different surrogate functions for interpolation and extrapolation.
- class IEPolationSurrogate(interpolation_surrogate: SurrogateObjectiveFunction, extrapolation_surrogate: SurrogateObjectiveFunction, train_set: PointList | None = None)[source]
Bases:
SurrogateObjectiveFunctionInter-extra-polation surrogate metamodel. It uses different surrogate functions for interpolation and extrapolation.
- __init__(interpolation_surrogate: SurrogateObjectiveFunction, extrapolation_surrogate: SurrogateObjectiveFunction, train_set: PointList | None = None) None[source]
Class constructor.
- Parameters:
interpolation_surrogate – Surrogate used for interpolation.
extrapolation_surrogate – Surrogate used for extrapolation.
train_set – Initial training set for the surrogates.
- build_convex_hull(train_set: PointList) None[source]
Builds a convex hull from the train set. This convex hull is then used to determine wheather the point value should be interpolated or extrapolated.
- Parameters:
train_set – Training set.
- train(train_set: PointList) None[source]
Train both surrogate functions with provided data.
- Parameters:
train_set – Training data for the model.
optilab.metamodels.top_half_metamodel module
Top half metamodel. Estimates all points using the surrogate function, then evaluates the top mu (typically half) points with the objective function.
- class TopHalfMetamodel(population_size: int, mu: int, objective_function: ObjectiveFunction, surrogate_function: SurrogateObjectiveFunction, *, buffer_size: int | None = None)[source]
Bases:
objectTop-half metamodel.
Estimates all points using the surrogate function, then calculates the real value for the top mu (typically half, hence the name) using the actual objective function. The remaining points get a value that’s guaranteed to be worse than the rest of the points.
- __init__(population_size: int, mu: int, objective_function: ObjectiveFunction, surrogate_function: SurrogateObjectiveFunction, *, buffer_size: int | None = None) None[source]
Class constructor.
- Parameters:
population_size – The population size (lambda).
mu – Number of elite solutions (typically population_size // 2).
objective_function – The real objective function.
surrogate_function – Surrogate used to pre-screen candidates.
buffer_size – If set, only the last buffer_size real evaluations are used as the surrogate training set.
- __call__(points: PointList) PointList[source]
Return evaluated / estimated values for points.
If
adapt()was called immediately before, returns the combined results (real values for top half, penalised for bottom half) and clears the internal cache. Otherwise falls back to pure surrogate estimation.- Parameters:
points – Candidate solutions.
- Returns:
PointList with y-values set for every point.
- adapt(xs: PointList) None[source]
Screen xs with the surrogate, evaluate the best half with the real objective, and cache a combined result for the next
__call__().- Parameters:
xs – Candidate solutions (must have length == population_size).
- Raises:
ValueError – If the number of points does not match population_size.
Module contents
Module containing metamodels.