Skip to content

Tunny-gh/Benckmark-plot

Repository files navigation

Optimization Function Visualization

A Python library for visualizing single-objective and multi-objective optimization benchmark functions commonly used in optimization algorithm research and testing.

Features

Single-Objective Functions

  • Rosenbrock (Banana): Classic optimization test function with global minimum at (1, 1)
  • Ackley: Multimodal function with global minimum at (0, 0)
  • Rastrigin: Highly multimodal function with global minimum at (0, 0)
  • Schwefel: Deceptive multimodal function with global minimum at (420.9687, 420.9687)
  • Sphere: Simple unimodal function with global minimum at (0, 0)
  • Griewank: Multimodal function with global minimum at (0, 0)

Multi-Objective Functions

  • DTLZ1: Linear Pareto front
  • DTLZ2: Concave Pareto front (circular)
  • ZDT1: Convex Pareto front
  • ZDT2: Non-convex Pareto front

Visualization Options

  • 3D Surface Plots: Four different viewing angles (top, front, side, perspective)
  • Contour Plots: 2D contour visualization with optimal points marked
  • Pareto Front Visualization: For multi-objective functions
  • Backend Support: Both Matplotlib and Plotly for interactive/static plots

Requirements

  • Python ≥ 3.13
  • NumPy ≥ 1.24.0
  • Matplotlib ≥ 3.6.0
  • Plotly ≥ 5.0.0

Installation

# Install dependencies using uv (recommended)
uv sync

# Or using pip
pip install numpy matplotlib plotly

Usage

Single-Objective Functions

# Using matplotlib backend
python main_so.py matplotlib

# Using plotly backend (interactive)
python main_so.py plotly

# Save figures to figs folder
python main_so.py plotly --save

Multi-Objective Functions

# Using matplotlib backend
python main_mo.py matplotlib

# Using plotly backend (interactive)
python main_mo.py plotly

# Save figures to figs folder
python main_mo.py plotly --save

Command Line Options

  • matplotlib or plotly: Choose visualization backend
  • --save or -s: Save generated figures to the figs/ directory

Project Structure

graph/
├── single_objective/
│   ├── optimization_functions.py    # Single-objective function definitions
│   └── visualization.py            # 3D and contour plotting utilities
├── multi_objective/
│   ├── mo_optimization_functions.py # Multi-objective function definitions
│   └── mo_visualization.py         # Pareto front visualization
├── figs/                           # Generated visualization files
├── main_so.py                      # Single-objective visualization entry point
├── main_mo.py                      # Multi-objective visualization entry point
└── pyproject.toml                  # Project configuration

Output

The visualization generates:

Single-Objective Functions

  • 4 different 3D surface plot views per function
  • 1 contour plot per function
  • Optimal points marked in red

Multi-Objective Functions

  • Objective space scatter plots
  • True Pareto front overlays (where analytical solutions exist)
  • Zoomed views of Pareto front regions

All visualizations clearly show the characteristics of each optimization landscape, making them useful for:

  • Understanding optimization problem difficulty
  • Algorithm testing and comparison
  • Educational purposes in optimization courses
  • Research presentations

Development

# Install development dependencies
uv sync --group dev

# Run linting
ruff check .

About

Plotting benchmark functions in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages