evox.workflows.eval_monitor
#
Module Contents#
Classes#
Evaluation monitor. Used for both single-objective and multi-objective workflow. Hooked around the evaluation process, can monitor the offspring, their corresponding fitness and keep track of the evaluation count. Moreover, it can also record the best solution or the pareto front on-the-fly. |
Functions#
Return the unique elements of the input tensor, as well as the unique index. |
API#
- evox.workflows.eval_monitor.unique(x: torch.Tensor, dim=0)[source]#
Return the unique elements of the input tensor, as well as the unique index.
- class evox.workflows.eval_monitor.EvalMonitor(multi_obj: bool = False, full_fit_history: bool = True, full_sol_history: bool = False, full_pop_history: bool = False, topk: int = 1, device: torch.device | None = None)[source]#
Bases:
evox.core.Monitor
Evaluation monitor. Used for both single-objective and multi-objective workflow. Hooked around the evaluation process, can monitor the offspring, their corresponding fitness and keep track of the evaluation count. Moreover, it can also record the best solution or the pareto front on-the-fly.
Initialization
Initialize the monitor.
- Parameters:
multi_obj – Whether the optimization is multi-objective. Defaults to False.
full_fit_history – Whether to record the full history of fitness value. Default to True. Setting it to False may reduce memory usage.
full_sol_history – Whether to record the full history of solutions. Default to False. Setting it to True may increase memory usage.
topk – Only affect Single-objective optimization. The number of elite solutions to record. Default to 1, which will record the best individual.
device – The device of the monitor. Defaults to None.
- Note:
If any of
full_fit_history
orfull_sol_history
is set to True, this monitor will introduce a graph break intorch.compile
.
- fitness_history: List[torch.Tensor]#
None
- solution_history: List[torch.Tensor]#
None
- auxiliary: List[Dict[str, torch.Tensor]]#
None
- get_pf_fitness(deduplicate=True) torch.Tensor [source]#
Get the approximate pareto front fitness values of all the solutions evaluated so far. Requires enabling
full_fit_history
.
- get_pf_solutions(deduplicate=True) torch.Tensor [source]#
Get the approximate pareto front solutions of all the solutions evaluated so far. Requires enabling both
full_sol_history
andfull_sol_history
. Ifdeduplicate
is set to True, the duplicated solutions will be removed.
- get_pf(deduplicate=True) Tuple[torch.Tensor, torch.Tensor] [source]#
Get the approximate pareto front solutions and fitness values of all the solutions evaluated so far. Requires enabling both
full_sol_history
andfull_sol_history
. Ifdeduplicate
is set to True, the duplicated solutions will be removed.
- plot(problem_pf=None, source='eval', **kwargs)[source]#
Plot the fitness history. If the problem’s Pareto front is provided, it will be plotted as well.
- Parameters:
problem_pf – The Pareto front of the problem. Default to None.
source – The source of the data, either “eval” or “pop”, default to “eval”. When “eval”, the fitness from the problem evaluation side will be plotted, representing what the problem sees. When “pop”, the fitness from the population inside the algorithm will be plotted, representing what the algorithm sees.
kwargs – Additional arguments for the plot.