porcupy.utils.interactive_visualization
Interactive visualization module for the Crested Porcupine Optimizer (CPO).
This module provides interactive visualization tools and dashboard components for monitoring and analyzing the CPO algorithm’s performance in real-time.
Classes
Interactive dashboard for monitoring CPO optimization in real-time. |
|
Interactive dashboard for parameter tuning and sensitivity analysis. |
Functions
|
Create an interactive plot for exploring the optimization landscape. |
Module Contents
- class porcupy.utils.interactive_visualization.OptimizationDashboard(objective_func: Callable, bounds: Tuple[numpy.ndarray, numpy.ndarray], dimensions: int = 2, update_interval: float = 0.5, figsize: Tuple[int, int] = (15, 10))[source]
Interactive dashboard for monitoring CPO optimization in real-time.
This dashboard displays multiple visualizations simultaneously, including: - Convergence history - Population size history - Diversity metrics - Defense mechanism usage - Current porcupine positions
The dashboard updates in real-time during optimization.
- update(iteration: int, best_cost: float, pop_size: int, positions: numpy.ndarray, best_position: numpy.ndarray, defense_types: List[str])[source]
Update the dashboard with new optimization data.
- Parameters:
iteration (int) – Current iteration number.
best_cost (float) – Current best cost value.
pop_size (int) – Current population size.
positions (ndarray) – Current positions of the porcupines, shape (pop_size, dimensions).
best_position (ndarray) – Current global best position, shape (dimensions,).
defense_types (list) – List of defense mechanisms used by each porcupine.
- class porcupy.utils.interactive_visualization.ParameterTuningDashboard(parameter_name: str, parameter_range: List[float], result_metric: str = 'Best Cost', figsize: Tuple[int, int] = (12, 8))[source]
Interactive dashboard for parameter tuning and sensitivity analysis.
This dashboard allows for real-time visualization of how different parameter values affect the performance of the CPO algorithm.
- update(parameter_value: float, result: float, convergence_history: List[float] | None = None)[source]
Update the dashboard with new parameter tuning results.
- porcupy.utils.interactive_visualization.create_interactive_optimization_plot(objective_func: Callable, bounds: Tuple[numpy.ndarray, numpy.ndarray], initial_positions: numpy.ndarray, figsize: Tuple[int, int] = (10, 8))[source]
Create an interactive plot for exploring the optimization landscape.
- Parameters:
objective_func (callable) – The objective function to visualize.
bounds (tuple) – A tuple (lb, ub) containing the lower and upper bounds.
initial_positions (ndarray) – Initial positions of the porcupines, shape (pop_size, 2).
figsize (tuple, optional) – Figure size as (width, height) in inches (default: (10, 8)).
- Returns:
A tuple containing (fig, ax, scatter) for further customization.
- Return type: