Illustration of the knapsack problem solved using a genetic algorithm. The items represented by the chromosomes are those from Image:Knapsack greedy.svg.
Problem
Which boxes to choose to maximize the amount of money while still fullfilling a given constraint (ie. capacity of the bag) ?
Solution
Basic genetic algorithm :
Generate a population of individuals whose chromosomes represent the selected items (1 = object is selected, 0 = not selected). Each individual is tested according to a fitness function (in knapsack problem, the goal is to optimize the money stored in the bag).
The evolution starts, the bad solutions are discarded, the best individuals are used for reproduction and share their chromosomes (cross-over operator) or are simply copied, mutations may also happen (change a 0 to 1 and vice-versa).
After several generations, the population converges towards an approximated solution or the real solution with luck.
делиться произведением – копировать, распространять и передавать данное произведение
создавать производные – переделывать данное произведение
При соблюдении следующих условий:
атрибуция – Вы должны указать авторство, предоставить ссылку на лицензию и указать, внёс ли автор какие-либо изменения. Это можно сделать любым разумным способом, но не создавая впечатление, что лицензиат поддерживает вас или использование вами данного произведения.
распространение на тех же условиях – Если вы изменяете, преобразуете или создаёте иное произведение на основе данного, то обязаны использовать лицензию исходного произведения или лицензию, совместимую с исходной.
== Description == Illustration of the knapsack problem solved using a genetic algorithm. Problem : Which boxes to choose to maximize the amount of money while still fullfilling a given constraint (ie. capacity of the bag) ? Solution (basic genetic algor