Problem solving using generic algorithms
Generic algorithms ( GA) can be very useful for solving complex optimization problems such as the knapsack problem. The knapsack problem aims to maximise the total profit for a specific selection of items while simultaneously not exceeding the knapsack capacity. Every item has a profit and a weight.
This is how I initialise everything with the given data from the lab:
p = vector<int> = { 92, 57, 49, 68, 60 ,43 ,67, 84, 87, 72 }; // profits
w = vector<int> = { 23, 31, 29, 44, 53 ,38 ,63, 85, 89, 82 }; // weights
c = 165; // capacity
os = vector<int> = {1, 1, 1, 1, 0, 1, 0, 0, 0, 0 }; // optional selection
n = profits.size(); // number of items
This is how I initialise everything with the given data from the lab:
p = vector<int> = { 92, 57, 49, 68, 60 ,43 ,67, 84, 87, 72 }; // profits
w = vector<int> = { 23, 31, 29, 44, 53 ,38 ,63, 85, 89, 82 }; // weights
c = 165; // capacity
os = vector<int> = {1, 1, 1, 1, 0, 1, 0, 0, 0, 0 }; // optional selection
n = profits.size(); // number of items
Comments
Post a Comment