A high-performance, interactive 3D visualization tool for studying metaheuristic optimization algorithms. OptiScape provides an immersive "playground" environment where students and researchers can visualize how different algorithms (like Cuckoo Search, PSO, and Genetic Algorithms) navigate complex mathematical landscapes in real-time.
- Cuckoo Search (CS): Visualizes random LΓ©vy flight walks and nest abandonment mechanics using the original selection logic.
- Particle Swarm Optimization (PSO): Demonstrates flocking behaviors with customizable inertia and social/cognitive coefficients.
- Genetic Algorithm (GA): Shows population evolution with multiple selection methods (Tournament, Roulette Wheel, Rank-based) and crossover strategies (Arithmetic, Uniform, Blend).
- Simulated Annealing (SA): Visualizes temperature-based exploration vs. exploitation.
- Random Search: A baseline for comparison.
- Interactive Info: Each algorithm includes a detailed scientific description accessible via the info button (βΉοΈ) in the UI.
Explore agents interacting with complex objective functions, each rendered in interactive 3D:
- Ackley Function: The "Egg Carton" landscape with many local minima.
- Rastrigin Function: A highly multimodal "field of needles."
- Rosenbrock Function: The classic "Valley/Banana" optimization problem.
- Schwefel Function: A deceptive landscape with distant global optima.
- Sphere Function: A simple convex bowl for sanity testing.
- Real-time Parameter Tuning: Adjust algorithm-specific parameters (e.g., Mutation Rate, Inertia, Discovery Rate) and landscape parameters (e.g., Schwefel Frequency, Ackley Amplitude) on the fly without restarting.
- Simulation Controls:
- Play/Pause: Run the simulation continuously at your desired speed
- Step: Execute one generation at a time for detailed analysis
- Reset: Restart the simulation from generation 0
- Visual Aids: Toggle Heatmaps and Auto-Rotation.
- Live Charts: Real-time plotting of convergence (Best Fitness vs. Generation).
- Statistical Dashboard: Live metrics including:
- Population Diversity (Standard Deviation)
- Average Fitness
- Success Rate (standardized across all landscapes)
- Total Generations counter
- Enhanced Export: Download comprehensive simulation data as CSV including:
- Algorithm-specific parameters (e.g., GA selection method, crossover method, mutation rate)
- Landscape parameters (e.g., Schwefel frequency, Ackley amplitude)
- Complete generation-by-generation statistics
- Comparison Mode: Run benchmarks to compare the performance of different algorithm configurations.
- Fully Responsive: Optimized for phones, tablets, and desktops with adaptive layouts.
- Progressive Web App (PWA):
- Install as Native App: Add to home screen on iOS and Android for standalone experience
- Offline Support: Service worker caching for reliable offline functionality
- Fullscreen Display: Automatic fullscreen mode with standalone display override
- App Icons: Custom 192x192 and 512x512 maskable icons
- Fullscreen Mode: Dedicated fullscreen button (βΆ) for immersive 3D viewing on mobile devices in landscape orientation.
- Touch Controls: Smooth, responsive sliders with
touch-actionoptimization to prevent scroll conflicts. - Gesture Support: Pinch-to-zoom, drag-to-rotate, and two-finger pan on 3D canvas.
- Adaptive Rendering:
- Camera, lighting, and fog automatically scale based on landscape size
- Particle and beacon sizes adjust dynamically for visibility across all terrains
- Optimized geometry recycling for smooth real-time parameter updates
- Performance Optimized: Automatic particle count reduction on mobile devices.
- Orientation Aware: Adapts to portrait and landscape modes seamlessly with landscape-specific UI density.
- Background Music: Ambient background music that enhances the visualization experience
- Sound Effects: Cuckoo sound effect when using the Cuckoo Search algorithm
- Music Toggle: Easy-to-use toggle button to enable/disable audio
- Auto-play Support: Intelligent audio initialization with browser auto-play policy compliance
π Read the Mobile Guide for detailed usage instructions.
- Visual Engine: Three.js (WebGL)
- Analytics: Chart.js
- Core: Vanilla JavaScript (ES6 Modules)
- Styling: Custom CSS3 (Glassmorphism design)
- Node.js installed (only for running the local dev server).
-
Clone the repository:
git clone https://github.com/Tejaromalius/OptiScape.git cd OptiScape -
Start the local server: This project uses
npxto serve static files. No heavynpm installis required for dependencies as libraries are loaded via CDN or ES modules.npm start
Alternatively, you can use any static file server like generic
python -m http.serveror VS Code's Live Server. -
Open in Browser: Navigate to
http://localhost:3000(or the port shown in your terminal).
/
βββ assets/ # Static assets (icons, audio)
β βββ icons/ # PWA app icons (192x192, 512x512)
β βββ sound.mp3 # Background music and sound effects
βββ css/ # Styling and UI design
βββ js/
β βββ algorithms/ # Logic for CS, PSO, GA, SA
β βββ landscapes/ # Math formulas for objective functions (Ackley, etc.)
β βββ managers/ # Simulation loop and state management
β βββ ui/ # User Interface event handling
β βββ utils/ # Math helpers and data processing
β βββ main.js # Entry point and Three.js scene setup
β βββ config.js # Global configuration and event bus
βββ index.html # Application entry point
βββ manifest.json # PWA manifest for app installation
βββ sw.js # Service worker for offline support
βββ package.json # Script definitions
βββ README.md # Project documentation
Concept: Inspired by the obligate brood parasitism of some cuckoo species, combined with the LΓ©vy flight behavior of some birds and fruit flies.
Mathematical Formulation:
The algorithm maintains a population of
-
LΓ©vy Flights (Global Random Walk): New solutions
$x^{(t+1)}$ are generated using a LΓ©vy flight:$$x_i^{(t+1)} = x_i^{(t)} + \alpha \oplus \text{Levy}(\lambda)$$ Where
$\alpha > 0$ is the step size scaling factor.The step length
$s$ follows the LΓ©vy distribution:$$\text{Levy} \sim u = t^{-\lambda}, \quad (1 < \lambda \le 3)$$ In this implementation, the step length is calculated using Mantegna's Algorithm:
$$\text{step} = \frac{u}{|v|^{1/\beta}}$$ Where
$u$ and$v$ are drawn from normal distributions:$$u \sim N(0, \sigma_u^2), \quad v \sim N(0, 1)$$ $$\sigma_u = \left\lbrace \frac{\Gamma(1+\beta) \sin(\pi \beta / 2)}{\Gamma[(1+\beta)/2] \beta 2^{(\beta-1)/2}} \right\rbrace^{1/\beta}$$ (Here
$\beta = \lambda - 1$ ). -
Selection: A randomly chosen nest
$j$ is compared with the new solution. If the new solution fitness$f_{new}$ is better than$f_j$ , it replaces nest$j$ . -
Discovery/Abandonment (Local Random Walk): A fraction
$p_a$ of the worst nests are abandoned and new ones are built. In this simulator, this is implemented as a random re-initialization of the abandoned nests within the bounds:$$x_i^{new} = \text{LowerBound} + r \times (\text{UpperBound} - \text{LowerBound})$$ Where
$r \sim U(0, 1)$ .
Concept: Simulates the social behavior of bird flocking or fish schooling.
Mathematical Formulation:
Each particle
-
Velocity Update:
$$v_i^{(t+1)} = w v_i^{(t)} + c_1 r_1 (pBest_i - x_i^{(t)}) + c_2 r_2 (gBest - x_i^{(t)})$$ Where:
-
$w$ : Inertia weight. -
$c_{1}, c_{2}$ : Cognitive and social acceleration coefficients. -
$r_{1}, r_{2} \sim U(0, 1)$ . -
$pBest_i$ : Personal best position of particle$i$ . -
$gBest$ : Global best position of the swarm.
-
-
Position Update:
$$x_i^{(t+1)} = x_i^{(t)} + v_i^{(t+1)}$$
Concept: Based on the principles of natural selection and genetics.
Mathematical Formulation:
-
Selection Methods:
-
Tournament Selection:
$(k=3)$ randomly selected individuals compete, best wins. - Roulette Wheel Selection: Fitness-proportionate selection where individuals with higher fitness have greater probability of selection.
- Rank-based Selection: Selection based on fitness rank rather than absolute fitness values.
-
Tournament Selection:
-
Crossover Strategies:
-
Arithmetic Crossover:
$Child = \gamma \cdot Parent_1 + (1 - \gamma) \cdot Parent_2$ , where$\gamma \sim U(0, 1)$ . - Uniform Crossover: Each gene randomly selected from either parent with equal probability.
-
Blend Crossover (BLX-Ξ±):
$Child = Parent_1 + \alpha \cdot (Parent_2 - Parent_1)$ , where$\alpha \in [-0.5, 1.5]$ .
-
Arithmetic Crossover:
-
Mutation: Uniform mutation with probability
$p_m$ .$$x_{new} = x_{old} + \delta, \quad \delta \in [-0.1 \cdot \text{Bounds}, 0.1 \cdot \text{Bounds}]$$
Concept: Probabilistic technique for approximating the global optimum of a given function, inspired by annealing in metallurgy.
Mathematical Formulation:
-
Exploration:
$$x_{new} = x_{curr} + \epsilon$$ Where step size
$\epsilon$ scales with the current temperature$T$ . -
Acceptance (Metropolis Criterion): Let
$\Delta E = f(x_{new}) - f(x_{curr})$ . If$\Delta E < 0$ , accept the new state. Else, accept with probability:$$P(\text{accept}) = \exp\left( -\frac{\Delta E}{T} \right)$$ -
Cooling Schedule: Geometric cooling.
$$T_{k+1} = \alpha T_k$$ Where
$\alpha$ is the cooling rate (e.g., 0.99).
A widely used multimodal test function. It is characterized by a nearly flat outer region (due to the exponential term) and a large hole at the center.
-
Global Minimum:
$0$ at$(0, 0)$ .
A highly multimodal function with a regular distribution of local minima. It is based on the Sphere function with a cosine modulation to create the "needle field."
-
Global Minimum:
$0$ at$(0, 0)$ .
Also known as the Valley or Banana function. The global minimum is inside a long, narrow, parabolic shaped flat valley. To find the valley is trivial. To converge to the global minimum is difficult.
-
Global Minimum:
$0$ at$(a, a^2)$ . (Standard: $(1, 1)$).
Complex function with many local minima. The global minimum is far from the next best local minima. This implementation includes an interactive frequency parameter that allows you to adjust the "waviness" of the landscape, creating more or fewer local minima for experimentation.
-
Global Minimum:
$0$ at$(420.9687, 420.9687)$ (at standard frequency = 1.0). - Interactive Parameters: Vertical Offset (200-600), Frequency/Waviness (0.5-2.0).
A simple unimodal convex function used as a baseline to check algorithm sanity and convergence speed.
-
Global Minimum:
$0$ at$(0, 0)$ .
Contributions are welcome! If you want to add a new algorithm (e.g., Firefly Algorithm, Ant Colony) or a new landscape:
- Create a new file in
js/algorithms/orjs/landscapes/. - Extend the base
AlgorithmorLandscapeclass. - Register it in
index.html(UI) andscaffold.js(Mapping).
