You are asked to apply Simulated Annealing and Genetic Algorithms to a variant of the Knapsack problem: Certificate in Python Programming Assignment, SETU, Ireland
University | South East Technological University (SETU) |
Subject | Certificate in Python Programming |
Problem: You are asked to apply Simulated Annealing and Genetic Algorithms to a variant of the Knapsack problem. In this knapsack problem, you have 20 items in total with each having a separate value and mass. Your objective is to minimize mass while maximizing value. There are 20 items in total you can choose from, but the knapsack can only hold 10 items and can hold a maximum of 25Kg. The value and mass of the items are given in the following table.
It is recommended that you make a two-dimensional list (or two one-dimensional lists) for the table above. You should represent a knapsack as a list of 10 indices to represent your ten items with each index referring to an entry in the table above. An index of −1 should be used to state that the current slot in the knapsack is empty. This will make the problem amenable to both Simulated Annealing and Genetic Algorithms. You must provide an implementation for Simulated Annealing and another implementation for Genetic Algorithms.