carbatpy.optimizations.opti_NSGA2

Functions

optimize(mode, config, boundaries[, same_fluid, ...])

Perform a multi-objective optimization using NSGA2.

Module Contents

carbatpy.optimizations.opti_NSGA2.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)[source]

Perform a multi-objective optimization using NSGA2.

Sets up the problem, initializes the NSGA2 algorithm, handles parallelization, and executes the optimization using Pymoo.

Parameters:
  • mode (str) – Optimization mode. Must currently be '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 to True.

  • heat_losses (float) – Fraction of heat losses in the system. Only used in 'cb' mode. Defaults to 0.0.

  • verbose (bool) – Whether to print progress information. Defaults to True.

  • n_processes (int | None) – Number of parallel processes. Auto-detected via default_n_processes() if None.

  • maxtasksperchild (int) – Maximum number of tasks per worker process. Defaults to 20.

  • n_ieq_constr (int) – Number of inequality constraints. Defaults to 3.

  • pop_size (int) – Population size for NSGA2. Defaults to 50.

  • n_offspring (int | None) – Number of offspring per generation. Defaults to NSGA2 internal rules if None.

  • sampling_iterations (int) – Iterations for Latin Hypercube sampling. Defaults to 50.

  • crowding_func (str) – Crowding distance function for survival selection. Defaults to 'pcd'.

  • eliminate_duplicates (bool) – Whether to remove duplicate solutions. Defaults to True.

  • 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.

  • save_history (bool) – Whether to save the optimization history. Defaults to False.

  • return_least_infeasible (bool) – Whether to return the least infeasible solution if no feasible solution is found. Defaults to False.

Raises:

ValueError – If boundaries is None or mode is not supported.

Returns:

Result object containing the Pareto front, best solutions, and other optimization metadata.

Return type:

pymoo.core.result.Result