carbatpy.optimizations.opti_NSGA2 ================================= .. py:module:: carbatpy.optimizations.opti_NSGA2 Functions --------- .. autoapisummary:: carbatpy.optimizations.opti_NSGA2.optimize Module Contents --------------- .. py:function:: optimize(mode: str, config: dict | str, boundaries: dict, same_fluid: bool = True, heat_losses: float = 0.0, verbose: bool = True, n_processes: int | None = None, maxtasksperchild: int = 20, n_ieq_constr: int = 3, pop_size: int = 50, n_offspring: int | None = None, sampling_iterations: int = 50, crowding_func: str = 'pcd', eliminate_duplicates: bool = True, n_gen: int = 100, period: int = 20, ftol: float = 0.0001, save_history: bool = False, return_least_infeasible: bool = False) Perform a multi-objective optimization using NSGA2. Sets up the problem, initializes the NSGA2 algorithm, handles parallelization, and executes the optimization using Pymoo. :param mode: Optimization mode. Must currently be ``'cb'``. :type mode: str :param config: Configuration dictionary or path to configuration file. :type config: dict | str :param boundaries: Lower and upper bounds for all optimization variables. :type boundaries: dict :param same_fluid: Whether the working fluid is the same for all cycles. Only used in ``'cb'`` mode. Defaults to ``True``. :type same_fluid: bool :param heat_losses: Fraction of heat losses in the system. Only used in ``'cb'`` mode. Defaults to ``0.0``. :type heat_losses: float :param verbose: Whether to print progress information. Defaults to ``True``. :type verbose: bool :param n_processes: Number of parallel processes. Auto-detected via :func:`default_n_processes` if ``None``. :type n_processes: int | None :param maxtasksperchild: Maximum number of tasks per worker process. Defaults to ``20``. :type maxtasksperchild: int :param n_ieq_constr: Number of inequality constraints. Defaults to ``3``. :type n_ieq_constr: int :param pop_size: Population size for NSGA2. Defaults to ``50``. :type pop_size: int :param n_offspring: Number of offspring per generation. Defaults to NSGA2 internal rules if ``None``. :type n_offspring: int | None :param sampling_iterations: Iterations for Latin Hypercube sampling. Defaults to ``50``. :type sampling_iterations: int :param crowding_func: Crowding distance function for survival selection. Defaults to ``'pcd'``. :type crowding_func: str :param eliminate_duplicates: Whether to remove duplicate solutions. Defaults to ``True``. :type eliminate_duplicates: bool :param n_gen: Maximum number of generations. Defaults to ``100``. :type n_gen: int :param period: Period for robust termination checking. Defaults to ``20``. :type period: int :param ftol: Function tolerance for termination. Defaults to ``1e-4``. :type ftol: float :param save_history: Whether to save the optimization history. Defaults to ``False``. :type save_history: bool :param return_least_infeasible: Whether to return the least infeasible solution if no feasible solution is found. Defaults to ``False``. :type return_least_infeasible: bool :raises ValueError: If ``boundaries`` is ``None`` or ``mode`` is not supported. :returns: Result object containing the Pareto front, best solutions, and other optimization metadata. :rtype: pymoo.core.result.Result