Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class NSGA-II Hybrid Multi-Objective Optimization MOPSO #2: NSGA-II from Scratch: Non-Dominated Sorting & Crowding Distance”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
Here is the final result, the NSGA-2 we wrote ourselves. From generation 10 which was still messy to generation 400, the population moves down the objective space and sticks to the true Pareto front ZDT-1, ZDT-2, and ZDT-3. Let's get started. Hello, welcome to episode two of the Hybrid Multi-Objective Meta Heuristics series. NSGA-2, developed by DEB and colleagues in 2002, is the most cited multi-objective algorithm and the mandatory benchmark in every paper. Its two ideas are simple but clever, sort solutions by front layers, and maintain spread with crowding distance. Today we are writing it from scratch.
Create a file NSGA-2.py The non-dominated sorting function calculates the dominance matrix, then peels off the front one by one, any solution that is not dominated becomes front zero, is removed, and the next front is found from the rest. The crowding distance function measures neighbor density. For each objective, solutions are sorted and the distance is calculated from the difference between left and right neighbors. Solutions at both ends are given an infinite value to ensure the ends of the front are always preserved. Simulated binary crossover produces two offspring around both parents,
with distribution controlled by the distribution index eta, mimicking the behavior of binary crossover on real numbers. Polynomial mutation shifts the average of one variable per solution. Environmental selection combines parents and offspring, then selects the top hundred, with lower front rankings prioritized, and among the last front, those with larger crowding distance are selected.
The NSGA-2 function ties it all together. Each generation, binary tournament selects parents, lower rankings win And if tied, the one with larger crowding distance wins. Offspring are created using SBX and mutation, then elitist selection chooses the next generation. The Pareto front is saved in a specific generation to be visualized.
Create the test file underscore NSGA-2.py and run it. An example of six solutions produces ranks 0, 1, 0, 2, 3, 0, according to their dominance layer. After 400 generations, the average distance to the actual front is ZDT1 0.0047, ZDT2 0.0034, and ZDT3 0.0107, each taking only about 1 second. Let's look at the graph. At generation 10, the front is still far above. At generation 100 it starts to approach, and at generation 40,000 it closely adheres to the actual front with an average of 5 segments, including 5 broken segments of ZDT3. Done. We have written NSGA-II from scratch using fast non-dominated sorting, crowding distance, SBX, polynomial mutation, and elitist selection, then validated it on 3 test functions. In the next episode, we build a different approach, Mo-PSO with a Pareto Archive. Currently working on a thesis, dissertation, or research in the field of optimization and artificial intelligence? Cerdas Inovasi Digital helps implement optimization algorithms, from NSGA-II and Mo-PSO, algorithm design hybrid, up to hypervolume metrics and IG, deserta statistical test for algorithm comparison, as well as opening Python programming courses for engineering. Want to master the entire series, from Pareto concepts up to large-scale case studies? All 6 episodes, complete with PDF step-by-step guides and source code, are available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or one-time payment of Rp999.000 for lifetime access. Want just one class? Buy a single class with lifetime access. Subscribe now at the premium page cerdasinovasidigital.com Contact our WhatsApp, or visit cerdasinovasidigital.com Thank you for watching, See you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →