otaf.optimization package
Module contents
- class otaf.optimization.AcceptTest(storage, defect_description, distance_threshold=1.0, surrogate_model=None)[source]
Bases:
objectCustom class for accepting or rejecting new steps in the optimization process.
Attributes:
- storageOptimizationStorage
An instance of the OptimizationStorage class to store and manage optimization points.
- linear_constraintsLinearConstraint
A function to enforce linear constraints on the variables.
- distance_thresholdfloat
Minimum distance between points to avoid revisiting.
- surrogate_modelcallable
A callable to update a surrogate model based on new points.
- __call__(f_new, x_new, f_old, x_old)[source]
Decide whether to accept or reject a new step in the optimization.
Parameters:
- f_newfloat
The function value at the new point.
- x_newarray-like
The coordinates of the new point.
- f_oldfloat
The function value at the previous point.
- x_oldarray-like
The coordinates of the previous point.
Returns:
: bool
True if the new step is accepted, False otherwise.
- class otaf.optimization.Callback(storage, stop_criterion=None)[source]
Bases:
objectA callback class to store accepted local minima and allow data sharing between components.
- __call__(x, f, accept)[source]
Store the current local minimum if accepted and apply the stop criterion if provided.
Parameters:
- xarray-like
The coordinates of the current minimum.
- ffloat
The function value at the current minimum.
- acceptbool
Whether the current minimum was accepted.
Returns:
: bool or None
Return True to stop the basinhopping routine if the stop criterion is met, otherwise return None.
- class otaf.optimization.ModifiedBasinHopping(func, x0, constraints=None, niter=100, T=1.0, stepsize=0.5, minimizer_kwargs=None, interval=50, disp=False, niter_success=None, seed=None, jac=False, jac_threshold=1e-05)[source]
Bases:
object
- class otaf.optimization.OptimizationTracker(bounds=None, constraint_tolerance=0.0001, precision_decimals=8)[source]
Bases:
objectHigh-performance storage for optimization loops. Uses byte-hashing for O(1) lookups during execution, and exports to Pandas for post-processing and filtering.
- filter_points(exp_key=None, source=None, bounds_respected=None, constraints_respected=None)[source]
Re-implementation of your old filter_points method.
- class otaf.optimization.StepTaking(storage, defect_description, stepsize=0.5)[source]
Bases:
objectCustom class for generating bounded steps in the optimization space.
Attributes:
- linear_conditioncallable
A function to enforce linear constraints on subsets of variables.
- stepsizefloat
The size of the step to be taken (default 0.5).
- otaf.optimization.check_constraint_with_tolerance(linear_constraint, x, tolerance=1e-06)[source]
Check if the vector x satisfies the linear constraint within a specified tolerance.
- Parameters:
linear_constraint (scipy.optimize.LinearConstraint) – The linear constraint object containing A, lb, and ub.
x (array_like) – The vector of independent variables to check.
tolerance (float, optional) – The tolerance within which the constraint should be satisfied (default is 1e-6).
- Returns:
bool – True if the constraint is satisfied within the tolerance, False otherwise.
dict – A dictionary containing the lower and upper residuals.
- otaf.optimization.create_constraint_checker(constraint, tolerance=1e-06)[source]
Creates a function to check if a vector x satisfies the given constraint (linear or nonlinear) within a specified tolerance.
- Parameters:
constraint (LinearConstraint or NonlinearConstraint) – The constraint object containing A, lb, and ub for linear, or fun, lb, and ub for nonlinear.
tolerance (float, optional) – The tolerance within which the constraint should be satisfied (default is 1e-6).
- Returns:
A function that takes a vector x and returns a boolean indicating if the constraint is satisfied within the tolerance, and the residuals as a dictionary.
- Return type:
function
- otaf.optimization.lambda_constraint_dict_from_composed_distribution(composed_distribution, tol=1e-12, keep_feasible=True)[source]
Condition lambda parameters to sum to 1 for each feature.
- Parameters:
sample (ot.Sample) – Lambda parameters with each feature ending in an integer sequence.
- Returns:
Conditioned lambda parameters.
- Return type:
ot.Sample
- Raises:
ValueError – If the description is missing or invalid.
- otaf.optimization.scaling(scale_factor)[source]
Decorator to scale the output of a function by a specified scaling factor.
- Parameters:
scale_factor (float) – The factor by which to scale the output of the wrapped function.
- Returns:
A decorator that applies the scaling to the output of the wrapped function.
- Return type:
function