2 %> Runs example 27.2 of \cite Bier15-book, solving the problem
using the greedy heuristic
5 %> @author Michel Bierlaire
6 %> @date Tue Apr 14 11:28:22 2015
9 u = [80 31 48 17 27 84 34 39 46 58 23 67]
' ; 10 w = [84 27 47 22 21 96 42 46 54 53 32 78]' ;
13 printf(
"Final utility: %d, final weight: %d\n",xopt
'*u, xopt'*w)
function knapsackGreedy(in u, in w, in capacity)