soogo.optimize_result module
OptimizeResult class for Soogo package.
- class soogo.optimize_result.OptimizeResult(x: ndarray | None = None, fx: float | ndarray | None = None, nit: int = 0, nfev: int = 0, sample: ndarray | None = None, fsample: ndarray | None = None, nobj: int = 1) None
Bases:
object
Optimization result for the global optimizers provided by this package.
-
fsample:
Optional
[ndarray
] = None Vector with all n objective values
-
fx:
Union
[float
,ndarray
,None
] = None Best objective function value
- init(fun, bounds, mineval: int, maxeval: int, surrogateModel: Surrogate, ntarget: int = 1) None
Initialize
nfev
andsample
andfsample
with data about the optimization that is starting.This routine calls the objective function
nfev
times.By default, all targets are considered to be used in the objective. If that is not the case, set nobj after calling this function.
- Parameters:
fun – The objective function to be minimized.
bounds (sequence) – List with the limits [x_min,x_max] of each direction x in the space.
mineval (
int
) – Minimum number of function evaluations to build the surrogate model.maxeval (
int
) – Maximum number of function evaluations.surrogateModel (
Surrogate
) – Surrogate model to be used.ntarget (
int
) – Number of target dimensions. Default is 1. (default:1
)
- Return type:
None
- init_best_values(surrogateModel: Surrogate | None = None) None
Initialize
x
andfx
based on the best values obtained so far.- Parameters:
surrogateModel (
Optional
[Surrogate
]) – Surrogate model. (default:None
)- Return type:
None
-
nfev:
int
= 0 Number of function evaluations taken
-
nit:
int
= 0 Number of active learning iterations
-
nobj:
int
= 1 Number of objective function targets
-
sample:
Optional
[ndarray
] = None n-by-dim matrix with all n samples
-
x:
Optional
[ndarray
] = None Best sample point found so far
-
fsample:
- soogo.optimize_result.evaluate_and_log_point(fun: Callable, x: ndarray, out: OptimizeResult)
Evaluate a point or array of points and log the results. If the function errors or the result is invalid (NaN or Inf), the output is logged as NaN. If the function value is less than the current best, the current best ( out.x, out.fx) is updated. Provided points are evaluated as a batch. This function only supports single-objective functions.
- Parameters:
fun (
Callable
) – The function to evaluate.x (
ndarray
) – The point(s) to evaluate. Can be a 1D array (single point) or 2D array (multiple points).out (
OptimizeResult
) – The output object to log the results.
- Returns:
The function value(s) or NaN. Returns a scalar for single point, array for multiple points.