Multi-user cooperative diversity is a recent technique promising great improvement of the performance of wireless communication systems operating in fading environments. Based on combinatorial optimization theory and specifically on the so-called knapsack problem, this paper presents a method of optimizing the selection among the potential cooperating users, when amplify-and-forward relays are used. In particular, two optimization problems are studied: the error probability minimization subject to total energy consumption constraints, and the dual one, the energy consumption minimization under error performance constraints. Depending on the frequency of repeating this selection, the above problems are categorized into shortterm and long-term node selection. Numerical examples verify the expected knapsack scheme's advantage of adapting the number of cooperating users, depending on the desired performance-consumption tradeoff. Moreover, long-term node selection seems to lead to similar error or consumption performance compared to the short-term one, despite its simplicity.