carbatpy.optimizations.opti_de
Functions
|
Perform the global optimization for the selected cycle. |
Module Contents
- carbatpy.optimizations.opti_de.optimize(mode: str, config: dict | str, boundaries: dict, same_fluid: bool = True, heat_losses: float = 0.0, COP: float | None = None, q_dot: float | None = None, verbose: bool = True, n_processes: int | None = None, maxtasksperchild: int = 20, n_ieq_constr: int = 3, pop_size: int = 50, sampling_iterations: int = 50, de_variant: str = 'DE/rand/1/bin', CR: float = 0.3, dither: str = 'vector', jitter: bool = False, n_gen: int = 100, period: int = 20, ftol: float = 0.0001, return_least_infeasible: bool = False)[source]
Perform the global optimization for the selected cycle.
This function sets up the optimization problem, initializes the differential evolution algorithm, handles parallelization, and executes the optimization using Pymoo.
- Parameters:
mode (str) – Optimization mode. Must be one of
'hp','orc', or'cb'.config (dict | str) – Configuration dictionary or path to configuration file.
boundaries (dict) – Lower and upper bounds for all optimization variables.
same_fluid (bool) – Whether the working fluid is the same for all cycles. Only used in
'cb'mode. Defaults toTrue.heat_losses (float) – Heat losses fraction. Only used in
'cb'mode. Defaults to0.0.COP (float | None) – Coefficient of performance. Only used in
'orc'mode.q_dot (float | None) – Heat input/output rate. Only used in
'orc'mode.verbose (bool) – Whether to print detailed optimization progress. Defaults to
True.n_processes (int | None) – Number of processes for parallelization. Defaults to auto-detection via
default_n_processes().maxtasksperchild (int) – Maximum tasks per worker process in the pool. Defaults to
20.n_ieq_constr (int) – Number of inequality constraints. Defaults to
3.pop_size (int) – Population size for the DE algorithm. Defaults to
50.sampling_iterations (int) – Number of iterations for Latin Hypercube sampling. Defaults to
50.de_variant (str) – Variant of the differential evolution algorithm. Defaults to
'DE/rand/1/bin'.CR (float) – Crossover probability for DE. Defaults to
0.3.dither (str) – Dithering strategy for DE. Defaults to
'vector'.jitter (bool) – Whether to apply jitter in DE. Defaults to
False.n_gen (int) – Maximum number of generations. Defaults to
100.period (int) – Period for robust termination checking. Defaults to
20.ftol (float) – Function tolerance for termination. Defaults to
1e-4.return_least_infeasible (bool) – Whether to return the least infeasible solution if no feasible solution is found. Defaults to
False.
- Raises:
ValueError – If
boundariesisNoneor required parameters for the selectedmodeare missing.- Returns:
The optimization result object containing the best solution and additional metadata.
- Return type:
pymoo.core.result.Result